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.


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.


template<class SubType>
SP::DynamicalSystem factory(int name, const SiconosVector &x0)

Template function to return a new object of type SubType.

  • name

  • x0



class Registry
#include <>

Registry Class for DynamicalSystem.

DynamicalSystem factory. Use:

   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.

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

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

  • x0 – the initial condition (SP)



Public Static Functions

static Registry &get()

Access function to the Registry.


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.

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

  • obj – an object creator