XII Release 0.1.0
Loading...
Searching...
No Matches
xiiSingletonRegistry Class Reference

xiiSingletonRegistry knows about all singleton instances of classes that use XII_DECLARE_SINGLETON. More...

#include <Singleton.h>

Classes

struct  SingletonEntry
 

Static Public Member Functions

template<typename Interface>
static Interface * GetSingletonInstance ()
 Retrieves a singleton instance by type name. Returns nullptr if no singleton instance is available.
 
template<typename Interface>
static Interface * GetRequiredSingletonInstance ()
 Retrieves a singleton instance by type name. Asserts if no singleton instance is available.
 
static const xiiMap< size_t, SingletonEntry > & GetAllRegisteredSingletons ()
 Allows to inspect all known singletons.
 
template<typename Interface>
static void Register (Interface *pSingletonInstance)
 Registers a singleton instance under a given type name. This is automatically called by xiiSingletonRegistrar.
 
template<typename Interface>
static void Unregister ()
 Unregisters a singleton instance. This is automatically called by xiiSingletonRegistrar.
 

Friends

template<typename>
class xiiSingletonRegistrar
 

Detailed Description

xiiSingletonRegistry knows about all singleton instances of classes that use XII_DECLARE_SINGLETON.

It allows to query for a specific interface implementation by type name only, which makes it possible to get rid of unwanted library dependencies and use pure virtual interface classes, without singleton code (and thus link dependencies).

See XII_DECLARE_SINGLETON and XII_DECLARE_SINGLETON_OF_INTERFACE for details.

Member Function Documentation

◆ GetSingletonInstance()

template<typename Interface>
static Interface * xiiSingletonRegistry::GetSingletonInstance ( )
inlinestatic

Retrieves a singleton instance by type name. Returns nullptr if no singleton instance is available.

Todo
Events for new/deleted singletons -> xiiInspector integration

The documentation for this class was generated from the following files: