dune-common  2.2.0
Static Public Member Functions | Protected Member Functions | List of all members
Dune::Singleton< T > Class Template Reference

An adapter to turn a class into a singleton. More...

#include <dune/common/singleton.hh>

Static Public Member Functions

static T & instance ()
 Get the instance of the singleton.

Protected Member Functions

 Singleton ()
 Singleton (const Singleton &)
 Private copy constructor.
Singletonoperator= (const Singleton &)
 Private assignment operator.

Detailed Description

template<class T>
class Dune::Singleton< T >

An adapter to turn a class into a singleton.

The class represented by the template parameter T must have a parameterless constructor.

Class T can be publicly derived from Singleton<T>:

class Foo : public Dune::Singleton<Foo>
{
public:
Foo()
{
bytes = new char[1000];
}
~Foo()
{
delete[] bytes;
}
private:
char* bytes;
};

Or one can construct a Singleton of an existing class. Say Foo1 is a class with parameterless constructor then

typedef Dune::Singleton<Foo1> FooSingleton;

Creates a singleton of that class and accesses its instance.

Constructor & Destructor Documentation

template<class T >
Dune::Singleton< T >::Singleton ( )
inlineprotected
template<class T >
Dune::Singleton< T >::Singleton ( const Singleton< T > &  )
inlineprotected

Private copy constructor.

Member Function Documentation

template<class T >
static T& Dune::Singleton< T >::instance ( )
inlinestatic

Get the instance of the singleton.

Returns
The instance of the singleton.
template<class T >
Singleton& Dune::Singleton< T >::operator= ( const Singleton< T > &  )
inlineprotected

Private assignment operator.


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