GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/AlgorithmFactory.cc
Date: 2025-01-05 09:03:17
Exec Total Coverage
Lines: 13 14 92.9%
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 628 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 taken 628 times.
✗ Branch 1 not taken.
628 if(auto it = s_creators.find(name); it == s_creators.end()) {
11 1256 s_creators.insert({name, creator});
12
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 628 times.
760 for(auto const& new_bank : new_banks) {
13
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(auto it = s_created_banks.find(new_bank); it == s_created_banks.end())
14 264 s_created_banks.insert({new_bank, {}});
15 132 s_created_banks.at(new_bank).push_back(name);
16 }
17 return true;
18 }
19 return false;
20 }
21
22 43 algo_t AlgorithmFactory::Create(std::string const& name)
23 {
24
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if(auto it = s_creators.find(name); it != s_creators.end())
25 43 return it->second();
26 throw std::runtime_error(fmt::format("AlgorithmFactory: algorithm with name {:?} does not exist", name));
27 }
28
29 15 std::optional<std::vector<std::string>> AlgorithmFactory::QueryNewBank(std::string const& bank_name) noexcept
30 {
31
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(auto it = s_created_banks.find(bank_name); it != s_created_banks.end())
32 15 return it->second;
33 return {};
34 }
35 }
36