From 4fbf3049d63362e1bd007d8f10675118566cccc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Fri, 14 Dec 2018 10:37:05 +0900 Subject: [PATCH] [neurun] Create a singleton for ConfigManager (#4040) Create a singleton for ConfigManager. Restrict ctor to be private so it does not instantiated by code from other places. Signed-off-by: Hanjoung Lee --- runtimes/neurun/src/util/config/ConfigManager.cc | 6 ++++++ runtimes/neurun/src/util/config/ConfigManager.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/runtimes/neurun/src/util/config/ConfigManager.cc b/runtimes/neurun/src/util/config/ConfigManager.cc index 546369d..9b8f97d 100644 --- a/runtimes/neurun/src/util/config/ConfigManager.cc +++ b/runtimes/neurun/src/util/config/ConfigManager.cc @@ -23,6 +23,12 @@ namespace neurun namespace config { +ConfigManager &ConfigManager::instance() +{ + static ConfigManager manager; + return manager; +} + ConfigManager::ConfigManager() { auto fetch_from_env_var = [&](const std::string &key) { diff --git a/runtimes/neurun/src/util/config/ConfigManager.h b/runtimes/neurun/src/util/config/ConfigManager.h index 59b4e79..8c5b852 100644 --- a/runtimes/neurun/src/util/config/ConfigManager.h +++ b/runtimes/neurun/src/util/config/ConfigManager.h @@ -38,6 +38,9 @@ namespace config class ConfigManager { public: + static ConfigManager &instance(); + +private: /** * @brief Construct a new ConfigManager object. Fetch variables from Environment Variables. */ -- 2.7.4