degate  0.1.2
Static Public Member Functions | Protected Member Functions | Static Private Attributes
degate::SingletonBase< T > Class Template Reference

This is a base class for singletons. More...

#include <SingletonBase.h>

Inheritance diagram for degate::SingletonBase< T >:
Inheritance graph
[legend]

List of all members.

Static Public Member Functions

static T & get_instance ()
 Get a reference to the singleton.
static void init ()
 Initialize the singleton.

Protected Member Functions

 SingletonBase ()
 Constructor.
virtual ~SingletonBase ()
 Destructor.

Static Private Attributes

static boost::scoped_ptr< T > t
static boost::once_flag flag = BOOST_ONCE_INIT

Detailed Description

template<class T>
class degate::SingletonBase< T >

This is a base class for singletons.

Definition at line 38 of file SingletonBase.h.


Constructor & Destructor Documentation

template<class T>
degate::SingletonBase< T >::SingletonBase ( ) [inline, protected]

Constructor.

Definition at line 50 of file SingletonBase.h.

{}
template<class T>
virtual degate::SingletonBase< T >::~SingletonBase ( ) [inline, protected, virtual]

Destructor.

Definition at line 56 of file SingletonBase.h.

{}

Member Function Documentation

template<class T>
static T& degate::SingletonBase< T >::get_instance ( ) [inline, static]

Get a reference to the singleton.

Definition at line 64 of file SingletonBase.h.

                              {
      boost::call_once(init, flag);
      return *t;
    }
template<class T>
static void degate::SingletonBase< T >::init ( ) [inline, static]

Initialize the singleton.

Definition at line 73 of file SingletonBase.h.

Referenced by degate::SingletonBase< Configuration >::get_instance().

                       {
      t.reset(new T());
    }

Here is the caller graph for this function:


Member Data Documentation

template<class T>
boost::once_flag degate::SingletonBase< T >::flag = BOOST_ONCE_INIT [static, private]
template<class T>
boost::scoped_ptr< T > degate::SingletonBase< T >::t [static, private]

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