add config getters
Stefan Schuermans

Stefan Schuermans commited on 2020-08-23 10:34:36
Showing 4 changed files, with 40 additions and 1 deletions.

... ...
@@ -10,6 +10,9 @@
10 10
 /// configuration file
11 11
 class Config {
12 12
 public:
13
+  /// map of trees
14
+  typedef std::map<boost::filesystem::path, Tree> TreeMap;
15
+
13 16
   /**
14 17
    * @brief parse configuration file
15 18
    * @param[in] configFileName name of configuation file
... ...
@@ -17,8 +20,11 @@ public:
17 20
    */
18 21
   void parseFile(std::string const &configFileName);
19 22
 
23
+  /// return trees
24
+  TreeMap const & getTrees() const;
25
+
20 26
 protected:
21
-  std::map<boost::filesystem::path, Tree> trees;
27
+  TreeMap trees;
22 28
 };
23 29
 
24 30
 #endif // #ifndef CONFIG_H
... ...
@@ -18,6 +18,18 @@ public:
18 18
    */
19 19
   void parseParams(std::string const &paramStr);
20 20
 
21
+  /// get user
22
+  User const & getUser() const;
23
+
24
+  /// get group
25
+  Group const & getGroup() const;
26
+
27
+  /// get permissions
28
+  Permissions const & getPermissions() const;
29
+
30
+  /// get root path
31
+  boost::filesystem::path const & getRoot() const;
32
+
21 33
 protected:
22 34
   User user;
23 35
   Group group;
... ...
@@ -33,6 +33,7 @@ void Config::parseFile(std::string const &configFileName) {
33 33
     if (typeStr == "tree") {
34 34
       Tree tree;
35 35
       tree.parseParams(line.substr(pos));
36
+      trees[tree.getRoot()] = tree;
36 37
       continue;
37 38
     }
38 39
     // unknown configuration line
... ...
@@ -41,3 +42,7 @@ void Config::parseFile(std::string const &configFileName) {
41 42
     throw std::runtime_error(msg.str());
42 43
   }
43 44
 }
45
+
46
+Config::TreeMap const & Config::getTrees() const {
47
+  return trees;
48
+}
... ...
@@ -55,3 +55,19 @@ void Tree::parseParams(std::string const &paramStr) {
55 55
 
56 56
   root = rootStr;
57 57
 }
58
+
59
+User const & Tree::getUser() const {
60
+  return user;
61
+}
62
+
63
+Group const & Tree::getGroup() const {
64
+  return group;
65
+}
66
+
67
+Permissions const & Tree::getPermissions() const {
68
+  return permissions;
69
+}
70
+
71
+boost::filesystem::path const & Tree::getRoot() const {
72
+  return root;
73
+}
58 74