Singleton< T > Class Template Reference

A singleton is perhaps the simplest design pattern, common to many programming languages and it’s the way to allow one and only one instance of a class. More...

#include <common.h>

Inheritance diagram for Singleton< T >:
Inheritance graph
[legend]

List of all members.

Static Public Member Functions

static T & instance ()

Protected Member Functions

 Singleton ()
virtual ~Singleton ()

Private Member Functions

 Singleton (const Singleton &)
Singletonoperator= (const Singleton &)
T & operator= (const T &)

Detailed Description

template<class T>
class Singleton< T >

A singleton is perhaps the simplest design pattern, common to many programming languages and it’s the way to allow one and only one instance of a class.

The key to creating a singleton is to prevent the client programmer from having any control over the lifetime of the object. To do this, all constructors are declared private, so that we also prevent the compiler from implicitly generating any constructors. Also the copy constructor and assignment operator (which intentionally have no implementations, as they will never be called) are declared private to prevent any sort of copies being made.


Constructor & Destructor Documentation

template<class T>
Singleton< T >::Singleton ( const Singleton< T > &   )  [private]
template<class T>
Singleton< T >::Singleton (  )  [inline, protected]
template<class T>
virtual Singleton< T >::~Singleton (  )  [inline, protected, virtual]

Member Function Documentation

template<class T>
static T& Singleton< T >::instance (  )  [inline, static]
template<class T>
T& Singleton< T >::operator= ( const T &   )  [private]
template<class T>
Singleton& Singleton< T >::operator= ( const Singleton< T > &   )  [private]

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

Generated by  doxygen 1.6.2