artdaq_mfextensions  v1_05_00
ma_participants.h
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 
12 #include <string>
13 #include <vector>
14 #include <map>
15 #include <set>
16 
17 namespace novadaq {
18 namespace errorhandler {
19 
20 typedef std::set<std::string> string_set_t;
21 typedef std::map<std::string, string_set_t> groups_t;
22 
24 {
25 private:
26 
28  : ungrouped_apps(), all_apps(), groups()
29  { }
30 
31 public:
32 
33  static ma_participants & instance()
34  { static ma_participants pt; return pt; }
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
45  , std::string const & app );
46 
47  // add a new participant to the top level (without a group)
48  void add_participant( std::string const & app );
49 
50  // get methods
51  size_t get_group_participant_count( std::string const & group ) const;
52  size_t get_participant_count( ) const;
53 
54  // reset method
55  void reset( );
56 
57 private:
58 
59  string_set_t ungrouped_apps;
60  string_set_t all_apps;
61  groups_t groups;
62 
63 };
64 
65 
66 
67 } // end of namespace errorhandler
68 } // end of namespace novadaq
69 
70 
71 
72 #endif
73 
74 
75 
76