File kernel/src/modelingTools/DynamicalSystemFactory.hpp

Go to the source code of this file

Factory to generate user-defined DynamicalSystems.

namespace DynamicalSystemFactory

Namespace for DynamicalSystem factory related objects.

Typedefs

typedef SP::DynamicalSystem (*object_creator)(int, const SiconosVector&)

A pointer to function, returning a pointer to DynamicalSystem, built with its type (related to the class name) and a vector of initial conditions.

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::DynamicalSystem factory(int name, const SiconosVector &x0)

Template function to return a new object of type SubType.

Parameters
  • name

  • x0

Returns

SP::DynamicalSystem

class Registry
#include <>

Registry Class for DynamicalSystem.

DynamicalSystem factory. Use:

DynamicalSystemFactory::Registry&
   regDynamicalSystem(DynamicalSystemFactory::Registry::get()) ;

SP::DynamicalSystem yourDynamicalSystem =
   regDynamicalSystem.instantiate(type, x0);

Public Functions

void add(int i, object_creator obj)

Add an object_creator into the factory_map, factory_map[name] = object.

Parameters
  • i – an int, the name of the object added

  • obj – an object creator

SP::DynamicalSystem instantiate(int i, const SiconosVector &x0)

Function to instantiate a new DynamicalSystem.

Parameters
  • i – an int, the name of the object added (type name!)

  • x0 – the initial condition (SP)

Returns

SP::DynamicalSystem

Public Static Functions

static Registry &get()

Access function to the Registry.

Returns

static 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 sensors.

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

Public Functions

Registration(int i, object_creator obj)

To register some new object into the factory.

Parameters
  • i – an int, the name of the object to be registered

  • obj – an object creator