Singleton< T > Class Template Reference

#include <Pt/Singleton.h>

Singleton class template More...

Inherits NonCopyable.

Static Public Member Functions

static T & instance ()
 Returns the instance of the singleton type. More...

Protected Member Functions

 Singleton ()
 ~Singleton ()

Detailed Description

template<typename T>
class Pt::Singleton< T >

TType of the singleton
AAllocator for type T

The Singleton class template can be used to easily implement the Singleton design pattern. It can either be used directly or as a base class.

The follwing example shows how to use the singleton as a base class:

class MySingleton : public Singleton<MySingleton>
friend class Singleton<MySingleton>;
// ...

Member Function Documentation

static T& instance ( )

When called for the first time, the singleton instance will be created with the specified alloctaor. All subsequent calls will return a reference to the previously created instance.

The singleton instance