Scanframe Modular Application 0.1.0
|
Template class used to register derived classes from a (virtual) interface class. More...
#include <TClassRegistration.h>
Classes | |
struct | entry_t |
Type of registered entry in the list. More... | |
Public Types | |
typedef TClassRegistration< T, P > | self_t |
typedef TClosure< T *, const P & > | callback_t |
typedef std::vector< entry_t > | entries_t |
typedef TVector< std::string > | strings_t |
Public Member Functions | |
TClassRegistration (entries_t &entries) | |
Constructor for the base class. | |
TClassRegistration (const TClassRegistration< T, P > &inst) | |
Copy constructor. | |
TClassRegistration (TClassRegistration< T, P > &&inst) | |
Move constructor. | |
TClassRegistration< T, P > & | operator= (const TClassRegistration< T, P > &inst) |
Assignment operator. | |
size_t | registerClass (const char *name, const char *description, const callback_t &callback) |
Register a derived class. | |
size_t | indexOf (const std::string &name) const |
Find a registered class structure index. | |
T * | create (const std::string &name, const P ¶ms) const |
Find and create registered class by name. | |
T * | create (size_t index, const P ¶ms) const |
Function create registered class by index. | |
size_t | size () const |
Returns the amount of registered entries. | |
const std::string & | getRegisterName (T *inst) const |
Gets the register name of the passed. | |
const char * | getName (size_t index) const |
Gets the name of the class from the passed index. | |
strings_t | getNames () const |
Gets the all the registered names. | |
const char * | getDescription (size_t index) const |
Returns the description of the class from the passed index. | |
Static Public Member Functions | |
static void | setRegisterName (T *inst, const char *name) |
Sets the register name on the passed instance. | |
Template class used to register derived classes from a (virtual) interface class.
Registering name and description.
Example
T | Base type of the class being registered |
P | Parameter type passed to the constructor. |
F | Callback function to create the instance. |
typedef TClosure<T*, const P&> sf::TClassRegistration< T, P >::callback_t |
typedef std::vector<entry_t> sf::TClassRegistration< T, P >::entries_t |
typedef TClassRegistration<T, P> sf::TClassRegistration< T, P >::self_t |
typedef TVector<std::string> sf::TClassRegistration< T, P >::strings_t |
|
inlineexplicit |
Constructor for the base class.
|
inline |
Copy constructor.
|
inline |
Move constructor.
|
inline |
Find and create registered class by name.
name | Registered name of the class |
params | Parameter type instance for the constructor. |
|
inline |
Function create registered class by index.
index | Index in the list of classes. |
params | Parameter structure. |
const char * sf::TClassRegistration< T, P >::getDescription | ( | size_t | index | ) | const |
Returns the description of the class from the passed index.
const char * sf::TClassRegistration< T, P >::getName | ( | size_t | index | ) | const |
Gets the name of the class from the passed index.
TClassRegistration< T, P >::strings_t sf::TClassRegistration< T, P >::getNames | ( | ) | const |
Gets the all the registered names.
|
inline |
Gets the register name of the passed.
|
inline |
Find a registered class structure index.
name | Registered name of the class. |
|
inline |
Assignment operator.
|
inline |
Register a derived class.
name | Name of the class. |
description | Description of the class. |
callback | Callback function to create instance of the class. |
|
inlinestatic |
Sets the register name on the passed instance.
This automatically is called from the callback_t when a class is registered.
size_t sf::TClassRegistration< T, P >::size | ( | ) | const |
Returns the amount of registered entries.