All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | List of all members
blaze::Singleton< T, D1, D2, D3, D4, D5, D6, D7, D8 > Class Template Reference

Base class for all lifetime managed singletons.The Singleton class represents the base class for all lifetime managed singletons of the Blaze library. Classes, which are supposed to be implemented in terms of the singleton pattern, only have to derive from this class in order to gain all basic characteristics of a singleton: More...

#include <Singleton.h>

Inherits blaze::NonCopyable.

Public Types

typedef Singleton< T, D1, D2,
D3, D4, D5, D6, D7, D8 > 
SingletonType
 Type of this Singleton instance.
 

Public Member Functions

typedef BLAZE_TYPELIST_8 (D1, D2, D3, D4, D5, D6, D7, D8) Dependencies
 Type list of all lifetime dependencies.
 

Static Public Member Functions

Instance function
static boost::shared_ptr< T > instance ()
 

Protected Member Functions

 Singleton ()
 Constructor for the Singleton class.
 
 ~Singleton ()
 Destructor for the Singleton class.
 

Member variables

boost::shared_ptr< D1 > dependency1_
 Handle to the first lifetime dependency.
 
boost::shared_ptr< D2 > dependency2_
 Handle to the second lifetime dependency.
 
boost::shared_ptr< D3 > dependency3_
 Handle to the third lifetime dependency.
 
boost::shared_ptr< D4 > dependency4_
 Handle to the fourth lifetime dependency.
 
boost::shared_ptr< D5 > dependency5_
 Handle to the fifth lifetime dependency.
 
boost::shared_ptr< D6 > dependency6_
 Handle to the sixth lifetime dependency.
 
boost::shared_ptr< D7 > dependency7_
 Handle to the seventh lifetime dependency.
 
boost::shared_ptr< D8 > dependency8_
 Handle to the eighth lifetime dependency.
 
static boost::mutex instanceMutex_
 Synchronization mutex for access to the singleton.
 

Detailed Description

template<typename T, typename D1 = NullType, typename D2 = NullType, typename D3 = NullType, typename D4 = NullType, typename D5 = NullType, typename D6 = NullType, typename D7 = NullType, typename D8 = NullType>
class blaze::Singleton< T, D1, D2, D3, D4, D5, D6, D7, D8 >

Base class for all lifetime managed singletons.

The Singleton class represents the base class for all lifetime managed singletons of the Blaze library. Classes, which are supposed to be implemented in terms of the singleton pattern, only have to derive from this class in order to gain all basic characteristics of a singleton:

The only prerequisite for classes deriving from the Singleton class template is the existance of a default constructor. In case no default constructor is available, the Blaze singleton functionality cannot be used!
Due to the use of the Singleton base class, lifetime dependencies between classes can be expressed very conveniently. The following example demonstrates this by means of the World class, which defines a lifetime dependency on the Logger class, which represents the core of the Blaze logging functionality:

// Definition of the World class
// The world is implemented in terms of the singleton pattern by
class World : private Singleton<World,Logger>
{
private:
World();
...
...
};

TODO: Finalize the documentation

Constructor & Destructor Documentation

template<typename T, typename D1 = NullType, typename D2 = NullType, typename D3 = NullType, typename D4 = NullType, typename D5 = NullType, typename D6 = NullType, typename D7 = NullType, typename D8 = NullType>
blaze::Singleton< T, D1, D2, D3, D4, D5, D6, D7, D8 >::Singleton ( )
inlineexplicitprotected

Constructor for the Singleton class.

In case a cyclic lifetime dependency is detected, a compilation error is created.


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