29 #ifndef YGGDRASILWM_CONFIGHANDLER_HPP
30 #define YGGDRASILWM_CONFIGHANDLER_HPP
34 #include <unordered_map>
35 #include "json/json.h"
67 auto it =
configMap_.find(std::type_index(
typeid(T)));
69 throw std::runtime_error(
"ConfigData not found");
71 return std::static_pointer_cast<T>(it->second);
81 static_assert(std::is_base_of<ConfigDataBase, T>::value,
"T must be a subclass of ConfigData");
82 configMap_[std::type_index(
typeid(T))] = configData;
89 static void Create(
const std::string& configPath);
125 std::unordered_map<std::type_index, std::shared_ptr<ConfigDataBase>>
configMap_;
ConfigDataBase class header. This class is an interface for the ConfigData classes.
Handle file I/O and JSON parsing for the configuration file. If no path is provided,...
Definition: ConfigFileHandler.hpp:40
ConfigHandler class This class is responsible for handling the configuration It can be created with a...
Definition: ConfigHandler.hpp:54
std::string configPath_
Definition: ConfigHandler.hpp:123
std::unordered_map< std::type_index, std::shared_ptr< ConfigDataBase > > configMap_
Definition: ConfigHandler.hpp:125
static unsigned long colorCodeToULong(const std::string &colorCode)
Convert a string containing a color code to unsigned long.
Definition: ConfigHandler.cpp:94
ConfigHandler(const ConfigHandler &)=delete
static ConfigHandler & GetInstance()
Get the ConfigHandler object Throws an exception if the object is not created.
Definition: ConfigHandler.cpp:46
ConfigHandler()
Construct a new ConfigHandler object without a path Instanciate a ConfigFileHandler Object without a ...
Definition: ConfigHandler.cpp:58
static ConfigHandler * instance_
Definition: ConfigHandler.hpp:124
static void Destroy()
Destroy the ConfigHandler object.
Definition: ConfigHandler.cpp:52
ConfigHandler & operator=(const ConfigHandler &)=delete
std::shared_ptr< T > getConfigData()
Get the ConfigData object of type T.
Definition: ConfigHandler.hpp:66
void addConfigData(std::shared_ptr< T > configData)
Definition: ConfigHandler.hpp:80
void configInit()
Initialize the ConfigHandler Read the configuration file and store the JSon root object in Json::Valu...
Definition: ConfigHandler.cpp:65
static void Create()
Definition: ConfigHandler.cpp:41