File control/src/utils/SensorFactory.hpp#

Go to the source code of this file

Factory to generate user-defined sensors

Defines

AUTO_REGISTER_SENSOR(class_name, class_type)#
namespace SensorFactory#

Namespace for Sensor factory related objects.

Typedefs

typedef SP::Sensor (*object_creator)(SP::DynamicalSystem)#

A pointer to function, returning a SP::Sensor, built with its type (ie class name) and a SP::DynamicalSystem.

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

The type of the factory map.

typedef MapFactory::iterator MapFactoryIt#

An iterator through the MapFactory.

Functions

template<class SubType>
SP::Sensor factory(SP::DynamicalSystem ds)#

Template function to return a new object of type SubType.

Parameters:

ds – the DynamicalSystem for the Sensor

Returns:

a Sensor

class Registry#
#include <SensorFactory.hpp>

Registry Class for sensors.

Sensor factory. Use: SensorFactory::Registry& regSensor(SensorFactory::Registry::get()) ; SP::Sensor yourSensor = regSensor.instantiate(sensorType, timeD, myDS); With sensorType a std::string, the name of the class of your Sensor (expl: “SensorPosition”), timeD a SP::TimeDiscretisation and myDS a SP::DynamicalSystem.

Public Functions

void add(int type, object_creator creator)#

Add an object_creator into the factory_map.

Parameters:
  • type – the type of the added Sensor

  • creator – object creator

SP::Sensor instantiate(int type, SP::DynamicalSystem ds)#

Function to instantiate a new Sensor.

Parameters:
  • type – the type of the Sensor we want to instantiate

  • ds – a SP::DynamicalSystem that will be linked to this Sensor

Returns:

a Sensor

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 <SensorFactory.hpp>

Registration Class for sensors.

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

Public Functions

Registration(int type, object_creator creator)#

To register some new object into the factory.

Parameters:
  • type – the type of the added Sensor

  • creator – object creator