Dune Core Modules (2.3.1)
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. More... | |
Protected Member Functions | |
Singleton (const Singleton &) | |
Private copy constructor. | |
Singleton & | operator= (const Singleton &) |
Private assignment operator. | |
Detailed Description
template<class T>
class Dune::Singleton< 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>:
#include<dune/common/singleton.hh>
{
public:
Foo()
{
bytes = new char[1000];
}
~Foo()
{
delete[] bytes;
}
private:
char* bytes;
};
Useful wrapper for creating singletons.
Or one can construct a Singleton of an existing class. Say Foo1 is a class with parameterless constructor then
typedef Dune::Singleton<Foo1> FooSingleton;
Foo1 instance& = FooSingleton::instance();
static T & instance()
Get the instance of the singleton.
Definition: singleton.hh:70
Creates a singleton of that class and accesses its instance.
Member Function Documentation
◆ instance()
template<class T >
|
inlinestatic |
Get the instance of the singleton.
- Returns
- The instance of the singleton.
The documentation for this class was generated from the following file:
- dune/common/singleton.hh
|
Legal Statements / Impressum |
Hosted by TU Dresden |
generated with Hugo v0.111.3
(Nov 12, 23:30, 2024)