Iguana 0.0.0
Implementation Guardian of Analysis Algorithms
Loading...
Searching...
No Matches
YAMLReader.h
1#pragma once
2
3#include <optional>
4#include <variant>
5#include <vector>
6
7#include <yaml-cpp/yaml.h>
8
9#include "ConfigFileReader.h"
10
11namespace iguana {
12
15 {
16
17 public:
18
20 using node_finder_t = std::function<YAML::Node(const YAML::Node)>;
21
25 using node_id_t = std::variant<std::string, node_finder_t>;
26
28 using node_path_t = std::deque<node_id_t>;
29
31 YAMLReader(std::string_view name = "config")
32 : ConfigFileReader(name)
33 {}
34 ~YAMLReader() {}
35
37 void LoadFiles();
38
42 template <typename SCALAR>
43 std::optional<SCALAR> GetScalar(YAML::Node node);
44
48 template <typename SCALAR>
49 std::optional<SCALAR> GetScalar(node_path_t node_path);
50
54 template <typename SCALAR>
55 std::optional<std::vector<SCALAR>> GetVector(YAML::Node node);
56
60 template <typename SCALAR>
61 std::optional<std::vector<SCALAR>> GetVector(node_path_t node_path);
62
68 template <typename SCALAR>
69 node_finder_t InRange(std::string const& key, SCALAR val);
70
71 private:
72
77 YAML::Node FindNode(YAML::Node node, node_path_t node_path);
78
80 std::deque<std::pair<YAML::Node, std::string>> m_configs;
81 };
82}
Configuration file manager.
A YAMLReader based on yaml-cpp.
Definition YAMLReader.h:15
std::optional< SCALAR > GetScalar(node_path_t node_path)
node_finder_t InRange(std::string const &key, SCALAR val)
std::deque< node_id_t > node_path_t
Representation of a path of YAML::Nodes in a YAML::Node tree, e.g., in a YAML file.
Definition YAMLReader.h:28
std::variant< std::string, node_finder_t > node_id_t
Definition YAMLReader.h:25
void LoadFiles()
Parse the YAML files added by ConfigFileReader::AddFile
std::optional< std::vector< SCALAR > > GetVector(YAML::Node node)
std::optional< std::vector< SCALAR > > GetVector(node_path_t node_path)
std::function< YAML::Node(const YAML::Node)> node_finder_t
A function f : Node A -> Node B which searches YAML::Node A for a specific YAML::Node B,...
Definition YAMLReader.h:20
std::optional< SCALAR > GetScalar(YAML::Node node)
YAMLReader(std::string_view name="config")
Definition YAMLReader.h:31
General, top-level namespace for algorithms and infrastructure. For algorithms and bindings,...
Definition Algorithm.h:14