knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
PropertyTree.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_PROPERTY_TREE_H_
7 #define KNOWROB_PROPERTY_TREE_H_
8 
9 #include <list>
10 #include <map>
11 #include <memory>
12 #include <optional>
13 #include <boost/property_tree/ptree.hpp>
14 #include "knowrob/terms/Term.h"
15 #include "knowrob/DataSource.h"
16 
17 namespace knowrob {
21  class PropertyTree {
22  public:
24 
29  explicit PropertyTree(std::shared_ptr<const boost::property_tree::ptree> ptree);
30 
35  explicit PropertyTree(const std::string_view json_str);
36 
40  void init();
41 
46  auto operator->() const { return ptree_; }
47 
61  TermPtr get(std::string_view key, const TermPtr &defaultValue);
62 
68  TermPtr createKeyTerm(std::string_view key) const;
69 
73  auto begin() const { return properties_.begin(); }
74 
78  auto end() const { return properties_.end(); }
79 
83  auto &dataSources() const { return dataSources_; }
84 
88  auto ptree() const { return ptree_; }
89 
90  private:
91  std::map<std::string, TermPtr> properties_;
92  std::list<std::shared_ptr<DataSource>> dataSources_;
93  std::shared_ptr<const boost::property_tree::ptree> ptree_;
94  std::string delimiter_;
95 
102  TermPtr get_value_recursive(const boost::property_tree::ptree &node, const std::string &path);
103  };
104 }
105 
106 #endif //KNOWROB_PROPERTY_TREE_H_
auto ptree() const
Definition: PropertyTree.h:88
PropertyTree(std::shared_ptr< const boost::property_tree::ptree > ptree)
auto begin() const
Definition: PropertyTree.h:73
auto operator->() const
Definition: PropertyTree.h:46
PropertyTree(const std::string_view json_str)
TermPtr createKeyTerm(std::string_view key) const
auto & dataSources() const
Definition: PropertyTree.h:83
TermPtr get(std::string_view key, const TermPtr &defaultValue)
TermRule & string()
Definition: terms.cpp:63
std::shared_ptr< Term > TermPtr
Definition: Term.h:117