My Project
PropertyTree.hpp
1 /*
2  Copyright 2019 SINTEF Digital, Mathematics and Cybernetics.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef OPM_PROPERTYTREE_HEADER_INCLUDED
21 #define OPM_PROPERTYTREE_HEADER_INCLUDED
22 
23 #include <iosfwd>
24 #include <memory>
25 #include <optional>
26 
27 namespace boost {
28 namespace property_tree {
29  template<class T1, class T2, class T3> class basic_ptree;
31 }
32 }
33 
34 namespace Opm
35 {
36 
37 class PropertyTree {
38 public:
39  PropertyTree();
40  PropertyTree(const std::string& jsonFile);
41  PropertyTree(const PropertyTree& tree);
42  ~PropertyTree();
43 
44  template<class T>
45  void put(const std::string& key, const T& data);
46 
47  template<class T>
48  T get(const std::string& key) const;
49 
50  template<class T>
51  T get(const std::string& key, const T& defValue) const;
52 
53  PropertyTree get_child(const std::string& key) const;
54 
55  std::optional<PropertyTree> get_child_optional(const std::string& key) const;
56 
57  PropertyTree& operator=(const PropertyTree& tree);
58 
59  void write_json(std::ostream& os, bool pretty) const;
60 
61 protected:
63 
64  std::unique_ptr<boost::property_tree::ptree> tree_;
65 };
66 
67 
68 } // namespace Opm
69 
70 #endif // OPM_PROPERTYTREE_HEADER_INCLUDED
Definition: PropertyTree.hpp:37
Definition: PropertyTree.hpp:29
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:26