Devel Lib
Singleton.h
1 #pragma once
2 
5 namespace Devel {
30  template<typename T>
31  class CSingleton {
32  protected:
36  CSingleton() = default;
37 
41  CSingleton(const CSingleton &) = delete;
42 
46  CSingleton &operator=(const CSingleton &) = delete;
47 
51  virtual ~CSingleton() = default;
52 
53  public:
59  static T *instance() {
60  static T s_oInstance;
61  return &s_oInstance;
62  }
63  };
64 }
A class template for creating singleton classes.
Definition: Singleton.h:31
CSingleton()=default
Constructor.
virtual ~CSingleton()=default
Destructor.
CSingleton(const CSingleton &)=delete
Copy constructor.
static T * instance()
Get the instance of the Singleton class.
Definition: Singleton.h:59
CSingleton & operator=(const CSingleton &)=delete
Copy assignment operator.
A namespace for development related classes and functions.