![]() |
Scanframe Modular Application 0.1.0
|
Template class used to register derived classes from a (virtual) interface class. Registering name and description.
Example
More...
#include <TClassRegistration.h>
Classes | |
class | entry_t |
Type of registered entry in the list. More... | |
Public Types | |
typedef TClassRegistration | self_t |
typedef TClosure< T *, const P & > | callback_t |
typedef std::vector< entry_t > | entries_t |
Vector type to register implementations in. | |
typedef TVector< std::string > | strings_t |
Type used to report the list of implementations in. | |
Public Member Functions | |
TClassRegistration (entries_t &entries) | |
Constructor for the base class. | |
TClassRegistration (const TClassRegistration &inst) | |
Copy constructor. | |
TClassRegistration (TClassRegistration &&inst) noexcept | |
Move constructor. | |
TClassRegistration & | operator= (const TClassRegistration &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. When not found it returns. | |
T * | create (const std::string &name, const P ¶ms=P{}) const |
Find and create registered class by name. | |
T * | create (size_t index, const P ¶ms=P{}) 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. This automatically is called from the callback_t when a class is registered. | |
Static Public Attributes | |
static auto constexpr | npos = std::numeric_limits<size_t>::max() |
Index value for when not found. | |
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. |
typedef TClosure<T*, const P&> sf::TClassRegistration< T, P >::callback_t |
typedef std::vector<entry_t> sf::TClassRegistration< T, P >::entries_t |
Vector type to register implementations in.
typedef TClassRegistration sf::TClassRegistration< T, P >::self_t |
typedef TVector<std::string> sf::TClassRegistration< T, P >::strings_t |
Type used to report the list of implementations in.
|
explicit |
Constructor for the base class.
sf::TClassRegistration< T, P >::TClassRegistration | ( | const TClassRegistration< T, P > & | inst | ) |
Copy constructor.
|
noexcept |
Move constructor.
T * sf::TClassRegistration< T, P >::create | ( | const std::string & | name, |
const P & | params = P{} |
||
) | const |
Find and create registered class by name.
name | Registered name of the class |
params | Parameter type instance for the constructor. |
T * sf::TClassRegistration< T, P >::create | ( | size_t | index, |
const P & | params = P{} |
||
) | const |
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.
strings_t sf::TClassRegistration< T, P >::getNames | ( | ) | const |
Gets the all the registered names.
const std::string & sf::TClassRegistration< T, P >::getRegisterName | ( | T * | inst | ) | const |
Gets the register name of the passed.
size_t sf::TClassRegistration< T, P >::indexOf | ( | const std::string & | name | ) | const |
Find a registered class structure index. When not found it returns.
name | Registered name of the class. |
|
inline |
Assignment operator.
size_t sf::TClassRegistration< T, P >::registerClass | ( | const char * | name, |
const char * | description, | ||
const callback_t & | callback | ||
) |
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.
|
staticconstexpr |
Index value for when not found.