feat(Core/Config): rework configs load system (#2566)

This commit is contained in:
Kargatum
2020-07-12 22:47:12 +07:00
committed by GitHub
parent 2fb9985a99
commit 94e6ef17a2
8 changed files with 175 additions and 136 deletions

View File

@@ -21,11 +21,10 @@ class ConfigMgr
friend class ConfigLoader;
public:
static ConfigMgr* instance();
/// Method used only for loading main configuration files (authserver.conf and worldserver.conf)
bool LoadInitial(char const* file);
bool LoadInitial(std::string const& file);
/**
* This method loads additional configuration files
@@ -33,30 +32,36 @@ public:
*
* @return true if loading was successful
*/
bool LoadMore(char const* file);
bool LoadMore(std::string const& file);
bool Reload();
std::string GetStringDefault(const char* name, const std::string& def, bool logUnused = true);
bool GetBoolDefault(const char* name, bool def, bool logUnused = true);
int GetIntDefault(const char* name, int def, bool logUnused = true);
float GetFloatDefault(const char* name, float def, bool logUnused = true);
bool LoadAppConfigs(std::string const& applicationName = "worldserver");
bool LoadModulesConfigs();
std::string GetStringDefault(std::string const& name, const std::string& def, bool logUnused = true);
bool GetBoolDefault(std::string const& name, bool def, bool logUnused = true);
int GetIntDefault(std::string const& name, int def, bool logUnused = true);
float GetFloatDefault(std::string const& name, float def, bool logUnused = true);
std::list<std::string> GetKeysByString(std::string const& name);
bool isDryRun() { return this->dryRun; }
void setDryRun(bool mode) { this->dryRun = mode; }
bool isDryRun() { return dryRun; }
void setDryRun(bool mode) { dryRun = mode; }
void SetConfigList(std::string const& fileName, std::string const& modulesConfigList = "");
private:
bool dryRun = false;
bool GetValueHelper(const char* name, ACE_TString &result);
bool LoadData(char const* file);
bool GetValueHelper(const char* name, ACE_TString& result);
bool LoadData(std::string const& file);
typedef ACE_Thread_Mutex LockType;
typedef ACE_Guard<LockType> GuardType;
std::vector<std::string> _confFiles;
std::vector<std::string> _modulesConfigFiles;
std::string _initConfigFile;
Config _config;
LockType _configLock;