dune-common  2.6-git
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 Protected constructor. */
57  Singleton() = default;
58 
59  public:
60 
61  Singleton(const Singleton&) = delete;
62  void operator=(const Singleton&) = delete;
63 
68  DUNE_EXPORT static T& instance()
69  {
70  static T instance_;
71  return instance_;
72  }
73  };
74 
75 } // namespace Dune
76 
77 #endif
Dune
Dune namespace.
Definition: alignedallocator.hh:9
Dune::Singleton::instance
static DUNE_EXPORT T & instance()
Get the instance of the singleton.
Definition: singleton.hh:68
visibility.hh
Definition of macros controlling symbol visibility at the ABI level.
Dune::Singleton::operator=
void operator=(const Singleton &)=delete
Dune::Singleton::Singleton
Singleton()=default
DUNE_EXPORT
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:18
Dune::Singleton
An adapter to turn a class into a singleton.
Definition: singleton.hh:53