-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig_manager.h
More file actions
32 lines (22 loc) · 792 Bytes
/
config_manager.h
File metadata and controls
32 lines (22 loc) · 792 Bytes
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
// class config manager
// singleton
#pragma once
#include <map>
typedef std::map<std::string, float> config_map;
class config_manager
{
public:
//get the instance
static config_manager* inst();
static void load(const std::string& filepath) {inst()->load_config(filepath); }
static float get(const std::string& key) { return inst()->value(key); }
static int get_int(const std::string& key) { return static_cast<int>(inst()->value(key)); }
static bool get_bool(const std::string& key) { if (inst()->value(key) == 0) return false; else return true; }
void load_config(const std::string& filepath);
const config_map config() const {return config_;}
const float value(const std::string& key);
private:
config_manager() {}
virtual ~config_manager() {}
config_map config_;
};