Line data Source code
1 : //
2 : // DUNE DAQ modification notice:
3 : // This file has been modified from the original ATLAS config source for the DUNE DAQ project.
4 : // Fork baseline commit: 67a24e731 (2022-10-27).
5 : // Renamed since fork: no.
6 : //
7 :
8 : #include "conffwk/SubscriptionCriteria.hpp"
9 : #include "conffwk/DalObject.hpp"
10 :
11 : namespace dunedaq {
12 : namespace conffwk {
13 :
14 : void
15 0 : ConfigurationSubscriptionCriteria::add(const std::string& class_name)
16 : {
17 0 : m_classes_subscription.insert(class_name);
18 0 : }
19 :
20 : void
21 0 : ConfigurationSubscriptionCriteria::add(const std::string& class_name, const std::string& object_id)
22 : {
23 0 : m_objects_subscription[class_name].insert(object_id);
24 0 : }
25 :
26 : void
27 0 : ConfigurationSubscriptionCriteria::add(const DalObject& object)
28 : {
29 0 : add(object.class_name(), object.UID());
30 0 : }
31 :
32 : void
33 0 : ConfigurationSubscriptionCriteria::remove(const std::string& class_name)
34 : {
35 0 : m_classes_subscription.erase(class_name);
36 0 : }
37 :
38 : void
39 0 : ConfigurationSubscriptionCriteria::remove(const std::string& class_name, const std::string& object_id)
40 : {
41 0 : ObjectMap::iterator i = m_objects_subscription.find(class_name);
42 0 : if (i != m_objects_subscription.end())
43 : {
44 0 : i->second.erase(object_id);
45 0 : if (i->second.empty())
46 : {
47 0 : m_objects_subscription.erase(i);
48 : }
49 : }
50 0 : }
51 :
52 : void
53 0 : ConfigurationSubscriptionCriteria::remove(const DalObject& object)
54 : {
55 0 : remove(object.class_name(), object.UID());
56 0 : }
57 :
58 : std::ostream&
59 0 : operator<<(std::ostream& s, const ConfigurationSubscriptionCriteria& criteria)
60 : {
61 0 : s << "Subscription criteria:\n";
62 :
63 : // print out classes subscription
64 0 : s << " classes subscription: ";
65 :
66 0 : if (criteria.get_classes_subscription().empty())
67 : {
68 0 : s << "(null)\n";
69 : }
70 : else
71 : {
72 0 : s << std::endl;
73 0 : for (const auto& i : criteria.get_classes_subscription())
74 : {
75 0 : s << " \"" << i << "\"\n";
76 : }
77 : }
78 :
79 : // print out objects subscription
80 0 : s << " objects subscription: ";
81 :
82 0 : if (criteria.get_objects_subscription().empty())
83 : {
84 0 : s << "(null)\n";
85 : }
86 : else
87 : {
88 0 : s << std::endl;
89 0 : for (const auto& i : criteria.get_objects_subscription())
90 : {
91 0 : s << " objects of class \"" << i.first << "\":\n";
92 0 : for (const auto& j : i.second)
93 : {
94 0 : s << " \"" << j << "\":\n";
95 : }
96 : }
97 : }
98 :
99 0 : return s;
100 : }
101 : } // namespace conffwk
102 : } // namespace dunedaq
|