PLCnext API Documentation 25.0.2.69
|
This class implements the singleton pattern. More...
#include <Singleton.hxx>
Public Member Functions | |
ARP_DEPRECATED ("Use Singleton<T>::GetInstance() or Singleton<T>::IsCreated() yet.") static Instance *GetInstancePtr(void) | |
Static Public Member Functions | |
template<class ... Args> | |
static Instance & | CreateInstance (Args &&... args) |
Creates this singleton instance. More... | |
static bool | IsCreated (void) |
Determines if this singleton instance is create yet. More... | |
static Instance & | GetInstance (void) |
Gets a reference of the singleton instance. More... | |
static void | DisposeInstance (void) |
Disposes this singleton instance. More... | |
Protected Types | |
using | SingletonBase = Singleton< T > |
Defines this type to be used from derived classes. | |
Protected Member Functions | |
Singleton (void) | |
The protected default constructor. | |
Singleton (const Singleton &arg)=delete | |
Singleton & | operator= (const Singleton &arg)=delete |
Singleton (Singleton &&arg)=delete | |
Singleton & | operator= (Singleton &&arg)=delete |
~Singleton (void) | |
The protected destructor. | |
Static Protected Member Functions | |
static Ptr & | GetStaticInstancePtr (void) |
static void | SetInstance (T *pInstance) |
DEPRECATED. More... | |
This class implements the singleton pattern.
Derived | The class to apply the singleton pattern to. |
Derive your own class called MyClass
from Singleton<MyClass>
to apply the singleton pattern to this class.
This class uses CRTP (Curiously recurring template pattern) to implement an own singleton instance for each derived class. For CRTP see: https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
|
inlinestatic |
Creates this singleton instance.
args | The arguments passed to the constructor of T. Thus there must exists a constructor with a matching signature. |
T | The type to create. Usually this is the derived type, but it might also be a polymorphic type. |
Args | The argument list must comply to a constructor with a matching signature. |
|
inlinestatic |
Disposes this singleton instance.
Deletes the singleton instance pointer.
|
inlinestatic |
Gets a reference of the singleton instance.
Exception | If the singleton instance was not created yet. |
|
inlinestatic |
Determines if this singleton instance is create yet.
true
if this singleton was created yet, otherwise false
.
|
inlinestaticprotected |
DEPRECATED.
Do not use this operation any more.