A singleton that wraps a pointer provided by a storage.
More...
#include <gf/Singleton.h>
template<typename T>
class gf::Singleton< T >
A singleton that wraps a pointer provided by a storage.
This class should be used with a global variable. It acts as an access to a singleton which storage is provided by a gf::SingletonStorage<T>.
int main() {
gFoo().bar();
}
- See also
- gf::SingletonStorage
Default constructor.
It initialize the underlying pointer to nullptr. The actual initialization is done when the storage is allocated.
Deleted copy constructor.
Deleted move constructor.
Check if the singleton has been initialized.
- Returns
- True if the singleton is valid
Access the singleton.
The access of the singleton must be done after a storage has been provided. Otherwise, the behaviour is undefined (and may result in a crash).
- Returns
- a reference to the stored singleton
Reset the singleton.
After a call to this function, the singleton must be accessed anymore.