|  | CuteHMI - CuteHMI (CuteHMI.2)
    | 
Singleton template. More...
#include <cutehmi/Singleton.hpp>
 
  
| Static Public Member Functions | |
| static C & | Instance () | 
| Get instance.  More... | |
| static void | Destroy () | 
| Destroy instance.  More... | |
| Protected Member Functions | |
| Singleton () | |
| Default constructor.  More... | |
| virtual | ~Singleton () | 
| Destructor.  More... | |
|  Protected Member Functions inherited from cutehmi::NonCopyable | |
| NonCopyable ()=default | |
| NonCopyable (NonCopyable &&other)=default | |
| ~NonCopyable ()=default | |
| NonCopyable & | operator= (NonCopyable &&other)=default | 
|  Protected Member Functions inherited from cutehmi::NonMovable | |
| NonMovable ()=default | |
| Static Protected Member Functions | |
| static std::unique_ptr< C > & | InstancePtr () | 
| Get instance pointer.  More... | |
Singleton template.
It may be necessary to make derived class a friend of inheriting class to grant Singleton<C> access to its constructor.
Snippet below shows sample class, which uses Singleton template.
Singleton instance can be obtained through Instance() function.
Singleton can be a subclass of QObject, providing that QObject is its first base class, as mentioned in Qt docs.
| 
 | protected | 
Default constructor.
| 
 | protectedvirtual | 
Destructor.
| 
 | static | 
Destroy instance.
This function is provided to satisfy the requirement that QApplication has to be first created and last destroyed QObject. Once this function is called singleton becomes unusable.
| 
 | static | 
Get instance.
Returns a reference to the instance of the singleton class. Object is instantiated upon first call of this function.
| 
 | staticprotected | 
Get instance pointer.