-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigManager.h
59 lines (43 loc) · 1.68 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// Created by Balajanovski on 2/12/2017.
//
#ifndef LANGTON_CONFIGMANAGER_H
#define LANGTON_CONFIGMANAGER_H
#include <string>
#include <yaml-cpp/yaml.h>
#include <vector>
#include <memory>
#include "Util/TileDirection.h"
#include "Util/RGB.h"
class ConfigManager {
private:
YAML::Node m_config;
std::string m_config_path;
bool m_config_loaded = false;
void validate_field_access(const std::string& field) const;
// These are the fields of the configuration file
int m_width;
int m_height;
int m_cell_size;
int m_ant_number;
size_t m_thread_number;
RGB m_background_color;
bool m_machine_generated_colors;
std::vector<RGB> m_tile_colors;
ConfigManager() { }
public:
ConfigManager(ConfigManager const&) = delete;
void operator=(ConfigManager const&) = delete;
void load_file(const std::string& config_path);
static ConfigManager& instance();
// Getters
int get_width() const { validate_field_access("width"); return m_width; }
int get_height() const { validate_field_access("height"); return m_height; }
int get_cell_size() const { validate_field_access("cell size"); return m_cell_size; }
int get_ant_number() const { validate_field_access("ant number"); return m_ant_number; }
size_t get_thread_number() const { validate_field_access("thread number"); return m_thread_number; }
RGB get_background_color() const { validate_field_access("background color"); return m_background_color; }
bool are_colors_machine_generated() const { validate_field_access("colors machine generated"); return m_machine_generated_colors; }
std::vector<RGB> get_custom_colors() const;
};
#endif //LANGTON_CONFIGMANAGER_H