File control/src/utils/ActuatorFactory.hpp

Go to the source code of this file

Factory to generate user-defined sensors.

namespace ActuatorFactory

Namespace for Actuator 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::Actuator (*object_creator)(SP::ControlSensor)

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

Functions

template <class SubType>
SP::Actuator factory(SP::ControlSensor sensor)

Template function to return a new object of type SubType.

Return
an Actuator
Parameters

class Registration
#include <ActuatorFactory.hpp>

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.

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

class Registry
#include <ActuatorFactory.hpp>

Registry Class for Actuators.

Actuator factory. Use:

ActuatorFactory::Registry&
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.

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

Return
SP::Actuator to the created Actuator
Parameters

Public Static Functions

static Registry &get()

Access function to the Registry.

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