ocra-recipes
Doxygen documentation for the ocra-recipes repository
IFunctionProperties.cpp
Go to the documentation of this file.
3 #include <algorithm>
4 
5 
6 namespace ocra
7 {
9  bool explicitlyTimeDependant, bool separableTimeDependancy)
10  : _type(linearity)
11  , _convexityProperty(convexity)
12  , _continuityProperty(continuity)
13  , _timeDependant(explicitlyTimeDependant)
14  , _separableTimeDependancy(separableTimeDependancy)
15  {
16  ocra_assert((continuity==CONTINUITY_UNKNOWN) || (continuity>0 && continuity<=CONTINUITY_CINF));
17  }
18 
19 
21  {
22  return _type;
23  }
24 
26  {
27  return _convexityProperty;
28  }
29 
31  {
32  return _continuityProperty;
33  }
34 
36  {
37  _type = newType;
38  }
39 
41  {
42  _convexityProperty = newProperty;
43  }
44 
46  {
47  ocra_assert((newProperty==CONTINUITY_UNKNOWN) || (newProperty>0 && newProperty<=CONTINUITY_CINF));
48  _continuityProperty = newProperty;
49  }
50 
51  void IFunctionProperties::addProperty(const std::string& functionProperty)
52  {
53  std::vector<std::string>::iterator it = std::find(_properties.begin(), _properties.end(), functionProperty);
54  if (it == _properties.end())
55  _properties.push_back(functionProperty);
56  }
57 
58  void IFunctionProperties::removeProperty(const std::string& functionProperty)
59  {
60  std::vector<std::string>::iterator it = std::find(_properties.begin(), _properties.end(), functionProperty);
61  if (it != _properties.end())
62  _properties.erase(it);
63 
64  ocra_assert(std::find(_properties.begin(), _properties.end(), functionProperty) == _properties.end());
65  }
66 
67  const std::string& IFunctionProperties::getProperty(int i) const
68  {
69  return _properties[i];
70  }
71 
73  {
74  return (int)_properties.size();
75  }
76 
77  bool IFunctionProperties::hasProperty(const std::string& functionProperty) const
78  {
79  std::vector<std::string>::const_iterator it = std::find(_properties.begin(), _properties.end(), functionProperty);
80  return (it != _properties.end());
81  }
82 
84  {
85  return _timeDependant;
86  }
87 
89  {
90  return !_timeDependant || _separableTimeDependancy;
91  }
92 
94  {
95  _timeDependant = b;
96  }
97 
99  {
100  _separableTimeDependancy = b;
101  }
102 }
103 
104 // cmake:sourcegroup=Function
void addProperty(const std::string &functionProperty)
eFunctionConvexity getConvexityProperty(void) const
const std::string & getProperty(int i) const
void removeProperty(const std::string &functionProperty)
int getContinuityProperty(void) const
void changeType(eFunctionLinearity newType)
IFunctionProperties(eFunctionLinearity linearity=LINEARITY_UNDEFINED, eFunctionConvexity convexity=CONVEXITY_UNDEFINED, int continuity=CONTINUITY_UNKNOWN, bool explicitlyTimeDependant=false, bool separableTimeDependancy=true)
IFunctionProperties Constructor.
bool hasProperty(const std::string &functionProperty) const
Optimization-based Robot Controller namespace. a library of classes to write and solve optimization p...
int getNumberOfProperties(void) const
bool hasSeparableTimeDependancy(void) const
eFunctionLinearity getType(void) const
bool isExplicitlyTimeDependant(void) const
void changeConvexityProperty(eFunctionConvexity newProperty)
#define ocra_assert(ocra_expression)
Definition: ocra_assert.h:45
void changeContinuityProperty(int newProperty)