File control/src/utils/ObserverFactory.hpp#

Go to the source code of this file

Factory to generate user-defined Observers


AUTO_REGISTER_OBSERVER(class_name, class_type)#
namespace ObserverFactory#

Namespace for Observer factory related objects.


typedef SP::Observer (*object_creator)(SP::ControlSensor, const SiconosVector&)#

A pointer to function, returning a SP::Observer, built with its type (ie class name) a ControlSensor and a SiconosVector, the initial estimate.

typedef std::map<unsigned int, object_creator> MapFactory#

The type of the factory map.

typedef MapFactory::iterator MapFactoryIt#

An iterator through the MapFactory.


template<class SubType>
SP::Observer factory(SP::ControlSensor sensor, const SiconosVector &xHat0)#

Template function to return a new object of type SubType.


an Observer

class Registry#
#include <ObserverFactory.hpp>

Registry Class for Observers.

Observer factory. Use: ObserverFactory::Registry& regObserver(ObserverFactory::Registry::get()) ; SP::Observer yourObserver = regObserver.instantiate(observerType, timeD, myDS); With observerType a string, the name of the class of your Observer (expl: “ObserverPosition”), timeD a SP::TimeDiscretisation and myDS a SP::DynamicalSystem.

Public Functions

void add(unsigned int type, object_creator creator)#

Add an object_creator into the factory_map, factory_map[name] = object.

  • type – the type of the added Observer

  • creator – object creator

SP::Observer instantiate(unsigned int type, SP::ControlSensor sensor, const SiconosVector &xHat0)#

Function to instantiate a new Observer.


a SP::Observer to the created Observer

Public Static Functions

static Registry &get()#

Access function to the Registry.


reference to the registry

Private Members

MapFactory factory_map#

map that links a string, the type of the class, to a pointer to function, used to build the object.

class Registration#
#include <ObserverFactory.hpp>

Registration Class for Observers.

Class used for auto-registration of Observer-type objects.

Public Functions

Registration(unsigned int type, object_creator creator)#

To register some new object into the factory.

  • type – the type of the added Observer

  • creator – object creator