ocra-recipes
Doxygen documentation for the ocra-recipes repository
|
A concatenation of base variables and other composite variables. More...
#include <Variable.h>
Public Member Functions | |
CompositeVariable (const std::string &name) | |
CompositeVariable (const std::string &name, Variable &var) | |
CompositeVariable (const std::string &name, Variable &var1, Variable &var2) | |
CompositeVariable (const std::string &name, const std::vector< Variable * > &vars) | |
void | clear () |
Detaches all children. More... | |
Variable & | operator() (size_t i) |
CompositeVariable & | addByMerge (Variable &v) |
CompositeVariable & | getTimeDerivative () |
Get the time derivative/primitive of the variable. More... | |
CompositeVariable & | getTimePrimitive () |
const Variable & | operator() (size_t i) const |
int | isAncestorOf (const Variable &var) const |
Returns the number of levels that separate the component from a potential child. More... | |
void | printSubTree (int depth, std::ostream &os) const |
Overload in ComponentDerived and CompositeDerived to simply call printTree_impl(). More... | |
CompositeVariable & | add (Variable &child) |
Attach/detach the child to/from this node. More... | |
CompositeVariable & | remove (Variable &child) |
Public Member Functions inherited from ocra::Composite< Variable, CompositeVariable, VariableParenthood > | |
bool | isParentOf (const Variable &node) |
size_t | getNumChildhoods () const |
Basic access to the children. More... | |
const parenthood_t_ & | getChildhood (size_t i) const |
const_iterator_ | children_begin () const |
Iterator range on the children. More... | |
iterator_ | children_begin () |
const_iterator_ | children_end () const |
iterator_ | children_end () |
Public Member Functions inherited from ocra::Variable | |
Variable (const std::string &name="") | |
virtual | ~Variable ()=0 |
The variable is automatically detached from parents and children at destruction. More... | |
virtual const std::string & | getName () const |
virtual bool | isBaseVariable () const |
int | getSize () const |
operator const VectorXd & () const | |
Implicit conversion to an Eigen vector. More... | |
const VectorXd & | getValue () const |
void | setValue (const VectorXd &value) |
bool | hasTimeDerivative () const |
bool | hasTimePrimitive () const |
void | getRelativeMappingOf (const Variable &subVariable, std::vector< int > &mapping) const |
Returns the indexes of a subvariable in the variable. More... | |
size_t | getNumberOfChildren () const |
Returns 0 in BaseVariable and the number of childhoods otherwise. More... | |
void | printNode (int depth, std::ostream &os) const |
Prints the name of the variables; preprends 3*depth blank spaces. More... | |
double | operator[] (size_t i) const |
double | at (size_t i) const |
void | createTimeDerivative (const std::string &name) |
Creates a time derivative/primitive with a given name. More... | |
void | createTimePrimitive (const std::string &name) |
Public Member Functions inherited from ocra::Component< Variable, CompositeVariable, VariableParenthood > | |
bool | isChildOf (const CompositeVariable &node) |
void | printTree (std::ostream &os) |
size_t | getNumParenthoods () const |
Basic access to the parents. More... | |
const parenthood_t & | getParenthood (size_t i) const |
const_iterator | parents_begin () const |
Iterator range on the set of parents. More... | |
iterator | parents_begin () |
const_iterator | parents_end () const |
iterator | parents_end () |
int | isDescendantOf (const CompositeVariable &node) const |
Returns the number of levels that separates the component from a potential parent. More... | |
int | isDescendantOf (const Variable &node) const |
Public Member Functions inherited from ocra::ObserverSubject | |
ObserverSubject () | |
virtual | ~ObserverSubject () |
Public Member Functions inherited from ocra::Observer | |
virtual | ~Observer () |
template<int EVT> | |
void | bind (SubjectBase< EVT > &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
template<int EVT> | |
void | stopPropagation () |
Public Member Functions inherited from ocra::ObserverBase< EVT_RESIZE > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
void | bind (subject_type &subject) |
Call this method to automatically propagate observed events to observers connected to the subject given in argument. More... | |
Public Member Functions inherited from ocra::Subject | |
virtual | ~Subject () |
template<int EVT, class Derived , class Base > | |
void | connect (Derived &object, void(Base::*newCallback)(int)) const |
Call this method to register a non-static method as a callback. More... | |
template<int EVT> | |
void | connect (void(*newCallback)(int)) const |
Call this method to register a free function as a callback. More... | |
template<int EVT, class Derived , class Base > | |
void | disconnect (Derived &object, void(Base::*callbackToErase)(int)) const |
Disconnect non-static method. More... | |
template<int EVT> | |
void | disconnect (void(*callbackToErase)(int)) const |
Disconnect free function. More... | |
template<int EVT> | |
void | propagate () const |
template<int EVT> | |
void | propagate (int timestamp) const |
Public Member Functions inherited from ocra::SubjectBase< EVT_RESIZE > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Public Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_DEPENDENCIES > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Public Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_VALUE > | |
void | connect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type newCallback) const |
Call this method to register a non-static method as a callback. More... | |
void | connect (typename SubjectBaseTraits< EVT, void >::callback_type newCallback) const |
Call this method to register a free function as a callback. More... | |
void | disconnect (T &object, typename SubjectBaseTraits< EVT, T >::callback_type callback) const |
Disconnect non-static method. More... | |
void | disconnect (typename SubjectBaseTraits< EVT, void >::callback_type callbackToErase) const |
Disconnect free function. More... | |
void | propagate (int timestamp) const |
void | propagate () const |
Protected Member Functions | |
void | do_setValue (const VectorXd &value) |
This method will attempt to assign a given value to the memory map. More... | |
size_t | do_getNumberOfChildren () const |
Always return getNumChildhoods. More... | |
void | onAttachedChild (const parenthood_t &child) |
void | onDetachedChild (const parenthood_t &child) |
Variable * | do_createTimeDerivative (const std::string &name) |
Variable * | do_createTimePrimitive (const std::string &name) |
Protected Member Functions inherited from ocra::Composite< Variable, CompositeVariable, VariableParenthood > | |
Composite () | |
~Composite () | |
void | attach (Variable &child) |
Attaches a Component to a Composite by simply creating a Parenthood bond between them. More... | |
void | detach (Variable &child) |
Erases a Parenthood bond between a Composite and a Component. More... | |
int | isAncestorOf_impl (const Variable &node) const |
void | printTree_impl (int depth, std::ostream &os) const |
virtual void | onAttachedChild (const parenthood_t_ &child) |
Default implementation of the callbacks, to overload in the private part of class CompositeDerived. More... | |
virtual void | onDetachedChild (const parenthood_t_ &child) |
Protected Member Functions inherited from ocra::Variable | |
void | onAttachedParent (const parenthood_t &parent) |
void | onDetachedParent (const parenthood_t &parent) |
Protected Member Functions inherited from ocra::Component< Variable, CompositeVariable, VariableParenthood > | |
virtual void | onAttachedParent (const parenthood_t &parent) |
Default implementation of the callbacks, to overload in class ComponentDerived. More... | |
virtual void | onDetachedParent (const parenthood_t &parent) |
Component () | |
~Component () | |
Protected Member Functions inherited from ocra::ObserverBase< EVT_RESIZE > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
void | stopPropagation () |
Call this method from your callbacks to avoid propagation to the bound subject (if any). More... | |
ObserverBase () | |
~ObserverBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_RESIZE > | |
SubjectBase () | |
~SubjectBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_DEPENDENCIES > | |
SubjectBase () | |
~SubjectBase () | |
Protected Member Functions inherited from ocra::SubjectBase< EVT_CHANGE_VALUE > | |
SubjectBase () | |
~SubjectBase () | |
Additional Inherited Members | |
Public Types inherited from ocra::Variable | |
typedef Component< Variable, CompositeVariable, VariableParenthood >::parenthood_t | parenthood_t |
Public Types inherited from ocra::Component< Variable, CompositeVariable, VariableParenthood > | |
typedef Variable | component_t |
Inherited typedefs. More... | |
typedef CompositeVariable | parent_t |
typedef Parenthood< Variable, CompositeVariable, VariableParenthood > | parenthood_t |
typedef std::vector< parenthood_t * >::const_iterator | const_iterator |
typedef std::vector< parenthood_t * >::iterator | iterator |
Protected Types inherited from ocra::ObserverBase< EVT_RESIZE > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
Protected Types inherited from ocra::ObserverBase< EVT_CHANGE_DEPENDENCIES > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
Protected Types inherited from ocra::ObserverBase< EVT_CHANGE_VALUE > | |
typedef SubjectBase< EVT > | subject_type |
typedef InvokerBase< EVT > | invoker_type |
Static Protected Member Functions inherited from ocra::Variable | |
static void | callInsertInMemoryMap (Variable &obj, const parenthood_t &child, size_t whereInChild, std::vector< const double * >::const_iterator start, std::vector< const double * >::const_iterator end) |
Proxy to the implementation of memory maps update. More... | |
static void | callRemoveFromMemoryMap (Variable &obj, const parenthood_t &child, size_t whereInChild, size_t numElements) |
static std::vector< const double * > & | getMemoryMap (Variable &obj) |
A concatenation of base variables and other composite variables.
Definition at line 357 of file Variable.h.
ocra::CompositeVariable::CompositeVariable | ( | const std::string & | name | ) |
Definition at line 410 of file Variable.cpp.
ocra::CompositeVariable::CompositeVariable | ( | const std::string & | name, |
Variable & | var | ||
) |
Definition at line 415 of file Variable.cpp.
ocra::CompositeVariable::CompositeVariable | ( | const std::string & | name, |
Variable & | var1, | ||
Variable & | var2 | ||
) |
Definition at line 421 of file Variable.cpp.
ocra::CompositeVariable::CompositeVariable | ( | const std::string & | name, |
const std::vector< Variable * > & | vars | ||
) |
Definition at line 428 of file Variable.cpp.
|
virtual |
Attach/detach the child to/from this node.
Reimplemented from ocra::Composite< Variable, CompositeVariable, VariableParenthood >.
Definition at line 580 of file Variable.cpp.
CompositeVariable & ocra::CompositeVariable::addByMerge | ( | Variable & | v | ) |
Definition at line 475 of file Variable.cpp.
void ocra::CompositeVariable::clear | ( | void | ) |
Detaches all children.
Definition at line 435 of file Variable.cpp.
|
protectedvirtual |
Implements ocra::Variable.
Definition at line 519 of file Variable.cpp.
|
protectedvirtual |
Implements ocra::Variable.
Definition at line 551 of file Variable.cpp.
|
protectedvirtual |
Always return getNumChildhoods.
Implements ocra::Variable.
Definition at line 641 of file Variable.cpp.
|
protectedvirtual |
This method will attempt to assign a given value to the memory map.
Implements ocra::Variable.
Definition at line 441 of file Variable.cpp.
|
virtual |
Get the time derivative/primitive of the variable.
If the derivative/primitive doesn't exist, it will be created automatically at the first call to this method.
Reimplemented from ocra::Variable.
Definition at line 455 of file Variable.cpp.
|
virtual |
Reimplemented from ocra::Variable.
Definition at line 460 of file Variable.cpp.
|
virtual |
Returns the number of levels that separate the component from a potential child.
Implements ocra::Component< Variable, CompositeVariable, VariableParenthood >.
Definition at line 509 of file Variable.cpp.
|
protected |
Definition at line 492 of file Variable.cpp.
|
protected |
Definition at line 501 of file Variable.cpp.
Variable & ocra::CompositeVariable::operator() | ( | size_t | i | ) |
Definition at line 465 of file Variable.cpp.
const Variable & ocra::CompositeVariable::operator() | ( | size_t | i | ) | const |
Definition at line 470 of file Variable.cpp.
|
virtual |
Overload in ComponentDerived and CompositeDerived to simply call printTree_impl().
You can also choose to reimplement the while function rather than calling the proposed printTree_impl method.
depth | is the current depth of the node. |
Implements ocra::Component< Variable, CompositeVariable, VariableParenthood >.
Definition at line 514 of file Variable.cpp.
|
virtual |
Reimplemented from ocra::Composite< Variable, CompositeVariable, VariableParenthood >.
Definition at line 620 of file Variable.cpp.