PTLib  Version 2.14.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PSingleton< Type, GuardType > Class Template Reference

Template class for a simple singleton object. More...

#include <object.h>

Inheritance diagram for PSingleton< Type, GuardType >:

Public Member Functions

 PSingleton ()
 
Type * operator-> () const
 
Type & operator* () const
 

Protected Attributes

Type * m_instance
 

Detailed Description

template<class Type, typename GuardType = unsigned>
class PSingleton< Type, GuardType >

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, PAtomicInteger> MySafeSingleton;
        MySafeSingleton()->DoSomething();

Constructor & Destructor Documentation

template<class Type, typename GuardType = unsigned>
PSingleton< Type, GuardType >::PSingleton ( )
inline

Member Function Documentation

template<class Type, typename GuardType = unsigned>
Type& PSingleton< Type, GuardType >::operator* ( ) const
inline
template<class Type, typename GuardType = unsigned>
Type* PSingleton< Type, GuardType >::operator-> ( ) const
inline

Member Data Documentation

template<class Type, typename GuardType = unsigned>
Type* PSingleton< Type, GuardType >::m_instance
protected

The documentation for this class was generated from the following file: