File control/src/utils/ActuatorFactory.hpp

Go to the source code of this file

Factory to generate user-defined sensors.

Defines

AUTO_REGISTER_ACTUATOR(class_name, class_type)
namespace ActuatorFactory

Namespace for Actuator factory related objects.

Typedefs

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.

Functions

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

Template function to return a new object of type SubType.

Parameters

sensor – the ControlSensor used by the Actuator

Returns

an Actuator

class Registry
#include <>

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.

Parameters
Returns

SP::Actuator to the created Actuator

Public Static Functions

static Registry &get()

Access function to the Registry.

Returns

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.

Parameters
  • type – the type of the added Actuator

  • creator – object creator