Simox
2.3.74.0
|
Data Structures | |
struct | SubClassRegistry |
Public Types | |
typedef std::shared_ptr< Base >(* | initialisationFunction) (constructorArg) |
Public Member Functions | |
void | setDescription (const std::string &newDescription) |
std::string | getDescription () const |
Static Public Member Functions | |
static std::shared_ptr< Base > | fromName (const std::string &name, constructorArg params) |
static std::shared_ptr< Base > | first (constructorArg params) |
static std::string | getName () |
static std::shared_ptr< Base > | createInstance (constructorArg) |
static void | registerClass (const std::string &name, initialisationFunction init) |
static std::vector< std::string > | getSubclassList () |
A template that can be used as a superclass of a class hierarchy that wants to provide a factory method which allows instantiation of objects based on a string identifier.
The first template argument is the base class of your class hierarchy. The second argument is the parameter type for the initialisation function each subclass has to provide. If you need multiple constructor arguments it is recommended to use a boost::tuple.
typedef std::shared_ptr<Base>(* AbstractFactoryMethod< Base, constructorArg >::initialisationFunction) (constructorArg) |
The function pointer type of subclass initialisation functions. This matches the createInstance method.
|
inlinestatic |
Initialisation function which needs to be provided by every subclass. It calls the constructor and returns a shared_ptr to the resulting object.
|
inlinestatic |
Function which can be used to retrieve the first registered object.
|
inlinestatic |
Function which can be used to retrieve an object specified by string name.
|
inline |
Return the description of the current instance.
|
inlinestatic |
Returns the class's name. This is used to identify the class which the user requests an instance of.
|
inlinestatic |
Return a list of all registered subclasses.
|
inlinestatic |
Statically called by subclasses to register their name and initialisation function so they can be found by fromName.
|
inline |
Set a description on the instance it is called on.