1 #ifndef CONFIGURATOR_HPP 2 #define CONFIGURATOR_HPP 6 #include "StringConvertible.hpp" 7 #include "PtrStringCovertible.hpp" 9 #define addConfVar(VAR){\ 10 auto ptr = std::make_shared<PtrStringConvertible<decltype(VAR)>>(&VAR);\ 11 Configurator::connectConfigurationVariable(ptr, #VAR);\ 14 #define addNamedConfVar(NAME, VAR){\ 15 auto ptr = std::make_shared<PtrStringConvertible<decltype(VAR)>>(&VAR);\ 16 Configurator::connectConfigurationVariable(ptr, #NAME);\ 19 #define delConfVar(VAR) Configurator::detachConfigurationVariable(#VAR) 21 #define relConfVar(VAR) Configurator::reloadVarFromCache(#VAR) 23 #define sscMapAddVar(MAP,VAR) MAP[#VAR]=std::make_shared<PtrStringConvertible<decltype(VAR)>>(&VAR) 25 #define varPair(VAR) {#VAR, std::make_shared<PtrStringConvertible<decltype(VAR)>>(&VAR)} 28 typedef std::map<std::string, std::string> StringStringMap;
29 typedef std::map<std::string, StringConvertiblePtr> StringStringConvertibleMap;
33 static void connectConfigurationVariable(
const StringConvertiblePtr&,
const std::string&&);
34 static bool detachConfigurationVariable(
const std::string&&);
35 static bool save(
const std::string& path =
"");
36 static bool load(
const std::string& path =
"",
bool logError =
true);
37 static std::string getRawParameterValue(
const std::string&& name);
38 static std::string getDefaultConfigurationPath();
39 static void setDefaultConfigurationPath(
const std::string& value);
40 static bool writeVars(
const sf::String&, StringStringConvertibleMap&&, StringStringMap* ssMap =
nullptr);
41 static bool loadVars(
const sf::String&, StringStringConvertibleMap&&, StringStringMap* ssMap =
nullptr,
bool logError =
true);
42 static bool reloadVarFromCache(
const std::string&& s =
"");
45 static StringStringConvertibleMap configVars;
46 static StringStringMap configMap;
47 static std::string defaultConfigurationPath;
54 #endif // CONFIGURATOR_HPP Definition: Configurator.hpp:31