MoCSI API Reference
Loading...
Searching...
No Matches
SetupRunner.h
Go to the documentation of this file.
1#ifndef TPM_SRC_SETUP_RUNNER
2#define TPM_SRC_SETUP_RUNNER
3
4#include <memory>
5#include <string>
6#include <valarray>
7
8#include "ChainManager.h"
10#include "GenericSubmodule.h"
11
18template <typename T>
19bool runSetup(std::vector<std::shared_ptr<GenericManagingModule<T>>> all_modules,
20 std::vector<std::shared_ptr<GenericSubmodule<T>>> all_submodules,
21 std::unordered_set<std::string> loaded_managing_modules)
22{
23 std::unordered_set<std::string> loaded_submodules{
25
26 for (const auto& module : all_modules)
27 {
28 std::string module_name{module->getNameLocal()};
30 {
31 module->setup(all_submodules);
32 }
33 }
34
35 // Since layering of submodules is allowed, all submodules also need the complete submodule list
36 for (const auto& submodule : all_submodules)
37 {
38 std::string submodule_name{submodule->getNameLocal()};
40 {
42 }
43 }
44
45 return true;
46}
47
59template <typename T>
60std::unordered_set<std::string> getLoadedSubmodules(
61 std::vector<std::shared_ptr<GenericManagingModule<T>>> all_modules,
62 std::vector<std::shared_ptr<GenericSubmodule<T>>> all_submodules,
63 std::unordered_set<std::string> loaded_managing_modules)
64{
65 std::unordered_set<std::string> unique_submodule_names_set;
66
67 for (auto const& module_pointer : all_modules)
68 {
69 std::string module_name{module_pointer->getNameLocal()};
71 {
72 for (auto const& submodule_name : module_pointer->getSubmoduleList())
73 {
75 }
76 }
77 }
78
79 std::vector<std::string> last_added_submodules(unique_submodule_names_set.begin(),
81
82 // Check iteratively the sub-submodules to complete the loaded submodules list.
83 while (!last_added_submodules.empty())
84 {
85 std::vector<std::string> newly_added;
87 {
88 std::string submodule_name{submodule_pointer->getNameLocal()};
90 {
91 for (auto& submodule_name : submodule_pointer->getSubmoduleList())
92 {
94 {
95 newly_added.push_back(submodule_name);
96 }
97 }
98 }
99 }
101 }
102
104}
105
106#endif
std::unordered_set< std::string > getLoadedSubmodules(std::vector< std::shared_ptr< GenericManagingModule< T > > > all_modules, std::vector< std::shared_ptr< GenericSubmodule< T > > > all_submodules, std::unordered_set< std::string > loaded_managing_modules)
Get the loaded submodules names. These are all the models, that are either requested by a loaded mana...
Definition SetupRunner.h:60
bool runSetup(std::vector< std::shared_ptr< GenericManagingModule< T > > > all_modules, std::vector< std::shared_ptr< GenericSubmodule< T > > > all_submodules, std::unordered_set< std::string > loaded_managing_modules)
Function that runs the setup-functions in each module and submodule. This is a bit of a work-around a...
Definition SetupRunner.h:19
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37