GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/Algorithm.cc
Date: 2025-09-03 22:39:58
Exec Total Coverage
Lines: 112 154 72.7%
Functions: 31 70 44.3%
Branches: 118 648 18.2%

Line Branch Exec Source
1 #include "Algorithm.h"
2
3 namespace iguana {
4
5 13 void Algorithm::Start()
6 {
7
1/2
✓ Branch 0 (2→3) taken 13 times.
✗ Branch 1 (2→5) not taken.
13 m_rows_only = true;
8 hipo::banklist no_banks = {};
9
1/2
✓ Branch 0 (2→3) taken 13 times.
✗ Branch 1 (2→5) not taken.
13 Start(no_banks);
10 13 }
11
12 ///////////////////////////////////////////////////////////////////////////////
13
14 template <typename OPTION_TYPE>
15 94 OPTION_TYPE Algorithm::GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path) const
16 {
17 94 CompleteOptionNodePath(key, node_path);
18 94 auto opt = GetCachedOption<OPTION_TYPE>(key);
19
2/2
✓ Branch 0 (4→5) taken 92 times.
✓ Branch 1 (4→11) taken 2 times.
94 if(!opt.has_value()) {
20
3/4
✓ Branch 0 (5→6) taken 91 times.
✓ Branch 1 (5→44) taken 1 times.
✓ Branch 2 (6→7) taken 52 times.
✗ Branch 3 (6→34) not taken.
144 opt = m_yaml_config->GetScalar<OPTION_TYPE>(node_path);
21 }
22
2/2
✓ Branch 0 (11→12) taken 2 times.
✓ Branch 1 (11→25) taken 91 times.
93 if(!opt.has_value()) {
23
3/6
✓ Branch 0 (16→17) taken 2 times.
✗ Branch 1 (16→36) not taken.
✓ Branch 2 (17→18) taken 1 times.
✓ Branch 3 (17→20) taken 1 times.
✗ Branch 4 (36→37) not taken.
✗ Branch 5 (36→39) not taken.
2 m_log->Error("Failed to `GetOptionScalar` for key {:?}", key);
24
1/2
✓ Branch 0 (23→24) taken 2 times.
✗ Branch 1 (23→42) not taken.
2 throw std::runtime_error("config file parsing issue");
25 }
26
2/4
✓ Branch 0 (25→26) taken 91 times.
✗ Branch 1 (25→44) not taken.
✓ Branch 2 (26→27) taken 54 times.
✗ Branch 3 (26→28) not taken.
91 PrintOptionValue(key, opt.value());
27 91 return opt.value();
28 }
29 template int Algorithm::GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path) const;
30 template double Algorithm::GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path) const;
31 template std::string Algorithm::GetOptionScalar(std::string const& key, YAMLReader::node_path_t node_path) const;
32
33 ///////////////////////////////////////////////////////////////////////////////
34
35 template <typename OPTION_TYPE>
36 41 std::vector<OPTION_TYPE> Algorithm::GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path) const
37 {
38 41 CompleteOptionNodePath(key, node_path);
39 41 auto opt = GetCachedOption<std::vector<OPTION_TYPE>>(key);
40
2/2
✓ Branch 0 (4→5) taken 31 times.
✓ Branch 1 (4→13) taken 10 times.
41 if(!opt.has_value()) {
41
2/4
✓ Branch 0 (5→6) taken 31 times.
✗ Branch 1 (5→45) not taken.
✓ Branch 2 (6→7) taken 31 times.
✗ Branch 3 (6→35) not taken.
62 opt = m_yaml_config->GetVector<OPTION_TYPE>(node_path);
42 }
43
2/2
✓ Branch 0 (13→14) taken 4 times.
✓ Branch 1 (13→27) taken 37 times.
41 if(!opt.has_value()) {
44
3/6
✓ Branch 0 (18→19) taken 4 times.
✗ Branch 1 (18→37) not taken.
✓ Branch 2 (19→20) taken 2 times.
✓ Branch 3 (19→22) taken 2 times.
✗ Branch 4 (37→38) not taken.
✗ Branch 5 (37→40) not taken.
4 m_log->Error("Failed to `GetOptionVector` for key {:?}", key);
45
1/2
✓ Branch 0 (25→26) taken 4 times.
✗ Branch 1 (25→43) not taken.
4 throw std::runtime_error("config file parsing issue");
46 }
47
2/6
✓ Branch 0 (27→28) taken 37 times.
✗ Branch 1 (27→45) not taken.
✓ Branch 2 (28→29) taken 37 times.
✗ Branch 3 (28→30) not taken.
✗ Branch 4 (45→46) not taken.
✗ Branch 5 (45→48) not taken.
41 PrintOptionValue(key, opt.value());
48
1/2
✓ Branch 0 (29→31) taken 37 times.
✗ Branch 1 (29→45) not taken.
74 return opt.value();
49 }
50 template std::vector<int> Algorithm::GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path) const;
51 template std::vector<double> Algorithm::GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path) const;
52 template std::vector<std::string> Algorithm::GetOptionVector(std::string const& key, YAMLReader::node_path_t node_path) const;
53
54 ///////////////////////////////////////////////////////////////////////////////
55
56 template <typename OPTION_TYPE>
57 17 std::set<OPTION_TYPE> Algorithm::GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path) const
58 {
59
2/2
✓ Branch 0 (3→4) taken 15 times.
✓ Branch 1 (3→11) taken 2 times.
17 auto val_vec = GetOptionVector<OPTION_TYPE>(key, node_path);
60 std::set<OPTION_TYPE> val_set;
61 std::copy(val_vec.begin(), val_vec.end(), std::inserter(val_set, val_set.end()));
62 15 return val_set;
63 1 }
64 template std::set<int> Algorithm::GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path) const;
65 template std::set<double> Algorithm::GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path) const;
66 template std::set<std::string> Algorithm::GetOptionSet(std::string const& key, YAMLReader::node_path_t node_path) const;
67
68 ///////////////////////////////////////////////////////////////////////////////
69
70 110 void Algorithm::SetName(std::string_view name)
71 {
72 110 Object::SetName(name);
73
1/2
✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→14) taken 110 times.
110 if(m_yaml_config)
74 m_yaml_config->SetName("config|" + m_name);
75 110 }
76
77 ///////////////////////////////////////////////////////////////////////////////
78
79 42 std::unique_ptr<YAMLReader> const& Algorithm::GetConfig() const
80 {
81 42 return m_yaml_config;
82 }
83
84 ///////////////////////////////////////////////////////////////////////////////
85
86 void Algorithm::SetConfig(std::unique_ptr<YAMLReader>&& yaml_config)
87 {
88 m_yaml_config = std::move(yaml_config);
89 }
90
91 ///////////////////////////////////////////////////////////////////////////////
92
93
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 6 times.
6 void Algorithm::SetConfigFile(std::string const& name)
94 {
95
4/8
✓ Branch 0 (5→6) taken 6 times.
✗ Branch 1 (5→30) not taken.
✓ Branch 2 (6→7) taken 6 times.
✗ Branch 3 (6→24) not taken.
✓ Branch 4 (18→19) taken 3 times.
✓ Branch 5 (18→21) taken 3 times.
✗ Branch 6 (30→31) not taken.
✗ Branch 7 (30→33) not taken.
12 o_user_config_file = SetOption("config_file", name);
96 6 }
97
98 ///////////////////////////////////////////////////////////////////////////////
99
100
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 6 times.
6 void Algorithm::SetConfigDirectory(std::string const& name)
101 {
102
3/8
✓ Branch 0 (5→6) taken 6 times.
✗ Branch 1 (5→30) not taken.
✓ Branch 2 (6→7) taken 6 times.
✗ Branch 3 (6→24) not taken.
✗ Branch 4 (18→19) not taken.
✓ Branch 5 (18→21) taken 6 times.
✗ Branch 6 (30→31) not taken.
✗ Branch 7 (30→33) not taken.
12 o_user_config_dir = SetOption("config_dir", name);
103 6 }
104
105 ///////////////////////////////////////////////////////////////////////////////
106
107
1/2
✓ Branch 0 (2→3) taken 42 times.
✗ Branch 1 (2→48) not taken.
42 void Algorithm::ParseYAMLConfig()
108 {
109
110 // start YAMLReader instance, if not yet started
111
1/2
✓ Branch 0 (2→3) taken 42 times.
✗ Branch 1 (2→48) not taken.
42 if(!m_yaml_config) {
112 // set config files and directories specified by `::SetConfigFile`, `::SetConfigDirectory`, etc.
113
2/4
✓ Branch 0 (4→5) taken 42 times.
✗ Branch 1 (4→86) not taken.
✓ Branch 2 (5→6) taken 42 times.
✗ Branch 3 (5→84) not taken.
42 o_user_config_file = GetCachedOption<std::string>("config_file").value_or("");
114
2/4
✓ Branch 0 (19→20) taken 42 times.
✗ Branch 1 (19→94) not taken.
✓ Branch 2 (20→21) taken 42 times.
✗ Branch 3 (20→92) not taken.
84 o_user_config_dir = GetCachedOption<std::string>("config_dir").value_or("");
115 42 m_log->Debug("Instantiating `YAMLReader`");
116
1/2
✓ Branch 0 (35→36) taken 42 times.
✗ Branch 1 (35→100) not taken.
84 m_yaml_config = std::make_unique<YAMLReader>("config|" + m_name);
117 42 m_yaml_config->SetLogLevel(m_log->GetLevel()); // synchronize log levels
118 42 m_yaml_config->AddDirectory(o_user_config_dir);
119 42 m_yaml_config->AddFile(m_default_config_file);
120 42 m_yaml_config->AddFile(o_user_config_file);
121 }
122 else
123 m_log->Debug("`YAMLReader` already instantiated for this algorithm; using that");
124
125 // parse the files
126 42 m_yaml_config->LoadFiles();
127
128 // if "log" was not set by `SetOption` (i.e., not in `m_option_cache`)
129 // - NB: not using `GetCachedOption<T>` here, since `T` can be a few different types for key=='log'
130
2/2
✓ Branch 0 (60→61) taken 23 times.
✓ Branch 1 (60→83) taken 19 times.
84 if(m_option_cache.find("log") == m_option_cache.end()) {
131 // check if 'log' is set in the YAML node for this algorithm
132
6/10
✓ Branch 0 (65→66) taken 23 times.
✗ Branch 1 (65→108) not taken.
✓ Branch 2 (66→67) taken 23 times.
✗ Branch 3 (66→106) not taken.
✓ Branch 4 (69→70) taken 46 times.
✓ Branch 5 (69→72) taken 23 times.
✓ Branch 6 (72→73) taken 3 times.
✓ Branch 7 (72→81) taken 20 times.
✗ Branch 8 (109→110) not taken.
✗ Branch 9 (109→112) not taken.
69 auto log_level_from_yaml = m_yaml_config->GetScalar<std::string>({m_class_name, "log"});
133
2/2
✓ Branch 0 (72→73) taken 3 times.
✓ Branch 1 (72→81) taken 20 times.
23 if(log_level_from_yaml) {
134
1/2
✓ Branch 0 (75→76) taken 3 times.
✗ Branch 1 (75→118) not taken.
3 m_log->SetLevel(log_level_from_yaml.value());
135
2/4
✓ Branch 0 (76→77) taken 3 times.
✗ Branch 1 (76→78) not taken.
✓ Branch 2 (80→81) taken 3 times.
✗ Branch 3 (80→118) not taken.
6 m_yaml_config->SetLogLevel(log_level_from_yaml.value());
136 }
137 }
138
0/2
✗ Branch 0 (114→115) not taken.
✗ Branch 1 (114→117) not taken.
42 }
139
140 ///////////////////////////////////////////////////////////////////////////////
141
142 160 hipo::banklist::size_type Algorithm::GetBankIndex(hipo::banklist& banks, std::string const& bank_name) const
143 {
144
2/2
✓ Branch 0 (2→3) taken 135 times.
✓ Branch 1 (2→15) taken 25 times.
160 if(m_rows_only)
145 return 0;
146 try {
147
1/2
✓ Branch 0 (3→4) taken 135 times.
✗ Branch 1 (3→22) not taken.
135 auto idx = hipo::getBanklistIndex(banks, bank_name);
148
3/6
✓ Branch 0 (8→9) taken 135 times.
✗ Branch 1 (8→16) not taken.
✓ Branch 2 (9→10) taken 72 times.
✓ Branch 3 (9→12) taken 63 times.
✗ Branch 4 (16→17) not taken.
✗ Branch 5 (16→19) not taken.
135 m_log->Debug("cached index of bank '{}' is {}", bank_name, idx);
149 135 return idx;
150 } catch(std::runtime_error const& ex) {
151 m_log->Error("required input bank '{}' not found; cannot `Start` algorithm '{}'", bank_name, m_class_name);
152 auto creators = AlgorithmFactory::QueryNewBank(bank_name);
153 if(creators)
154 m_log->Error(" -> this bank is created by algorithm(s) [{}]; please `Start` ONE of them BEFORE this algorithm", fmt::join(creators.value(), ", "));
155 throw std::runtime_error("cannot cache bank index");
156 }
157 }
158
159 ///////////////////////////////////////////////////////////////////////////////
160
161
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 27 times.
27 void Algorithm::PrintOptionValue(std::string const& key, int const& val, Logger::Level const level, std::string_view prefix) const
162 {
163
4/8
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 27 times.
✓ Branch 2 (5→6) taken 27 times.
✗ Branch 3 (5→12) not taken.
✓ Branch 4 (6→7) taken 25 times.
✓ Branch 5 (6→9) taken 2 times.
✗ Branch 6 (12→13) not taken.
✗ Branch 7 (12→15) not taken.
54 m_log->Print(level, "{}: {:>20} = {} [int]", prefix, key, val);
164 27 }
165
166
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 10 times.
10 void Algorithm::PrintOptionValue(std::string const& key, double const& val, Logger::Level const level, std::string_view prefix) const
167 {
168
3/8
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 10 times.
✓ Branch 2 (5→6) taken 10 times.
✗ Branch 3 (5→12) not taken.
✓ Branch 4 (6→7) taken 10 times.
✗ Branch 5 (6→9) not taken.
✗ Branch 6 (12→13) not taken.
✗ Branch 7 (12→15) not taken.
20 m_log->Print(level, "{}: {:>20} = {} [double]", prefix, key, val);
169 10 }
170
171
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 54 times.
54 void Algorithm::PrintOptionValue(std::string const& key, std::string const& val, Logger::Level const level, std::string_view prefix) const
172 {
173
5/10
✓ Branch 0 (9→10) taken 54 times.
✗ Branch 1 (9→21) not taken.
✓ Branch 2 (10→11) taken 50 times.
✓ Branch 3 (10→13) taken 4 times.
✓ Branch 4 (15→16) taken 36 times.
✓ Branch 5 (15→18) taken 18 times.
✗ Branch 6 (21→22) not taken.
✗ Branch 7 (21→24) not taken.
✗ Branch 8 (27→28) not taken.
✗ Branch 9 (27→30) not taken.
108 m_log->Print(level, "{}: {:>20} = {:?} [string]", prefix, key, val);
174 54 }
175
176
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 16 times.
16 void Algorithm::PrintOptionValue(std::string const& key, std::vector<int> const& val, Logger::Level const level, std::string_view prefix) const
177 {
178
2/6
✓ Branch 0 (6→7) taken 16 times.
✗ Branch 1 (6→13) not taken.
✓ Branch 2 (7→8) taken 16 times.
✗ Branch 3 (7→10) not taken.
✗ Branch 4 (13→14) not taken.
✗ Branch 5 (13→16) not taken.
16 m_log->Print(level, "{}: {:>20} = ({}) [std::vector<int>]", prefix, key, fmt::join(val, ", "));
179 16 }
180
181
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 16 times.
16 void Algorithm::PrintOptionValue(std::string const& key, std::vector<double> const& val, Logger::Level const level, std::string_view prefix) const
182 {
183
2/6
✓ Branch 0 (6→7) taken 16 times.
✗ Branch 1 (6→13) not taken.
✓ Branch 2 (7→8) taken 16 times.
✗ Branch 3 (7→10) not taken.
✗ Branch 4 (13→14) not taken.
✗ Branch 5 (13→16) not taken.
16 m_log->Print(level, "{}: {:>20} = ({}) [std::vector<double>]", prefix, key, fmt::join(val, ", "));
184 16 }
185
186 5 void Algorithm::PrintOptionValue(std::string const& key, std::vector<std::string> const& val, Logger::Level const level, std::string_view prefix) const
187 {
188 std::vector<std::string> val_quoted;
189
2/2
✓ Branch 0 (13→3) taken 12 times.
✓ Branch 1 (13→14) taken 5 times.
17 for(auto const& s : val)
190
1/2
✓ Branch 0 (6→7) taken 12 times.
✗ Branch 1 (6→26) not taken.
24 val_quoted.push_back(fmt::format("{:?}", s));
191
2/6
✓ Branch 0 (18→19) taken 5 times.
✗ Branch 1 (18→32) not taken.
✓ Branch 2 (19→20) taken 5 times.
✗ Branch 3 (19→22) not taken.
✗ Branch 4 (32→33) not taken.
✗ Branch 5 (32→35) not taken.
5 m_log->Print(level, "{}: {:>20} = ({}) [std::vector<string>]", prefix, key, fmt::join(val_quoted, ", "));
192 5 }
193
194 ///////////////////////////////////////////////////////////////////////////////
195
196 125900 hipo::bank& Algorithm::GetBank(hipo::banklist& banks, hipo::banklist::size_type const idx, std::string const& expected_bank_name) const
197 {
198
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→5) taken 125900 times.
125900 if(m_rows_only) {
199 m_log->Error("algorithm is in 'rows only' mode; cannot call `Run` since banks are not cached; use action function(s) instead");
200 }
201 else {
202 try {
203
1/2
✓ Branch 0 (5→6) taken 125900 times.
✗ Branch 1 (5→56) not taken.
125900 auto& result = banks.at(idx);
204
4/6
✓ Branch 0 (6→7) taken 112600 times.
✓ Branch 1 (6→19) taken 13300 times.
✗ Branch 2 (11→12) not taken.
✓ Branch 3 (11→13) taken 112600 times.
✗ Branch 4 (19→20) not taken.
✓ Branch 5 (19→40) taken 125900 times.
351100 if(!expected_bank_name.empty() && result.getSchema().getName() != expected_bank_name)
205 m_log->Error("expected input bank '{}' at index={}; got bank named '{}'", expected_bank_name, idx, result.getSchema().getName());
206 else
207 125900 return result;
208 }
209 catch(std::out_of_range const& o) {
210 m_log->Error("required input bank '{}' not found; cannot `Run` algorithm '{}'", expected_bank_name, m_class_name);
211 auto creators = AlgorithmFactory::QueryNewBank(expected_bank_name);
212 if(creators)
213 m_log->Error(" -> this bank is created by algorithm(s) [{}]; please `Run` ONE of them BEFORE this algorithm", fmt::join(creators.value(), ", "));
214 }
215 }
216 throw std::runtime_error("GetBank failed");
217 }
218
219 ///////////////////////////////////////////////////////////////////////////////
220
221 26 hipo::schema Algorithm::CreateBank(
222 hipo::banklist& banks,
223 hipo::banklist::size_type& bank_idx,
224 std::string const& bank_name) const noexcept(false)
225 {
226 // loop over bank definitions
227 // NOTE: `BANK_DEFS` is generated at build-time using `src/iguana/bankdefs/iguana.json`
228
1/2
✓ Branch 0 (64→3) taken 85 times.
✗ Branch 1 (64→65) not taken.
85 for(auto const& bank_def : BANK_DEFS) {
229
2/2
✓ Branch 0 (3→4) taken 26 times.
✓ Branch 1 (3→63) taken 59 times.
85 if(bank_def.name == bank_name) {
230 // make sure the new bank is in REGISTER_IGUANA_ALGORITHM
231
1/2
✗ Branch 0 (8→9) not taken.
✓ Branch 1 (8→30) taken 26 times.
52 if(!AlgorithmFactory::QueryNewBank(bank_name)) {
232 m_log->Error("{:?} creates bank {:?}, which is not registered; new banks must be included in `REGISTER_IGUANA_ALGORITHM` arguments", m_class_name, bank_name);
233 throw std::runtime_error("CreateBank failed");
234 }
235 // create the schema format string
236 std::vector<std::string> schema_def;
237
2/2
✓ Branch 0 (48→31) taken 263 times.
✓ Branch 1 (48→49) taken 26 times.
289 for(auto const& entry : bank_def.entries)
238
1/2
✓ Branch 0 (31→32) taken 263 times.
✗ Branch 1 (31→112) not taken.
526 schema_def.push_back(entry.name + "/" + entry.type);
239 26 auto format_string = fmt::format("{}", fmt::join(schema_def, ","));
240 // create the new bank schema
241
1/2
✓ Branch 0 (50→51) taken 26 times.
✗ Branch 1 (50→106) not taken.
26 hipo::schema bank_schema(bank_name.c_str(), bank_def.group, bank_def.item);
242
1/2
✓ Branch 0 (51→52) taken 26 times.
✗ Branch 1 (51→104) not taken.
26 bank_schema.parse(format_string);
243 // create the new bank
244
1/2
✓ Branch 0 (52→53) taken 26 times.
✗ Branch 1 (52→104) not taken.
52 banks.push_back({bank_schema});
245
2/4
✓ Branch 0 (55→56) taken 26 times.
✗ Branch 1 (55→104) not taken.
✗ Branch 2 (56→57) not taken.
✓ Branch 3 (56→59) taken 26 times.
26 bank_idx = GetBankIndex(banks, bank_name);
246 26 return bank_schema;
247 26 }
248 }
249 throw std::runtime_error(fmt::format("bank {:?} not found in 'BankDefs.h'; is this bank defined in src/iguana/bankdefs/iguana.json ?", bank_name));
250 }
251
252 ///////////////////////////////////////////////////////////////////////////////
253
254 void Algorithm::ShowBanks(hipo::banklist& banks, std::string_view message, Logger::Level const level) const
255 {
256 if(m_log->GetLevel() <= level) {
257 if(!message.empty())
258 m_log->Print(level, message);
259 for(auto& bank : banks)
260 bank.show();
261 }
262 }
263
264 ///////////////////////////////////////////////////////////////////////////////
265
266 76984 void Algorithm::ShowBank(hipo::bank& bank, std::string_view message, Logger::Level const level) const
267 {
268
1/2
✗ Branch 0 (3→4) not taken.
✓ Branch 1 (3→7) taken 76984 times.
76984 if(m_log->GetLevel() <= level) {
269 if(!message.empty())
270 m_log->Print(level, message);
271 bank.show();
272 }
273 76984 }
274
275 ///////////////////////////////////////////////////////////////////////////////
276
277 template <typename OPTION_TYPE>
278 219 std::optional<OPTION_TYPE> Algorithm::GetCachedOption(std::string const& key) const
279 {
280
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 219 times.
219 if(key == "")
281 return {};
282
2/2
✓ Branch 0 (7→8) taken 24 times.
✓ Branch 1 (7→12) taken 195 times.
219 if(auto it{m_option_cache.find(key)}; it != m_option_cache.end()) {
283 try { // get the expected type
284 return std::get<OPTION_TYPE>(it->second);
285 }
286 catch(std::bad_variant_access const& ex) {
287 auto printer = [&key, this](auto const& v) {
288 m_log->Error("wrong type used in SetOption call for option {:?}; using its default value instead", key);
289 PrintOptionValue(key, v, Logger::Level::error, " USER");
290 if(m_log->GetLevel() > Logger::Level::debug)
291 m_log->Error("to see the actual option values used (and their types), set the log level to 'debug' or lower");
292 };
293 std::visit(printer, it->second);
294 }
295 }
296 195 return {};
297 }
298 template std::optional<int> Algorithm::GetCachedOption(std::string const& key) const;
299 template std::optional<double> Algorithm::GetCachedOption(std::string const& key) const;
300 template std::optional<std::string> Algorithm::GetCachedOption(std::string const& key) const;
301 template std::optional<std::vector<int>> Algorithm::GetCachedOption(std::string const& key) const;
302 template std::optional<std::vector<double>> Algorithm::GetCachedOption(std::string const& key) const;
303 template std::optional<std::vector<std::string>> Algorithm::GetCachedOption(std::string const& key) const;
304
305 ///////////////////////////////////////////////////////////////////////////////
306
307
2/2
✓ Branch 0 (2→3) taken 66 times.
✓ Branch 1 (2→9) taken 69 times.
135 void Algorithm::CompleteOptionNodePath(std::string const& key, YAMLReader::node_path_t& node_path) const
308 {
309
2/2
✓ Branch 0 (2→3) taken 66 times.
✓ Branch 1 (2→9) taken 69 times.
135 if(node_path.empty())
310 66 node_path.push_front(key);
311 135 node_path.push_front(m_class_name);
312 135 }
313 }
314