GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/AlgorithmFactory.cc
Date: 2025-09-03 22:39:58
Exec Total Coverage
Lines: 13 15 86.7%
Functions: 3 3 100.0%
Branches: 6 12 50.0%

Line Branch Exec Source
1 #include "Algorithm.h"
2
3 namespace iguana {
4
5 std::unordered_map<std::string, AlgorithmFactory::algo_creator_t> AlgorithmFactory::s_creators;
6 std::unordered_map<std::string, std::vector<std::string>> AlgorithmFactory::s_created_banks;
7
8 852 bool AlgorithmFactory::Register(std::string const& name, algo_creator_t creator, std::vector<std::string> const new_banks) noexcept
9 {
10
1/2
✓ Branch 0 (5→6) taken 852 times.
✗ Branch 1 (5→23) not taken.
852 if(auto it = s_creators.find(name); it == s_creators.end()) {
11 1704 s_creators.insert({name, creator});
12
2/2
✓ Branch 0 (22→10) taken 259 times.
✓ Branch 1 (22→23) taken 852 times.
1111 for(auto const& new_bank : new_banks) {
13
1/2
✓ Branch 0 (13→14) taken 259 times.
✗ Branch 1 (13→19) not taken.
259 if(auto it = s_created_banks.find(new_bank); it == s_created_banks.end())
14 518 s_created_banks.insert({new_bank, {}});
15 259 s_created_banks.at(new_bank).push_back(name);
16 }
17 return true;
18 }
19 return false;
20 }
21
22 50 algo_t AlgorithmFactory::Create(std::string const& name)
23 {
24
1/2
✓ Branch 0 (5→6) taken 50 times.
✗ Branch 1 (5→10) not taken.
50 if(auto it = s_creators.find(name); it != s_creators.end())
25 50 return it->second();
26 throw std::runtime_error(fmt::format("AlgorithmFactory: algorithm with name {:?} does not exist", name));
27 }
28
29 26 std::optional<std::vector<std::string>> AlgorithmFactory::QueryNewBank(std::string const& bank_name) noexcept
30 {
31
1/2
✓ Branch 0 (5→6) taken 26 times.
✗ Branch 1 (5→8) not taken.
26 if(auto it = s_created_banks.find(bank_name); it != s_created_banks.end())
32 26 return it->second;
33 return {};
34 }
35 }
36