+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __NEURUN_CONFIG_CONFIG_MANAGER_H__
-#define __NEURUN_CONFIG_CONFIG_MANAGER_H__
-
-#include <algorithm>
-#include <string>
-#include <unordered_map>
-
-#include "IConfigSource.h"
-
-/**
- * @file ConfigManager.h
- * @brief This file contains neurun::util::ConfigManager class
- */
-
-namespace neurun
-{
-namespace util
-{
-
-/**
- * @brief Class that manages configurations
- */
-
-class ConfigManager
-{
-public:
- static ConfigManager &instance();
-
-private:
- /**
- * @brief Construct a new ConfigManager object
- */
- ConfigManager(const IConfigSource &source);
-
-public:
- /**
- * @brief Return the configuration value of given key
- *
- * @tparam T Type of the config
- * @param key String key value
- *
- * @return The configuration value of given key value
- */
- template <typename T> T get(const std::string &key) const;
-
-private:
- std::unordered_map<std::string, std::string> _map;
-};
-
-template <> bool ConfigManager::get<bool>(const std::string &key) const;
-template <> int ConfigManager::get<int>(const std::string &key) const;
-template <> std::string ConfigManager::get<std::string>(const std::string &key) const;
-
-} // namespace util
-} // namespace neurun
-
-#endif // __NEURUN_CONFIG_CONFIG_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "util/ConfigManager.h"
-
-#include <cassert>
-
-#include "util/EnvConfigSource.h"
-#include "util/logging.h"
-
-namespace neurun
-{
-namespace util
-{
-
-#define CONFIG(Name, Type, Default) const char *Name = #Name;
-
-#include "util/Config.lst"
-
-#undef CONFIG
-
-ConfigManager &ConfigManager::instance()
-{
- static ConfigManager manager{EnvConfigSource{}};
- return manager;
-}
-
-ConfigManager::ConfigManager(const IConfigSource &source)
-{
-#define CONFIG(Name, Type, Default) \
- { \
- auto name = std::string{#Name}; \
- auto insert_status = _map.emplace(name, std::string{Default}); \
- assert(insert_status.second); /* Insertion must success */ \
- auto value = source.get(name); \
- if (!value.empty()) \
- { \
- insert_status.first->second = value; \
- } \
- }
-
-#include "util/Config.lst"
-
-#undef CONFIG
-}
-
-template <> bool ConfigManager::get<bool>(const std::string &key) const
-{
- auto raw = _map.at(key);
-
- static const std::array<std::string, 5> false_list{"0", "OFF", "FALSE", "N", "NO"};
- auto false_found = std::find(false_list.begin(), false_list.end(), raw);
-
- return (false_found == false_list.end());
-}
-
-template <> int ConfigManager::get<int>(const std::string &key) const
-{
- auto raw = _map.at(key);
- return std::stoi(raw);
-}
-
-template <> std::string ConfigManager::get<std::string>(const std::string &key) const
-{
- auto raw = _map.at(key);
- return raw;
-}
-
-} // namespace util
-} // namespace neurun