CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RegistrationCollection.cc
Go to the documentation of this file.
1 // $Id: RegistrationCollection.cc,v 1.10.4.1 2011/03/07 11:33:05 mommsen Exp $
3 
5 
6 #include <boost/pointer_cast.hpp>
7 #include <algorithm>
8 
9 using namespace stor;
10 
12 {
13  boost::mutex::scoped_lock sl( lock_ );
15  registrationAllowed_ = false;
16 }
17 
19 
21 {
22  boost::mutex::scoped_lock sl( lock_ );
23 
25  {
26  return ConsumerID(0);
27  }
28 
29  return ++nextConsumerId_;
30 }
31 
32 bool
34 {
35  boost::mutex::scoped_lock sl( lock_ );
37  {
38  ConsumerID cid = ri->consumerId();
39  RegistrationMap::iterator pos = consumers_.lower_bound(cid);
40 
41  if ( pos != consumers_.end() && !(consumers_.key_comp()(cid, pos->first)) )
42  {
43  // The given ConsumerID already exists.
44  return false;
45  }
46 
47  consumers_.insert( pos, RegistrationMap::value_type(cid, ri) );
48  return true;
49  }
50  else
51  {
52  return false;
53  }
54 }
55 
56 
58 {
59  boost::mutex::scoped_lock sl( lock_ );
60  RegPtr regInfo;
61  RegistrationMap::const_iterator pos = consumers_.find(cid);
62  if ( pos != consumers_.end() )
63  {
64  pos->second->consumerContact();
65  regInfo = pos->second;
66  }
67  return regInfo;
68 }
69 
70 
72 {
73  boost::mutex::scoped_lock sl( lock_ );
74  for( RegistrationMap::const_iterator it = consumers_.begin();
75  it != consumers_.end(); ++it )
76  {
77  EventConsRegPtr eventConsumer =
78  boost::dynamic_pointer_cast<EventConsumerRegistrationInfo>( it->second );
79  if ( eventConsumer )
80  crs.push_back( eventConsumer );
81  }
82  // sort the event consumers to have identical consumers sharing a queue
83  // next to each others.
85  std::sort(crs.begin(), crs.end(), comp);
86 }
87 
89 {
90  boost::mutex::scoped_lock sl( lock_ );
91  for( RegistrationMap::const_iterator it = consumers_.begin();
92  it != consumers_.end(); ++it )
93  {
94  DQMEventConsRegPtr dqmEventConsumer =
95  boost::dynamic_pointer_cast<DQMEventConsumerRegistrationInfo>( it->second );
96  if ( dqmEventConsumer )
97  crs.push_back( dqmEventConsumer );
98  }
99 }
100 
102 {
103  //boost::mutex::scoped_lock sl( lock_ );
104  registrationAllowed_ = true;
105 }
106 
108 {
109  //boost::mutex::scoped_lock sl( lock_ );
110  registrationAllowed_ = false;
111 }
112 
114 {
115  boost::mutex::scoped_lock sl( lock_ );
116  consumers_.clear();
117 }
118 
120 {
121  boost::mutex::scoped_lock sl( lock_ );
122 
123  RegistrationMap::const_iterator pos = consumers_.find(cid);
124  if ( pos == consumers_.end() ) return false;
125  pos->second->consumerContact();
126 
127  return registrationAllowed_;
128 }
129 
130 
std::vector< EventConsRegPtr > ConsumerRegistrations
boost::shared_ptr< RegistrationInfoBase > RegPtr
boost::shared_ptr< stor::EventConsumerRegistrationInfo > EventConsRegPtr
Container::value_type value_type
RegPtr getRegistrationInfo(const ConsumerID) const
bool registrationIsAllowed(const ConsumerID) const
void getEventConsumers(ConsumerRegistrations &) const
std::vector< DQMEventConsRegPtr > DQMConsumerRegistrations
boost::shared_ptr< stor::DQMEventConsumerRegistrationInfo > DQMEventConsRegPtr
void getDQMEventConsumers(DQMConsumerRegistrations &) const