A template class that provides an implementation of the Singleton pattern. Any class may derive from Singleton to become a Singleton. This pattern should not be abused.
Singleton.h
class MySingleton : public Singleton<MySingleton>
{
public:
/* ... */
private:
MySingleton();
//since the constructor is private, Singleton must be a friend
//so that this class can be instantiated.
friend class Singleton<MySingleton>;
};
·A template class that provides an implementation of the Singleton pattern. | |
The one and only one method of accessing a Singleton. | |
The Singleton constructor. | |
The Singleton destructor. | |
The Singleton copy constructor. | |
The Singleton assignment operator. |
| static T &get() |
| Singleton() |
| virtual ~Singleton() |
|