Line data Source code
1 : #ifndef ERRORHANDLER_PARTICIPANTS_H
2 : #define ERRORHANDLER_PARTICIPANTS_H
3 :
4 : // ma_participants
5 : // --------------------------------------------
6 : // A singleton class that keeps track of current participants (applications
7 : // who have sent a message facility message) in the DAQ system. Participants
8 : // can be grouped to "groups", e.g., all "dcm"s can be grouped together. One
9 : // may query the number of participants in a group
10 :
11 : #include <map>
12 : #include <set>
13 : #include <string>
14 : #include <vector>
15 :
16 : namespace novadaq {
17 : namespace errorhandler {
18 :
19 : typedef std::set<std::string> string_set_t;
20 : typedef std::map<std::string, string_set_t> groups_t;
21 :
22 : class ma_participants
23 : {
24 : private:
25 0 : ma_participants()
26 0 : : ungrouped_apps(), all_apps(), groups()
27 0 : {}
28 :
29 : public:
30 0 : static ma_participants& instance()
31 : {
32 0 : static ma_participants pt;
33 0 : return pt;
34 : }
35 :
36 : // add a new group
37 : void add_group(std::string const& group);
38 :
39 : // add a new group and fill the group with participants "group-1", "group-2"
40 : // ... "group-size"
41 : void add_group(std::string const& group, size_t size);
42 :
43 : // add a new participant to a group
44 : void add_participant(std::string const& group, std::string const& app);
45 :
46 : // add a new participant to the top level (without a group)
47 : void add_participant(std::string const& app);
48 :
49 : // get methods
50 : size_t get_group_participant_count(std::string const& group) const;
51 : size_t get_participant_count() const;
52 :
53 : // reset method
54 : void reset();
55 :
56 : private:
57 : string_set_t ungrouped_apps;
58 : string_set_t all_apps;
59 : groups_t groups;
60 : };
61 :
62 : } // end of namespace errorhandler
63 : } // end of namespace novadaq
64 :
65 : #endif
|