From 0caba77f049add11158ed1b5572f74c1b52e37ca Mon Sep 17 00:00:00 2001 From: Hauke Moenck <hauke_moenck@gmx.de> Date: Fri, 26 Oct 2018 15:15:49 +0200 Subject: [PATCH] Removed liabilities --- Src/util/singleton.h | 63 -------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 Src/util/singleton.h diff --git a/Src/util/singleton.h b/Src/util/singleton.h deleted file mode 100644 index d171b6b..0000000 --- a/Src/util/singleton.h +++ /dev/null @@ -1,63 +0,0 @@ -#pragma once -#include <map> -#include "settings/Settings.h" - -namespace BioTracker { -namespace Util { - -template<class T> -class Singleton { - - protected: - Singleton() {} - ~Singleton() {} - Singleton(const Singleton &) = delete; - Singleton &operator=(const Singleton &) = delete; - - public: - static T &getInstance(); - -}; - -template<class T> -T &Singleton<T>::getInstance() { - static T instance; - return instance; -} - -/* - * Just like Singleton, but I want to have several different singleton instances of the same type which I can address by name. - * Example is the Settings class, which is also threadsafe by plastering it with mutexes. - * This way you can access everywhere in the application the current configuration from different threads without worries. - * Only recommendet, as performance is not relevant when accessing configuration. -*/ -template<class T> -class TypedSingleton { - -protected: - TypedSingleton() {} - ~TypedSingleton() {} - TypedSingleton(const TypedSingleton &) = delete; - TypedSingleton &operator=(const TypedSingleton &) = delete; - -public: - static T *getInstance(std::string s); - -}; - -template<class T> -T *TypedSingleton<T>::getInstance(std::string s) { - static std::map<std::string, T*> instance; - if (instance.find(s) != instance.end()) { - return instance.find(s)->second; - } - else { - T* t = new T(s); - instance.insert(std::pair<std::string, T*>(s, t)); - return t; - } - return 0; -} - -} -} -- GitLab