dune-common
2.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
common
singleton.hh
Go to the documentation of this file.
1
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi: set et ts=4 sw=2 sts=2:
3
#ifndef DUNE_SINGLETON_HH
4
#define DUNE_SINGLETON_HH
5
6
#include <memory>
7
15
namespace
Dune
16
{
52
template
<
class
T>
53
class
Singleton
54
{
56
static
std::auto_ptr<T> instance_;
57
protected
:
58
/* @brief Private constructor. */
59
Singleton
(){}
61
Singleton
(
const
Singleton
&){}
63
Singleton
&
operator=
(
const
Singleton
&){}
64
65
public
:
70
static
T&
instance
()
71
{
72
if
(instance_.get() == 0)
73
instance_ = std::auto_ptr<T>(
new
T());
74
return
*instance_;
75
}
76
};
77
78
template
<
class
T>
79
typename
std::auto_ptr<T> Singleton<T>::instance_;
80
81
}
// namespace Dune
82
83
#endif
Generated on Mon Feb 10 2014 23:52:39 for dune-common by
1.8.1.2