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