Dune Core Modules (2.5.1)

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 
7 
15 namespace Dune
16 {
52  template<class T>
53  class Singleton
54  {
55  protected:
56  /* @brief Private constructor. */
57  Singleton(){}
59  Singleton(const Singleton&){}
62 
63  public:
68  DUNE_EXPORT static T& instance()
69  {
70  static T instance_;
71  return instance_;
72  }
73  };
74 
75 } // namespace Dune
76 
77 #endif
An adapter to turn a class into a singleton.
Definition: singleton.hh:54
Singleton(const Singleton &)
Private copy constructor.
Definition: singleton.hh:59
Singleton & operator=(const Singleton &)
Private assignment operator.
Definition: singleton.hh:61
static DUNE_EXPORT T & instance()
Get the instance of the singleton.
Definition: singleton.hh:68
Dune namespace.
Definition: alignment.hh:11
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:18
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 13, 22:30, 2024)