File kernel/src/simulationTools/EventFactory.hpp

Go to the source code of this file

Factory to generate user-defined Events.

Defines

AUTO_REGISTER_EVENT(class_name, class_type)
namespace EventFactory

Namespace for Events factory related objects.

Typedefs

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.

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::Event factory(double time, int type)

Template function to return a new object of type SubType.

Parameters
  • time – time of the Event

  • type – type of the Event

Returns

an Event

class Registry
#include <>

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)
Parameters
Returns

an Event

Public Static Functions

static Registry &get()

get access to the Registry

Returns

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

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