GGS(GenericGEANT4Simulation)Software
2.7.0
|
Template factory class. More...
#include <GGSFactory.h>
Public Member Functions | |
bool | RegisterBuilder (const std::string &builderName, T *(*objectBuilder)(ConstructorArgs...)) |
Register a builder for a class. More... | |
std::unique_ptr< T > | CreateObject (const std::string &name, ConstructorArgs...arguments) |
Create an object. More... | |
const std::vector< std::string > & | GetListOfRegisteredBuilders () |
Gets a vector containing the names of available registered builders. More... | |
Static Public Member Functions | |
static GGSFactory & | GetInstance () |
Getter method for singleton pointer. More... | |
Template factory class.
This class is a generic factory, that can build all the derived classes of a given base class using constructors with any set of arguments. The first template argument is the base class of the objects built by the factory. Variadic template arguments are the constructor arguments. Actual object build is done by means of builder functions, each constructing instances of a given derived class. Builders must be registered providing a suitable builder function with a name (which can be the name of the built class itself).
Definition at line 29 of file GGSFactory.h.
std::unique_ptr< T > GGSFactory< T, ConstructorArgs >::CreateObject | ( | const std::string & | name, |
ConstructorArgs... | arguments | ||
) |
Create an object.
The builder is fetched by its name. If the desired builder is not available, the NULL pointer will be returned.
name | The name of the builder for the desired object. |
Definition at line 115 of file GGSFactory.h.
|
static |
Getter method for singleton pointer.
Definition at line 71 of file GGSFactory.h.
const std::vector< std::string > & GGSFactory< T, ConstructorArgs >::GetListOfRegisteredBuilders | ( | ) |
Gets a vector containing the names of available registered builders.
Definition at line 110 of file GGSFactory.h.
bool GGSFactory< T, ConstructorArgs >::RegisterBuilder | ( | const std::string & | builderName, |
T *(*)(ConstructorArgs...) | objectBuilder | ||
) |
Register a builder for a class.
builderName | The name of the builder. |
objectBuilder | Pointer to a builder function for the class. |
Definition at line 92 of file GGSFactory.h.