-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigManager.h
40 lines (31 loc) · 980 Bytes
/
ConfigManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef ConfigManager_h__
#define ConfigManager_h__
#include <boost/noncopyable.hpp>
#include <boost/function.hpp>
#include "APITypes.h"
class ConfigManager
{
public:
static void setPath(const std::string& path);
static void setDefaultConfig(const FB::VariantMap& defMap);
template<typename T>
T getValue(const std::string& key) {
return configMap[key].convert_cast<T>();
}
template<typename T>
void setValue(const std::string& key, const T& val) {
configMap[key] = val;
saveConfig();
}
protected:
ConfigManager() {}
virtual ~ConfigManager() {}
void initConfigFile();
virtual void saveConfigMap(const std::string& filePath, const FB::VariantMap& map) = 0;
virtual FB::VariantMap loadConfigMap(const std::string& filePath) = 0;
void saveConfig();
void initConfig();
FB::VariantMap configMap;
static FB::VariantMap defaultConfig;
};
#endif // ConfigManager_h__