File control/src/utils/ObserverFactory.hpp

Go to the source code of this file

Factory to generate user-defined Observers.

namespace ObserverFactory

Namespace for Observer factory related objects.

Typedefs

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

The type of the factory map.

typedef MapFactory::iterator MapFactoryIt

An iterator through the MapFactory.

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.

Functions

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

Template function to return a new object of type SubType.

Return
an Observer
Parameters

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.

Parameters
  • type: the type of the added Observer
  • creator: object creator

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.

Parameters
  • 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.

Return
a SP::Observer to the created Observer
Parameters

Public Static Functions

static Registry &get()

Access function to the Registry.

Return
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.