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 Factory & | instance () |
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()
|
inline |
Add a creator of type AbstractCreator to registered list
- Parameters
-
[in] name name of the creator [in] creator pointer to the creator
- Returns
- current size of creators registered in the list
Definition at line 109 of file factory.hpp.
◆ containsCreator()
|
inline |
Check if a class is already registered
- Parameters
-
[in] name name of the creator
- Returns
- true if the creator exists
Definition at line 119 of file factory.hpp.
◆ create()
|
inlinestatic |
Create a Base Class with linked creator
- Parameters
-
[in] name name of a creator registered in the singleton [in] xml_root reference 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()
|
inlinestatic |
Instance the singleton
Definition at line 78 of file factory.hpp.
◆ mapRegisteredBlocks()
|
inline |
- Returns
- the whole list of registered creators
Definition at line 134 of file factory.hpp.
◆ removeCreator()
|
inline |
Remove a creator from registered list
- Parameters
-
[in] name name of the creator
Definition at line 96 of file factory.hpp.
◆ setDefaultCreator()
|
inline |
It sets a default creator for all your possible registered classes.
- Parameters
-
[in] creator pointer to a creator
Definition at line 127 of file factory.hpp.
The documentation for this class was generated from the following file:
- src/common/factory.hpp