A simple implementation of the Singleton pattern. More...
#include <Singleton.h>
Static Public Member Functions | |
| static T & | get () |
| static void | instantiateDerived (T *t) |
| static void | clean () |
Private Member Functions | |
| Singleton () | |
| ~Singleton () | |
| Singleton (const Singleton &s) | |
| Singleton< T > & | operator= (const Singleton &s) |
Static Private Attributes | |
| static T * | mInstance = 0 |
A simple implementation of the Singleton pattern.
This is a very basic implementation of the Singleton pattern used for getting Singleton's to the core utilities in LoM.
Singleton offers only basic exception safety. If an exception occurs during instantiation of its internal type the exception will not be caught. In general practice using any of the core utility classes, an exception being thrown indicates a serious error that must be address by the client.Singleton offers a static member method Singleton::clean(). This should only ever be used when nothing is using the instance of T (e.g., at the end of a program. | static void Singleton< T >::clean | ( | ) | [inline, static] |
Frees any currently instantiated instances of T.
| static T& Singleton< T >::get | ( | ) | [inline, static] |
Gets an instance of the specified type T. If an instance hasn't yet been created, one is created.
| static void Singleton< T >::instantiateDerived | ( | T * | t | ) | [inline, static] |
Sets the internal type T to a type that derives from T.
Singleton<T>::instantiateDerived(new T()).Singleton::get();Internal instance of type T.
1.7.1