LBIBCell
|
#include <Factory.hpp>
Public Member Functions | |
bool | registerType (const IdentifierType &id, ProductCreatorSignature creator) |
bool | unregisterType (const IdentifierType &id) |
AbstractProduct * | createObject (const IdentifierType &id) const |
Factory implementation, following [Alexandescu, 2002].
To generate a factory do a typedef like that:
This code generates a factory of CDESolvers as an Singleton.
To register your class in the Factory use this code in the header:
And in the implementation do this:
Where NAME is replaced by your string identifier for this class
Additional your class should protect the Constructor by making it either private or protected. Provide a static create method which returns a pointer to this class which is then registered in the factory.
To instantiate an object use this code:
Definition at line 112 of file Factory.hpp.
|
inline |
Create an instance of the specified type.
id | The type identifier. |
Definition at line 143 of file Factory.hpp.
|
inline |
Registers a type with the factory.
id | The identifier of the type. |
creator | Function pointer to the type creation method. |
Definition at line 122 of file Factory.hpp.
|
inline |
Unregisters a type.
id | The type identifier. |
Definition at line 133 of file Factory.hpp.