mimmo::Factory< Base > Class Template Reference

Factory base template singleton for automatic factorization of executable classes. More...

#include <factory.hpp>

Classes

class  AbstractCreator
 Abstract class embedded in Factory to link creators of type Base* <>(const bitpit::Config::Section & xml_root) More...
 

Public Member Functions

int addCreator (const std::string name, const AbstractCreator *creator)
 
bool containsCreator (const std::string &name)
 
std::vector< std::string > mapRegisteredBlocks ()
 
void removeCreator (const std::string &name)
 
int setDefaultCreator (const AbstractCreator *creator)
 

Static Public Member Functions

static Base * create (const std::string name, const bitpit::Config::Section &xml_root)
 
static Factoryinstance ()
 

Detailed Description

template<class Base>
class mimmo::Factory< Base >

Factory base template singleton for automatic factorization of executable classes.

Factory register a list of Base classes with their own custom method which create and instance them automatically.

Definition at line 47 of file factory.hpp.

Member Function Documentation

◆ addCreator()

template<class Base >
int mimmo::Factory< Base >::addCreator ( const std::string  name,
const AbstractCreator creator 
)
inline

Add a creator of type AbstractCreator to registered list

Parameters
[in]namename of the creator
[in]creatorpointer to the creator
Returns
current size of creators registered in the list

Definition at line 109 of file factory.hpp.

◆ containsCreator()

template<class Base >
bool mimmo::Factory< Base >::containsCreator ( const std::string &  name)
inline

Check if a class is already registered

Parameters
[in]namename of the creator
Returns
true if the creator exists

Definition at line 119 of file factory.hpp.

◆ create()

template<class Base >
static Base* mimmo::Factory< Base >::create ( const std::string  name,
const bitpit::Config::Section &  xml_root 
)
inlinestatic

Create a Base Class with linked creator

Parameters
[in]namename of a creator registered in the singleton
[in]xml_rootreference to info, passed as xml-data tree, referred to the creator
Returns
pointer to the newly instantiated base class

Definition at line 87 of file factory.hpp.

◆ instance()

template<class Base >
static Factory& mimmo::Factory< Base >::instance ( )
inlinestatic

Instance the singleton

Definition at line 78 of file factory.hpp.

◆ mapRegisteredBlocks()

template<class Base >
std::vector<std::string> mimmo::Factory< Base >::mapRegisteredBlocks ( )
inline
Returns
the whole list of registered creators

Definition at line 134 of file factory.hpp.

◆ removeCreator()

template<class Base >
void mimmo::Factory< Base >::removeCreator ( const std::string &  name)
inline

Remove a creator from registered list

Parameters
[in]namename of the creator

Definition at line 96 of file factory.hpp.

◆ setDefaultCreator()

template<class Base >
int mimmo::Factory< Base >::setDefaultCreator ( const AbstractCreator creator)
inline

It sets a default creator for all your possible registered classes.

Parameters
[in]creatorpointer to a creator

Definition at line 127 of file factory.hpp.


The documentation for this class was generated from the following file: