artdaq_mfextensions  v1_05_00
ma_participants.cpp
1 
2 #include "ErrorHandler/MessageAnalyzer/ma_participants.h"
3 
4 #include <stdexcept>
5 #include <sstream>
6 
7 using namespace novadaq::errorhandler;
8 
9 // -----------------------------------------------------------------
10 // add group
11 
12 void ma_participants::add_group( std::string const & group )
13 {
14  groups_t::const_iterator it = groups.find(group);
15 
16  if( it!=groups.end() )
17  throw std::runtime_error( group + " already exists while creating new group");
18 
19  string_set_t apps;
20  groups.insert( std::make_pair(group, apps) );
21 }
22 
23 void ma_participants::add_group( std::string const & group, size_t size )
24 {
25  groups_t::const_iterator it = groups.find(group);
26 
27  if( it!=groups.end() )
28  throw std::runtime_error( group + " already exists while creating new group");
29 
30  string_set_t apps;
31  std::stringstream ss;
32 
33  for( size_t i=0; i<size; ++i )
34  {
35  ss.str( group );
36  ss << "-" << i;
37  apps.insert( ss.str() );
38  all_apps.insert( ss.str() );
39  }
40 
41  groups.insert( std::make_pair(group, apps) );
42 }
43 
44 // -----------------------------------------------------------------
45 // add participant
46 
47 void ma_participants::add_participant( std::string const & group
48  , std::string const & app )
49 {
50  groups_t::iterator it = groups.find(group);
51 
52  if( it==groups.end() )
53  throw std::runtime_error( group + " does not exist while inserting participants");
54 
55  it->second.insert(app);
56  all_apps.insert(app);
57 }
58 
59 void ma_participants::add_participant( std::string const & app )
60 {
61  ungrouped_apps.insert(app);
62  all_apps.insert(app);
63 }
64 
65 // -----------------------------------------------------------------
66 // get count
67 
68 size_t ma_participants::
69  get_group_participant_count( std::string const & group ) const
70 {
71  groups_t::const_iterator it = groups.find(group);
72 
73  if( it==groups.end() )
74  throw std::runtime_error( group + " does not exist while getting participant count");
75 
76  return it->second.size();
77 }
78 
79 size_t ma_participants::
80  get_participant_count( ) const
81 {
82  return all_apps.size();
83 }
84 
85 
86 // -----------------------------------------------------------------
87 // reset
88 void ma_participants::reset( )
89 {
90  ungrouped_apps.clear();
91  all_apps.clear();
92  groups.clear();
93 }
94 
95 
96 
97 
98 
99 
100 
101 
102