![]() |
smgl 0.11.0
Structured Metadata Engine and Graph Objects Library
|
Class for constructing and managing the lifetime of a singleton object. More...
#include <smgl/Singleton.hpp>
Public Types | |
| using | InstanceType = typename ThreadingModel< T >::VolatileType |
Public Member Functions | |
| SingletonHolder ()=delete | |
Static Public Member Functions | |
| static T & | Instance () |
| Access the singleton instance. | |
Static Private Member Functions | |
| static void | DestroySingleton () |
Static Private Attributes | |
| static InstanceType * | instance_ = nullptr |
| static bool | destroyed_ = false |
Class for constructing and managing the lifetime of a singleton object.
This class provides singleton management functionality to a provided template type. The lifetime management behaviors of the singleton are managed by the provided template policies: CreationPolicy manages allocation and deallocation of the object, LifetimePolicy manages when the Singleton is destroyed, and ThreadingModel manages any locking mechanics for multithreaded applications. This class only supports class-level singletons.
Derived from "Modern C++ Design" by Andrei Alexandrescu and the Loki library.
Definition at line 124 of file Singleton.hpp.
| using smgl::detail::SingletonHolder< T, CreationPolicy, LifetimePolicy, ThreadingModel >::InstanceType = typename ThreadingModel<T>::VolatileType |
Underlying type of the singleton object. Often, but not always, T. For multi-threaded ThreadingModels, could be volatile T.
Definition at line 131 of file Singleton.hpp.
|
delete |
Instance cannot be constructed
|
staticprivate |
Destroys the wrapped singleton object
Definition at line 68 of file SingletonImpl.hpp.
|
static |
Access the singleton instance.
Definition at line 38 of file SingletonImpl.hpp.
|
staticprivate |
Whether the Singleton has been destroyed
Definition at line 145 of file Singleton.hpp.
|
staticprivate |
Pointer to the Singleton instance
Definition at line 143 of file Singleton.hpp.