This class implements the singleton pattern for singletons with process wide scope.
More...
#include <AppDomainSingleton.hxx>
template<class Derived>
class Arp::AppDomainSingleton< Derived >
This class implements the singleton pattern for singletons with process wide scope.
- Template Parameters
-
Derived | The class to apply the singleton pattern to. |
Derive your own class called MyClass
from AppDomainSingleton<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
◆ SingletonBase
Defines this type to be used from derived classes.
◆ AppDomainSingleton()
The protected default constructor.
◆ ~AppDomainSingleton()
The protected default destructor.
◆ CreateInstance()
template<class Derived >
template<class T , class ... Args>
Creates this singleton instance.
- Template Parameters
-
T | The type to create. Usually this is the derived type, but it might also be a polymorphic type. |
Args | The argument list must match a constructor's signature of T . |
- Parameters
-
args | The arguments passed to the constructor of T . Thus there must exists a constructor of T with a matching signature. |
- Returns
- The new created singleton instance as reference.
◆ DisposeInstance()
Disposes this singleton instance.
Deletes the singleton instance pointer.
◆ GetInstance()
Gets a reference of the singleton instance.
- Returns
- The singleton instance as reference.
- Exceptions
-
Exception | If the singleton instance was not created yet. |
◆ GetInstancePtr()
Gets a pointer to the singleton instance.
- Returns
- The singleton instance as pointer, if it was created yet, otherwise
nullptr
.
◆ IsCreated()
Determines if this singleton instance is created yet.
- Returns
true
if this singleton was created yet, otherwise false
.
The documentation for this class was generated from the following file: