Merge pull request #62 from tboudreaux/refactor/spelling
refactor(serif): fixed typos and updated names to reflect 4DSSE->SERiF
This commit is contained in:
@@ -29,19 +29,18 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
namespace serif {
|
||||
namespace config {
|
||||
namespace serif::config {
|
||||
|
||||
Config::Config() {}
|
||||
Config::Config() {}
|
||||
|
||||
Config::~Config() {}
|
||||
Config::~Config() {}
|
||||
|
||||
Config& Config::getInstance() {
|
||||
Config& Config::getInstance() {
|
||||
static Config instance;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
bool Config::loadConfig(const std::string& configFile) {
|
||||
bool Config::loadConfig(const std::string& configFile) {
|
||||
configFilePath = configFile;
|
||||
try {
|
||||
yamlRoot = YAML::LoadFile(configFile);
|
||||
@@ -51,21 +50,21 @@ bool Config::loadConfig(const std::string& configFile) {
|
||||
}
|
||||
m_loaded = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool Config::isKeyInCache(const std::string &key) {
|
||||
bool Config::isKeyInCache(const std::string &key) {
|
||||
return configMap.find(key) != configMap.end();
|
||||
}
|
||||
}
|
||||
|
||||
void Config::addToCache(const std::string &key, const YAML::Node &node) {
|
||||
void Config::addToCache(const std::string &key, const YAML::Node &node) {
|
||||
configMap[key] = node;
|
||||
}
|
||||
}
|
||||
|
||||
void Config::registerUnknownKey(const std::string &key) {
|
||||
void Config::registerUnknownKey(const std::string &key) {
|
||||
unknownKeys.push_back(key);
|
||||
}
|
||||
}
|
||||
|
||||
bool Config::has(const std::string &key) {
|
||||
bool Config::has(const std::string &key) {
|
||||
if (!m_loaded) {
|
||||
throw std::runtime_error("Error! Config file not loaded");
|
||||
}
|
||||
@@ -85,27 +84,26 @@ bool Config::has(const std::string &key) {
|
||||
// Key exists and is of the requested type
|
||||
addToCache(key, node);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void recurse_keys(const YAML::Node& node, std::vector<std::string>& keyList, const std::string& path = "") {
|
||||
void recurse_keys(const YAML::Node& node, std::vector<std::string>& keyList, const std::string& path = "") {
|
||||
if (node.IsMap()) {
|
||||
for (const auto& it : node) {
|
||||
std::string key = it.first.as<std::string>();
|
||||
std::string new_path = path.empty() ? key : path + ":" + key;
|
||||
auto key = it.first.as<std::string>();
|
||||
auto new_path = path.empty() ? key : path + ":" + key;
|
||||
recurse_keys(it.second, keyList, new_path);
|
||||
}
|
||||
} else {
|
||||
keyList.push_back(path);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> Config::keys() const {
|
||||
std::vector<std::string> Config::keys() const {
|
||||
std::vector<std::string> keyList;
|
||||
YAML::Node node = YAML::Clone(yamlRoot);
|
||||
recurse_keys(node, keyList);
|
||||
return keyList;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace config
|
||||
} // namespace serif
|
||||
}
|
||||
|
||||
@@ -32,18 +32,18 @@
|
||||
#include "yaml-cpp/yaml.h"
|
||||
|
||||
// -- Forward Def of Resource manager to let it act as a friend of Config --
|
||||
namespace serif { namespace resource { class ResourceManager; } } // Forward declaration
|
||||
namespace serif::resource { class ResourceManager; }
|
||||
|
||||
class configTestPrivateAccessor; // Forward declaration for test utility
|
||||
|
||||
namespace serif {
|
||||
namespace config {
|
||||
namespace serif::config {
|
||||
|
||||
/**
|
||||
/**
|
||||
* @class Config
|
||||
* @brief Singleton class to manage configuration settings loaded from a YAML file.
|
||||
*/
|
||||
class Config {
|
||||
private:
|
||||
class Config {
|
||||
private:
|
||||
/**
|
||||
* @brief Private constructor to prevent instantiation.
|
||||
*/
|
||||
@@ -117,7 +117,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* @brief Get the singleton instance of the Config class.
|
||||
* @return Reference to the Config instance.
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
template <typename T>
|
||||
T get(const std::string &key, T defaultValue) {
|
||||
if (!m_loaded) {
|
||||
// ONLY THROW ERROR IF HARSH OR WARN CONFIGURATION
|
||||
// ONLY THROW ERROR IF HARSH OR WARN CONFIGURATION
|
||||
#if defined(CONFIG_HARSH)
|
||||
throw std::runtime_error("Error! Config file not loaded. To disable this error, recompile with CONFIG_HARSH=0");
|
||||
#elif defined(CONFIG_WARN)
|
||||
@@ -240,7 +240,6 @@ public:
|
||||
friend class ::configTestPrivateAccessor; // Friend declaration for global test accessor
|
||||
// -- Resource Manager is a friend of config so it can create a seperate instance
|
||||
friend class serif::resource::ResourceManager; // Adjusted friend declaration
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace config
|
||||
} // namespace serif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user