ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
manager.cpp
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup daq_config
4 * @copyright (c) Copyright ESO 2022
5 * All Rights Reserved
6 * ESO (eso.org) is an Intergovernmental Organisation, and therefore special legal conditions apply.
7 *
8 * @brief daq::config::Manager and associated types.
9 */
11
12#include <ostream>
13
14#include <boost/algorithm/string/join.hpp>
15
16namespace daq::config {
17
18std::ostream& operator<<(std::ostream& os, Origin origin) {
19 switch (origin) {
20 case Origin::Runtime:
21 os << "Runtime";
22 break;
24 os << "CommandLine";
25 break;
27 os << "Configuration";
28 break;
30 os << "EnvironmentVariable";
31 break;
32 case Origin::Default:
33 os << "Default";
34 break;
35 default:
36 os << "Unknown";
37 break;
38 };
39 return os;
40}
41
42
43std::ostream& operator<<(std::ostream& os, OriginInfo const& origin) {
44 os << "origin: " << origin.origin << ", details: " << origin.description;
45 return os;
46}
47
48std::optional<std::reference_wrapper<elt::configng::CiiConfigInstanceNode const>>
49GetParam(std::string const& query, elt::configng::CiiConfigInstanceNode const& node) {
50 if (query.empty()) {
51 // A search in the form `/node/` was made which has a trailing slash
52 return {};
53 }
54 auto pos = query.find('/');
55 if (pos == std::string::npos) {
56 // last node
57 if (node.Has(query)) {
58 return std::cref(node[query]);
59 }
60 return {};
61 }
62 auto next = query.substr(0, pos);
63 auto next_query = query.substr(pos + 1, std::string::npos);
64 if (!node.Has(next)) {
65 return {};
66 }
67 return GetParam(next_query, node[next]);
68}
69
70} // namespace daq::config
daq::config::Manager and associated types.
std::string description
May include additional information like which configuration file was used.
Definition: manager.hpp:134
Origin
Configuration origins in descending priority.
Definition: manager.hpp:39
@ Configuration
Configuration file.
@ Default
Built-in default value.
@ Runtime
Runtime change via e.g.
@ CommandLine
Command line argument.
@ EnvironmentVariable
Environment variable.
std::optional< std::reference_wrapper< elt::configng::CiiConfigInstanceNode const > > GetParam(std::string const &query, elt::configng::CiiConfigInstanceNode const &node)
Performs lookup of parameters in the form root/node/leaf relative to the provided node.
Definition: manager.cpp:49
std::ostream & operator<<(std::ostream &os, Origin origin)
Format Origin.
Definition: manager.cpp:18
Mutable metadata about a configuration attribute that describes where a value comes from.
Definition: manager.hpp:129