12#ifndef SINGLETON_H_6014714286
13#define SINGLETON_H_6014714286
58template<
typename InstanceType >
76 CARNA_ASSERT_EX( instancePtr ==
nullptr,
"Multiple singleton instances created." );
85 if( instancePtr !=
nullptr )
103 instancePtr =
nullptr;
111 return instancePtr ==
nullptr ? *
new InstanceType() : *instancePtr;
119 return instancePtr !=
nullptr;
125template<
typename InstanceType >
126InstanceType* Singleton< InstanceType >::instancePtr =
nullptr;
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
#define CARNA_ASSERT_EX(expression, description)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Represents an association.
static void reset()
Deletes the only instance from class InstanceType.
static bool exists()
Tells whether the instance from class InstanceType currently exists.
static InstanceType & instance()
Returns the only instance from class InstanceType.
Singleton()
Denotes that the instance was created. Default constructor is hidden.
InstanceType Instance
Denotes the class, that is derived from this class template.
virtual ~Singleton()
Denotes that the instance was deleted.
#define NON_COPYABLE
Features class it is placed in as non-copyable.