|
Devel Lib
|
A class template for creating singleton classes. More...
#include <Singleton.h>
Static Public Member Functions | |
| static T * | instance () |
| Get the instance of the Singleton class. More... | |
Protected Member Functions | |
| CSingleton ()=default | |
| Constructor. More... | |
| CSingleton (const CSingleton &)=delete | |
| Copy constructor. More... | |
| CSingleton & | operator= (const CSingleton &)=delete |
| Copy assignment operator. More... | |
| virtual | ~CSingleton ()=default |
| Destructor. More... | |
A class template for creating singleton classes.
A singleton is a design pattern that restricts the instantiation of a class to a single instance. This is useful when exactly one object is needed to coordinate actions across the system.
| T | The type that will be a singleton. |
Example
A class must derive from this class in order to become a singleton.
|
protecteddefault |
Constructor.
This constructor is protected to prevent direct instantiation of the class.
|
protecteddelete |
Copy constructor.
This constructor is deleted to prevent copying of the instance.
|
protectedvirtualdefault |
Destructor.
This destructor is virtual and does nothing, allowing derived classes to clean up if needed.
|
inlinestatic |
Get the instance of the Singleton class.
This function provides access to the single instance of the class. If the instance does not exist, it is created.
|
protecteddelete |
Copy assignment operator.
This operator is deleted to prevent assignment of the instance.