ocra-recipes
Doxygen documentation for the ocra-recipes repository
Public Member Functions | Protected Member Functions | List of all members
ocra::CompositeVariable Class Reference

A concatenation of base variables and other composite variables. More...

#include <Variable.h>

Inheritance diagram for ocra::CompositeVariable:
[legend]
Collaboration diagram for ocra::CompositeVariable:
[legend]

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...
 
Variableoperator() (size_t i)
 
CompositeVariableaddByMerge (Variable &v)
 
CompositeVariablegetTimeDerivative ()
 Get the time derivative/primitive of the variable. More...
 
CompositeVariablegetTimePrimitive ()
 
const Variableoperator() (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...
 
CompositeVariableadd (Variable &child)
 Attach/detach the child to/from this node. More...
 
CompositeVariableremove (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_tgetParenthood (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)
 
Variabledo_createTimeDerivative (const std::string &name)
 
Variabledo_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, VariableParenthoodparenthood_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)
 

Detailed Description

A concatenation of base variables and other composite variables.

Definition at line 357 of file Variable.h.

Constructor & Destructor Documentation

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.

Member Function Documentation

CompositeVariable & ocra::CompositeVariable::add ( Variable child)
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.

Variable * ocra::CompositeVariable::do_createTimeDerivative ( const std::string &  name)
protectedvirtual
See also
class ocra::Variable

Implements ocra::Variable.

Definition at line 519 of file Variable.cpp.

Variable * ocra::CompositeVariable::do_createTimePrimitive ( const std::string &  name)
protectedvirtual

Implements ocra::Variable.

Definition at line 551 of file Variable.cpp.

size_t ocra::CompositeVariable::do_getNumberOfChildren ( ) const
protectedvirtual

Always return getNumChildhoods.

Implements ocra::Variable.

Definition at line 641 of file Variable.cpp.

void ocra::CompositeVariable::do_setValue ( const VectorXd &  value)
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.

CompositeVariable & ocra::CompositeVariable::getTimeDerivative ( )
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.

CompositeVariable & ocra::CompositeVariable::getTimePrimitive ( )
virtual

Reimplemented from ocra::Variable.

Definition at line 460 of file Variable.cpp.

int ocra::CompositeVariable::isAncestorOf ( const Variable node) const
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.

void ocra::CompositeVariable::onAttachedChild ( const parenthood_t child)
protected

Definition at line 492 of file Variable.cpp.

void ocra::CompositeVariable::onDetachedChild ( const parenthood_t child)
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.

void ocra::CompositeVariable::printSubTree ( int  depth,
std::ostream &  os 
) const
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.

Parameters
depthis the current depth of the node.

Implements ocra::Component< Variable, CompositeVariable, VariableParenthood >.

Definition at line 514 of file Variable.cpp.

CompositeVariable & ocra::CompositeVariable::remove ( Variable child)
virtual

The documentation for this class was generated from the following files: