db2081579bfdad15ca234dfcfc438ca75596505a
[vlp.git] / src / global / vlp / config.h
1 #ifndef __VLP_CONFIG_H
2 #define __VLP_CONFIG_H
3
4 /**
5  * 
6  * @author Rafał Długołęcki
7  */
8
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <vector>
13 #include <string>
14
15 #include <libconfig.h>
16
17 namespace loglan {
18 namespace vlp {
19
20 enum ConnectionType {
21         EXPLICIT = 1,
22         REGISTER = 2
23 };
24
25 /**
26  * Common config class used for handling configuration file I/O
27  */
28 class Config
29 {
30 private:
31         config_t cfg;
32         config_setting_t *setting;
33
34         FILE * file;
35
36 public:
37         Config();
38         ~Config();
39
40         bool load(const char * configFilePath);
41         bool save(const char * configFilePath);
42
43         int getNodeNumber();
44         void setNodeNumber(int nodeNumber);
45
46         std::vector<std::string> getHosts();
47         void setHosts(std::vector<std::string> hosts);
48
49         ConnectionType getConnectionType();
50         void setConnectionType(ConnectionType type);
51
52         const char * getProgramDir();
53         void setProgramDir(const char * programDir);
54 };
55
56 }
57 }
58
59 #endif /* __VLP_CONFIG_H */