Base module

IRegistry

Abstract interface for object registries.

IRegistry

#include <icy/iregistry.h>

Abstract interface for object registries.

Public Attributes

ReturnNameDescription
Signal< void(const std::string &)>TypeRegistered
Signal< void(const std::string &)>TypeUnregistered

TypeRegistered

Signal< void(const std::string &)> TypeRegistered

TypeUnregistered

Signal< void(const std::string &)> TypeUnregistered

Public Methods

ReturnNameDescription
IRegistryDefaulted constructor.
ItemT *createInstance virtual inlineCreates and returns a new heap-allocated instance of the type registered under key s.
voidregisterType inlineRegisters type T under the given key s. Emits TypeRegistered. Subsequent calls to createInstance(s) will return new T().
voidunregisterType virtual inlineRemoves the type registered under key s. Emits TypeUnregistered. Does nothing if s is not registered.
TypeMaptypes const inlineReturns a copy of the current type map.

IRegistry

IRegistry() = default

Defaulted 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

  • s The 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

  • T Concrete type to register; must be default-constructible and derive from ItemT.

Parameters

  • s Registration 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

  • s Registration key to remove.

types

const inline

inline TypeMap types() const

Returns a copy of the current type map.

Returns

Map of registration keys to factory function pointers.

Public Types

NameDescription
TypeMap

TypeMap

std::map< std::string, ItemT *(*)()> TypeMap()

Private Attributes

ReturnNameDescription
TypeMap_types

_types

TypeMap _types

Private Static Methods

ReturnNameDescription
ItemT *createT static inline

createT

static inline

template<typename T> static inline ItemT * createT()