File kernel/src/modelingTools/RelationFactory.hpp

Go to the source code of this file

Factory to generate user-defined Relations.

namespace RelationFactory

Namespace for Relation factory related objects.

Typedefs

typedef std::map<int, object_creator> MapFactory

The type of the factory map.

typedef MapFactory::iterator MapFactoryIt

An iterator through the MapFactory.

typedef SP::Relation (*object_creator)(int)

A pointer to function, returning a pointer to Relation, built with its type (related to the class name)

Functions

template <class SubType>
SP::Relation factory(int name)

Template function to return a new object of type SubType.

Return
SP::Relation
Parameters
  • name: an int, the name of the object added

class Registration
#include <RelationFactory.hpp>

Registration Class for relations.

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

Public Functions

Registration(int name, object_creator obj)

To register some new object into the factory.

Parameters
  • name: an int, the name of the object to be registered
  • obj: an object creator

class Registry
#include <RelationFactory.hpp>

Registry Class for sensors.

Relation factory. Use: RelationFactory::Registry& regRelation(RelationFactory::Registry::get()) ; SP::Relation yourRelation = regRelation.instantiate(type, x0);

Public Functions

void add(int name, object_creator obj)

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

Parameters
  • name: an int, the name of the object added
  • obj: an object creator

SP::Relation instantiate(int name)

Function to instantiate a new Relation.

Return
SP::Relation
Parameters
  • name: an int, the name of the object added (type name!)

Public Static Functions

static Registry &get()

Access function to the Registry.

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