00001 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 // vi: set et ts=4 sw=2 sts=2: 00003 #ifndef DUNE_SINGLETON_HH 00004 #define DUNE_SINGLETON_HH 00005 00006 #include <dune/common/visibility.hh> 00007 00015 namespace Dune 00016 { 00052 template<class T> 00053 class Singleton 00054 { 00055 protected: 00056 /* @brief Private constructor. */ 00057 Singleton(){} 00059 Singleton(const Singleton&){} 00061 Singleton& operator=(const Singleton&){} 00062 00063 public: 00068 DUNE_EXPORT static T& instance() 00069 { 00070 static T instance_; 00071 return instance_; 00072 } 00073 }; 00074 00075 } // namespace Dune 00076 00077 #endif