diff --git a/Framework/Utilities/Singleton.h b/Framework/Utilities/Singleton.h index 3780cc99a1398833a77729e26eb11f9b089ba753..dd0ff2ceff144b92eb69ba7b614f0d8290267755 100644 --- a/Framework/Utilities/Singleton.h +++ b/Framework/Utilities/Singleton.h @@ -15,9 +15,6 @@ //#define OFFLINE_USE_GAMMA_SINGLETON namespace corsika::utl { - -#ifndef OFFLINE_USE_GAMMA_SINGLETON - /** * \class Singleton Singleton.h utl/Singleton.h * @@ -49,101 +46,18 @@ namespace corsika::utl { class Singleton { public: static T& GetInstance() -#ifdef __MAKECINT__ - ; -#else { static T instance; return instance; } -#endif + + Singleton(const Singleton&) = delete; + Singleton& operator=(const Singleton&) = delete; protected: // derived class can call ctor and dtor Singleton() {} ~Singleton() {} - - private: - // no one should do copies - Singleton(const Singleton&); - Singleton& operator=(const Singleton&); - }; - -#else - - /// classical Gamma singleton - template <typename T> - class Singleton { - public: - static T& GetInstance() { - if (!fgInstance) fgInstance = new T; - return *fgInstance; - } - - protected: - // derived class can call ctor and dtor - Singleton() {} - ~Singleton() {} - - private: - // no one should do copies - Singleton(const Singleton&); - Singleton& operator=(const Singleton&); - - static T* fgInstance = 0; - }; - -#endif - - /** - * \class LeakingSingleton Singleton.h utl/Singleton.h - * - * \brief CRTP for leaking singleton - * - * This type of creation (Gamma singleton) leaks the object at - * the end of the run, i.e. class T destructor does not get called - * in at_exit(). - * - * This singleton can be implemented as follows - * \code - * #include <utl/Singleton.h> - * - * class SomeClass : public utl::LeakingSingleton<SomeClass> { - * ... - * private: - * // prevent creation, destruction - * SomeClass() { } - * ~SomeClass() { } - * - * friend class utl::LeakingSingleton<SomeClass>; - * }; - * \endcode - * LeakingSingleton automatically prevents copying of the derived - * class. - * - * \author Darko Veberic - * \date 9 Aug 2006 - * \version $Id: Singleton.h 25091 2014-01-30 09:49:57Z darko $ - * \ingroup stl - */ - - template <class T> - class LeakingSingleton { - public: - static T& GetInstance() { - static T* const instance = new T; - return *instance; - } - - protected: - // derived class can call ctor and dtor - LeakingSingleton() {} - ~LeakingSingleton() {} - - private: - // no one should do copies - LeakingSingleton(const LeakingSingleton&); - LeakingSingleton& operator=(const LeakingSingleton&); }; } // namespace corsika::utl