-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathPropertyTreeHelpers.h
More file actions
64 lines (54 loc) · 3.08 KB
/
PropertyTreeHelpers.h
File metadata and controls
64 lines (54 loc) · 3.08 KB
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
60
61
62
63
64
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#ifndef O2_FRAMEWORK_PROPERTYTREEHELPERS_H_
#define O2_FRAMEWORK_PROPERTYTREEHELPERS_H_
#include "Framework/ConfigParamSpec.h"
#include <boost/property_tree/ptree.hpp>
#include <boost/program_options/variables_map.hpp>
#include <functional>
namespace o2::framework
{
/// Helpers to manipulate property_trees.
struct PropertyTreeHelpers {
/// For all the options specified in @a schama, this fills
/// @a tree with the contents of @a vmap, which is populated via boost
/// program options. Any key in the @a schema will be marked as
/// "default" in the provenance ptree.
static void populateDefaults(std::vector<ConfigParamSpec> const& schema,
boost::property_tree::ptree& tree,
boost::property_tree::ptree& provenance);
/// For all the options specified in @a schama, this fills
/// @a tree with the contents of @a vmap, which is populated via boost
/// program options. Any key in the @a schema will be marked as
/// "fairmq" in the provenance ptree.
static void populate(std::vector<ConfigParamSpec> const& schema,
boost::property_tree::ptree& tree,
boost::program_options::variables_map const& vmap,
boost::property_tree::ptree& provenance);
/// For all the options specified in @a schama, this fills
/// @a tree with the contents of @a in, which is another ptree
/// e.g. populated using ConfigurationInterface.
/// Any key in the @a schema will be marked as "configuration" in the provenance ptree.
static void populate(std::vector<ConfigParamSpec> const& schema,
boost::property_tree::ptree& tree,
boost::property_tree::ptree const& in,
boost::property_tree::ptree& provenance,
std::string const& propertyLabel);
//using WalkerFunction = std::function<void(boost::property_tree::ptree const&, boost::property_tree::ptree::path_type, boost::property_tree::ptree const&)>;
using WalkerFunction = std::function<void(boost::property_tree::ptree const&, boost::property_tree::ptree::path_type, boost::property_tree::ptree const&)>;
/// Traverse the tree recursively calling @a WalkerFunction on each leaf.
static void traverse(boost::property_tree::ptree const& parent, WalkerFunction& method);
/// Merge @a source ptree into @a dest
static void merge(boost::property_tree::ptree& dest,
boost::property_tree::ptree const& source,
boost::property_tree::ptree::path_type const& mergePoint);
};
} // namespace o2::framework
#endif // O2_FRAMEWORK_PROPERTYTREEHELPERS_H_