DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ExcludedEntities.cpp
Go to the documentation of this file.
6
9
10#include "logging/Logging.hpp"
11
13
14using namespace dunedaq::confmodel;
15
17
18ExcludedEntities::ExcludedEntities(const ExcludableEntitySet* root, std::vector<const ExcludableEntity*> initial_list)
19{
20 TLOG_DEBUG(2) << "construct the object from ExcludableEntity " << root->UID();
21 update(root, initial_list);
22}
23
24void
25ExcludedEntities::update(const ExcludableEntitySet* root, std::vector<const ExcludableEntity*> initial_list)
26{
27
28 m_excluded.clear();
29
30 m_initialised = true;
31
32 // get list of all root's entities-sets also test any
33 // circular dependencies between segments and entity sets
34 TestCircularDependency cd_fuse("component \'is-excluded\' status", root);
35 std::vector<const ExcludableEntitySet*> sets;
36 std::set<const ExcludableEntity*> simple_entities;
37 fill(*root, sets, simple_entities, cd_fuse);
38
39 for (auto& comp : initial_list) {
40 exclude(*comp);
41 TLOG_DEBUG(6) << comp->UID() << " is excluded in session";
42 if (const ExcludableEntitySet* rs = comp->cast<ExcludableEntitySet>()) {
44 }
45 }
46
47 for (unsigned long count = 1; true; ++count) {
48 const unsigned long num(size()); // Remember current size
49
50 TLOG_DEBUG(6) << "before auto-exclusion iteration " << count << " the number of excluded components is " << num;
51 for (const auto& set : sets) {
52 if (is_included(set)) {
53 if (set->compute_excluded_state(m_excluded)) {
54 TLOG_DEBUG(6) << "Exclude custom entity-set- " << set->UID() << " because children are excluded";
55 exclude(*set);
56 exclude_children(*set);
57 }
58 }
59 }
60
61 for (auto& en : simple_entities) {
62 if (is_included(en) && en->compute_excluded_state(m_excluded)) {
63 TLOG_DEBUG(6) << "Marking " << en->UID() << " as excluded\n";
64 exclude(*en);
65 }
66 }
67
68 if (size() == num) {
69 TLOG_DEBUG(6) << "after " << count
70 << " iteration(s) auto-exclusion algorithm found no newly excluded sets, exiting loop ...";
71 break;
72 }
73
74 unsigned int iLimit(1000);
75 if (count > iLimit) {
76 ers::error(ReadMaxAllowedIterations(ERS_HERE, iLimit));
77 break;
78 }
79 }
80}
81
82// fill data from entities sets
83void
85 std::vector<const ExcludableEntitySet*>& all_sets,
86 std::set<const ExcludableEntity*>& simple_entities,
88{
89 TLOG_DEBUG(6) << "es.UID=" << es.UID() << ", class=" << es.class_name();
90 all_sets.push_back(&es);
91 auto rptr = &es;
92 if (rptr->cast<ExcludableEntity>() == nullptr) {
93 throw(MissingConstructor(ERS_HERE, "ExcludableEntity", es.full_name()));
94 }
95 for (auto& res : es.contained_excludable_entities()) {
96 AddTestOnCircularDependency add_fuse_test(cd_fuse, res);
97 if (const ExcludableEntitySet* es2 = res->cast<ExcludableEntitySet>()) {
98 fill(*es2, all_sets, simple_entities, cd_fuse);
99 } else {
100 simple_entities.insert(res);
101 }
102 }
103}
104
105void
107{
108 TLOG_DEBUG(6) << "Excluding children of " << rs.UID();
109 for (auto& res : rs.contained_excludable_entities()) {
110 TLOG_DEBUG(6) << "Excluding child " << res->UID();
111 exclude(*res);
112 if (const auto* rs2 = res->cast<ExcludableEntitySet>()) {
113 exclude_children(*rs2);
114 }
115 }
116}
#define ERS_HERE
std::string full_name() const noexcept
const TARGET * cast() const noexcept
Casts object to different class.
const std::string & class_name() const noexcept
const std::string & UID() const noexcept
virtual std::vector< const ExcludableEntity * > contained_excludable_entities() const =0
void fill(const ExcludableEntitySet &rs, std::vector< const ExcludableEntitySet * > &all_resource_sets, std::set< const ExcludableEntity * > &simple_resources, TestCircularDependency &cd_fuse)
void exclude_children(const ExcludableEntitySet &)
void update(const ExcludableEntitySet *root, std::vector< const ExcludableEntity * > initial_list)
void exclude(const ExcludableEntity &component)
bool is_included(const ExcludableEntity *component) const
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
void error(const Issue &issue)
Definition ers.hpp:101