ocra-recipes
Doxygen documentation for the ocra-recipes repository
FunctionInterfaceMapping.h
Go to the documentation of this file.
1 
11 #ifndef _OCRABASE_FUNCTION_INTERFACE_MAPPING_H_
12 #define _OCRABASE_FUNCTION_INTERFACE_MAPPING_H_
13 
14 #include "ocra/optim/Function.h"
15 
16 namespace ocra
17 {//TODO update documentation
23  template<class Derived>
25 
26  template<class T> class Constraint;
27 
29 #define GET_FUNCTION(X) static_cast<X<Function>*>(this)->getFunction()
30 #define GET_FUNCTION_CONST(X) static_cast<const X<Function>* const>(this)->getFunction()
31 
36  template<template<class> class X >
38  {
39  int getDimension() const {return GET_FUNCTION_CONST(X).getDimension();}
40  void changeDimension(int newDimension) {GET_FUNCTION(X).changeDimension(newDimension);}
41  const std::string& getName() const {return GET_FUNCTION_CONST(X).getName();}
42  const Variable& getVariable() const {return GET_FUNCTION_CONST(X).getVariable();}
43  Variable& getVariable() {return GET_FUNCTION(X).getVariable();}
44  template<eFunctionAbility Ability>
45  void invalidate() {GET_FUNCTION(X).template invalidate<Ability>();}
46  void invalidateAll() {GET_FUNCTION(X).invalidateAll();}
47  template<eFunctionAbility Ability>
48  bool isValid() const {return GET_FUNCTION_CONST(X).template isValid<Ability>();}
49  template<eFunctionAbility Ability>
50  bool canCompute() const {return GET_FUNCTION_CONST(X).template canCompute<Ability>();}
51  template<eFunctionAbility Ability> const typename IFunction<Ability>::return_type&
52  get() const {return GET_FUNCTION_CONST(X).template get<Ability>();} //index
53  template<eFunctionAbility Ability> typename IFunction<Ability>::return_sub_type
54  get(int index) const {return GET_FUNCTION_CONST(X).template get<Ability>(index);}
55  const VectorXd& getValue() const {return GET_FUNCTION_CONST(X).getValue();}
56  double getValue(int index) const {return GET_FUNCTION_CONST(X).getValue(index);}
57  const MatrixXd& getJacobian() const {return GET_FUNCTION_CONST(X).getJacobian();}
58  MatrixXdRow getJacobian(int index) const {return GET_FUNCTION_CONST(X).getJacobian(index);}
59 
60 
61  eFunctionLinearity getType(void) const {return GET_FUNCTION_CONST(X).getType();}
62  eFunctionConvexity getConvexityProperty(void) const {return GET_FUNCTION_CONST(X).getConvexityProperty();}
63  int getContinuityProperty(void) const {return GET_FUNCTION_CONST(X).getContinuityProperty();}
64  const std::string& getProperty(int i) const {return GET_FUNCTION_CONST(X).getProperty(i);}
65  int getNumberOfProperties(void) const {return GET_FUNCTION_CONST(X).getNumberOfProperties();}
66  bool hasProperty(const std::string& functionProperty) const {return GET_FUNCTION_CONST(X).hasProperty(functionProperty);}
67  bool isExplicitlyTimeDependant(void) const {return GET_FUNCTION_CONST(X).isExplicitlyTimeDependant();}
68  bool hasSeparableTimeDependancy(void) const {return GET_FUNCTION_CONST(X).hasSeparableTimeDependancy();}
69  };
70 
71 
72 #undef GET_FUNCTION
73 #undef GET_FUNCTION_CONST
74 }
75 
76 #endif //_OCRABASE_FUNCTION_INTERFACE_MAPPING_H_
77 
78 // cmake:sourcegroup=Constraint
#define GET_FUNCTION_CONST(X)
#define GET_FUNCTION(X)
bool hasProperty(const std::string &functionProperty) const
ocra_function_traits< Property >::sub_type_t return_sub_type
Definition: IFunction.h:282
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
ocra_function_traits< Property >::type_t return_type
Definition: IFunction.h:281
Function class.
Definition: Function.h:77
Constraint class.
Definition: Constraint.h:100
This class represents a variable in a mathematical sense.
Definition: Variable.h:105
Eigen::DenseBase< MatrixXd >::ConstRowXpr MatrixXdRow
Definition: MathTypes.h:29
Declaration file of the Function class.