Plasma Engine  2.0
Loading...
Searching...
No Matches
plSingletonRegistry Class Reference

plSingletonRegistry knows about all singleton instances of classes that use PL_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 plMap< 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 plSingletonRegistrar.
 
template<typename Interface >
static void Unregister ()
 Unregisters a singleton instance. This is automatically called by plSingletonRegistrar.
 

Friends

template<typename >
class plSingletonRegistrar
 

Detailed Description

plSingletonRegistry knows about all singleton instances of classes that use PL_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 PL_DECLARE_SINGLETON and PL_DECLARE_SINGLETON_OF_INTERFACE for details.

Member Function Documentation

◆ GetSingletonInstance()

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

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

Todo
Events for new/deleted singletons -> plInspector integration

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