File control/src/utils/ActuatorFactory.hpp

Go to the source code of this file

Factory to generate user-defined sensors.


AUTO_REGISTER_ACTUATOR(class_name, class_type)
namespace ActuatorFactory

Namespace for Actuator factory related objects.


typedef SP::Actuator (*object_creator)(SP::ControlSensor)

A pointer to function, returning a pointer to Actuator, built with a SP::ControlSensor.

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::Actuator factory(SP::ControlSensor sensor)

Template function to return a new object of type SubType.


sensor – the ControlSensor used by the Actuator


an Actuator

class Registry
#include <>

Registry Class for Actuators.

Actuator factory. Use:

regActuator(ActuatorFactory::Registry::get()) ;

Actuator * yourActuator = regActuator.instantiate(sensorType, timeD, ds);
With sensorType a std::string, the name of the class of your Actuator (expl: “ActuatorPosition”), timeD a SP::TimeDiscretisation and ds 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 Actuator

  • creator – object creator

SP::Actuator instantiate(unsigned int type, SP::ControlSensor sensor)

Function to instantiate a new Actuator.


SP::Actuator to the created Actuator

Public Static Functions

static Registry &get()

Access function to the Registry.


a reference to the registry

Private Members

MapFactory factory_map

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

class Registration
#include <>

Registration Class for Actuators.

Class used for auto-registration of Actuator-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 Actuator

  • creator – object creator