template<class Type, typename GuardType = unsigned, Type *(*)() Creator = PSingletonCreatorDefault<Type>>
class PSingleton< Type, GuardType, Creator >
Template class for a simple singleton object.
Usage is typically like:
typedef PSingleton<MyClass> MySingleton;
MySingleton()->DoSomething();
Default is not thread safe, however the following is:
typedef PSingleton<MyClass, atomic<uint32_t> > MySafeSingleton;
MySafeSingleton()->DoSomething();
If the singleton class requires parameters on construction, then a creator function may be included in the template parameters:
MyClass * CreateMyClass() { return new MyClass("fred"); }
typedef PSingleton<MyClass, atomic<uint32_t>, CreateMyClass> MySafeSingleton;
MySafeSingleton()->DoSomething();