Base module
IRegistry
Abstract interface for object registries.
IRegistry
#include <icy/iregistry.h>Abstract interface for object registries.
Public Attributes
| Return | Name | Description |
|---|---|---|
Signal< void(const std::string &)> | TypeRegistered | |
Signal< void(const std::string &)> | TypeUnregistered |
TypeRegistered
Signal< void(const std::string &)> TypeRegisteredTypeUnregistered
Signal< void(const std::string &)> TypeUnregisteredPublic Methods
| Return | Name | Description |
|---|---|---|
IRegistry | Defaulted constructor. | |
ItemT * | createInstance virtual inline | Creates and returns a new heap-allocated instance of the type registered under key s. |
void | registerType inline | Registers type T under the given key s. Emits TypeRegistered. Subsequent calls to createInstance(s) will return new T(). |
void | unregisterType virtual inline | Removes the type registered under key s. Emits TypeUnregistered. Does nothing if s is not registered. |
TypeMap | types const inline | Returns a copy of the current type map. |
IRegistry
IRegistry() = defaultDefaulted constructor.
createInstance
virtual inline
virtual inline ItemT * createInstance(const std::string & s)Creates and returns a new heap-allocated instance of the type registered under key s.
Parameters
sThe registration key (type name).
Returns
Pointer to the new instance, or nullptr if s is not registered.
registerType
inline
template<typename T> inline void registerType(const std::string & s)Registers type T under the given key s. Emits TypeRegistered. Subsequent calls to createInstance(s) will return new T().
Parameters
TConcrete type to register; must be default-constructible and derive from ItemT.
Parameters
sRegistration key (type name).
unregisterType
virtual inline
virtual inline void unregisterType(const std::string & s)Removes the type registered under key s. Emits TypeUnregistered. Does nothing if s is not registered.
Parameters
sRegistration key to remove.
types
const inline
inline TypeMap types() constReturns a copy of the current type map.
Returns
Map of registration keys to factory function pointers.
Public Types
| Name | Description |
|---|---|
TypeMap |
TypeMap
std::map< std::string, ItemT *(*)()> TypeMap()Private Attributes
| Return | Name | Description |
|---|---|---|
TypeMap | _types |
_types
TypeMap _typesPrivate Static Methods
| Return | Name | Description |
|---|---|---|
ItemT * | createT static inline |
createT
static inline
template<typename T> static inline ItemT * createT()