AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
Static Public Member Functions | Protected Member Functions
Aqua::Singleton< T > Class Template Reference

Simple but versatile singleton instance (Meyers singleton). More...

#include <Singleton.h>

Static Public Member Functions

static T * singleton ()
 Returns the instance of the class.
 

Protected Member Functions

 Singleton ()
 Constructor.
 
virtual ~Singleton ()
 Destructor.
 

Detailed Description

template<typename T>
class Aqua::Singleton< T >

Simple but versatile singleton instance (Meyers singleton).

The singletons are instances that can be accessed everywhere even though it has not been passed as argument.

To create a singleton instance just define the class as an inherited of this one:

#include <Singleton.h>
class MyClass : public Aqua::Singleton<MyClass>
{
...
};
Singleton instance. (See Aqua::Singleton for details)
Simple but versatile singleton instance (Meyers singleton).
Definition: Singleton.h:57

Then you can access your class everywhere you want (please, don't forget to include your class header):

MyClass *c = MyClass::singleton();
Warning
This implementation will not support multithreading.

Constructor & Destructor Documentation

◆ Singleton()

template<typename T >
Aqua::Singleton< T >::Singleton ( )
inlineprotected

Constructor.

◆ ~Singleton()

template<typename T >
virtual Aqua::Singleton< T >::~Singleton ( )
inlineprotectedvirtual

Destructor.

Member Function Documentation

◆ singleton()

template<typename T >
static T * Aqua::Singleton< T >::singleton ( )
inlinestatic

Returns the instance of the class.

Returns
singleton instance.

The documentation for this class was generated from the following file: