dune-common
2.2.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
common
singleton.hh
Go to the documentation of this file.
1
#ifndef DUNE_SINGLETON_HH
2
#define DUNE_SINGLETON_HH
3
4
#include <memory>
5
13
namespace
Dune
14
{
50
template
<
class
T>
51
class
Singleton
52
{
54
static
std::auto_ptr<T> instance_;
55
protected
:
56
/* @brief Private constructor. */
57
Singleton
(){}
59
Singleton
(
const
Singleton
&){}
61
Singleton
&
operator=
(
const
Singleton
&){}
62
63
public
:
68
static
T&
instance
()
69
{
70
if
(instance_.get() == 0)
71
instance_ = std::auto_ptr<T>(
new
T());
72
return
*instance_;
73
}
74
};
75
76
template
<
class
T>
77
typename
std::auto_ptr<T> Singleton<T>::instance_;
78
79
}
// namespace Dune
80
81
#endif
Generated on Sun May 12 2013 23:19:48 for dune-common by
1.8.3.1