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 0 : i->second.erase(object_id);
44 0 : if (i->second.empty()) {
45 0 : m_objects_subscription.erase(i);
46 : }
47 : }
48 0 : }
49 :
50 : void
51 0 : ConfigurationSubscriptionCriteria::remove(const DalObject& object)
52 : {
53 0 : remove(object.class_name(), object.UID());
54 0 : }
55 :
56 : std::ostream&
57 0 : operator<<(std::ostream& s, const ConfigurationSubscriptionCriteria& criteria)
58 : {
59 0 : s << "Subscription criteria:\n";
60 :
61 : // print out classes subscription
62 0 : s << " classes subscription: ";
63 :
64 0 : if (criteria.get_classes_subscription().empty()) {
65 0 : s << "(null)\n";
66 : } else {
67 0 : s << std::endl;
68 0 : for (const auto& i : criteria.get_classes_subscription()) {
69 0 : s << " \"" << i << "\"\n";
70 : }
71 : }
72 :
73 : // print out objects subscription
74 0 : s << " objects subscription: ";
75 :
76 0 : if (criteria.get_objects_subscription().empty()) {
77 0 : s << "(null)\n";
78 : } else {
79 0 : s << std::endl;
80 0 : for (const auto& i : criteria.get_objects_subscription()) {
81 0 : s << " objects of class \"" << i.first << "\":\n";
82 0 : for (const auto& j : i.second) {
83 0 : s << " \"" << j << "\":\n";
84 : }
85 : }
86 : }
87 :
88 0 : return s;
89 : }
90 : } // namespace conffwk
91 : } // namespace dunedaq
|