File kernel/src/simulationTools/EventFactory.hpp

Go to the source code of this file

Factory to generate user-defined Events.

namespace EventFactory

Namespace for Events 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::Event (*object_creator)(double, int)

A pointer to function, returning a pointer to Event, built with its type (ie class name) and a pointer to Model.

Functions

template <class SubType>
SP::Event factory(double time, int type)

Template function to return a new object of type SubType.

Return
an Event
Parameters

class Registration
#include <EventFactory.hpp>

Registration Class for Events.

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

Public Functions

Registration(int type, object_creator creator)

To register some new object into the factory.

Parameters
  • type: the type of the object added
  • creator: object creator

class Registry
#include <EventFactory.hpp>

Registry Class for Events.

Public Functions

void add(int type, object_creator creator)

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

Parameters
  • type: the type of the object added
  • creator: object creator

SP::Event instantiate(double time, int type)

Return
an Event
Parameters

Public Static Functions

static Registry &get()

get access to the Registry

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