CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Types | Private Attributes
stor::RegistrationCollection Class Reference

#include <RegistrationCollection.h>

Public Types

typedef std::vector
< EventConsRegPtr
ConsumerRegistrations
 
typedef std::vector
< DQMEventConsRegPtr
DQMConsumerRegistrations
 

Public Member Functions

bool addRegistrationInfo (RegPtr)
 
void clearRegistrations ()
 
void disableConsumerRegistration ()
 
void enableConsumerRegistration ()
 
ConsumerID getConsumerId ()
 
void getDQMEventConsumers (DQMConsumerRegistrations &) const
 
void getEventConsumers (ConsumerRegistrations &) const
 
RegPtr getRegistrationInfo (const ConsumerID) const
 
 RegistrationCollection ()
 
bool registrationIsAllowed (const ConsumerID) const
 
 ~RegistrationCollection ()
 

Private Types

typedef std::map< ConsumerID,
RegPtr
RegistrationMap
 

Private Attributes

RegistrationMap consumers_
 
boost::mutex lock_
 
ConsumerID nextConsumerId_
 
bool registrationAllowed_
 

Detailed Description

Keep a collection of registered event and DQM event consumers.

Author:
mommsen
Revision:
1.8
Date:
2011/03/07 15:31:32

Definition at line 29 of file RegistrationCollection.h.

Member Typedef Documentation

Get event consumer registrations.

Definition at line 57 of file RegistrationCollection.h.

Get DQM event consumer registrations.

Definition at line 63 of file RegistrationCollection.h.

Definition at line 94 of file RegistrationCollection.h.

Constructor & Destructor Documentation

RegistrationCollection::RegistrationCollection ( )

Definition at line 11 of file RegistrationCollection.cc.

References lock_, nextConsumerId_, and registrationAllowed_.

12 {
13  boost::mutex::scoped_lock sl( lock_ );
15  registrationAllowed_ = false;
16 }
RegistrationCollection::~RegistrationCollection ( )

Definition at line 18 of file RegistrationCollection.cc.

18 {}

Member Function Documentation

bool RegistrationCollection::addRegistrationInfo ( RegPtr  ri)

Add registration info. Return false if no registration is allowed.

Definition at line 33 of file RegistrationCollection.cc.

References consumers_, lock_, pos, and registrationAllowed_.

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 }
Container::value_type value_type
void RegistrationCollection::clearRegistrations ( )

Clear registrations.

Definition at line 113 of file RegistrationCollection.cc.

References consumers_, and lock_.

114 {
115  boost::mutex::scoped_lock sl( lock_ );
116  consumers_.clear();
117 }
void RegistrationCollection::disableConsumerRegistration ( )

Disable registration.

Definition at line 107 of file RegistrationCollection.cc.

References registrationAllowed_.

108 {
109  //boost::mutex::scoped_lock sl( lock_ );
110  registrationAllowed_ = false;
111 }
void RegistrationCollection::enableConsumerRegistration ( )

Enable registration.

Definition at line 101 of file RegistrationCollection.cc.

References registrationAllowed_.

102 {
103  //boost::mutex::scoped_lock sl( lock_ );
104  registrationAllowed_ = true;
105 }
ConsumerID RegistrationCollection::getConsumerId ( )

Return next available consumer ID or 0 if no registration is allowed.

Definition at line 20 of file RegistrationCollection.cc.

References lock_, nextConsumerId_, and registrationAllowed_.

21 {
22  boost::mutex::scoped_lock sl( lock_ );
23 
25  {
26  return ConsumerID(0);
27  }
28 
29  return ++nextConsumerId_;
30 }
void RegistrationCollection::getDQMEventConsumers ( DQMConsumerRegistrations crs) const

Definition at line 88 of file RegistrationCollection.cc.

References consumers_, and lock_.

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 }
boost::shared_ptr< stor::DQMEventConsumerRegistrationInfo > DQMEventConsRegPtr
void RegistrationCollection::getEventConsumers ( ConsumerRegistrations crs) const

Definition at line 71 of file RegistrationCollection.cc.

References consumers_, lock_, and python.multivaluedict::sort().

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.
84  utils::ptrComp<EventConsumerRegistrationInfo> comp;
85  std::sort(crs.begin(), crs.end(), comp);
86 }
boost::shared_ptr< stor::EventConsumerRegistrationInfo > EventConsRegPtr
RegPtr RegistrationCollection::getRegistrationInfo ( const ConsumerID  cid) const

Get registration info for ConsumerID. Returns empty pointer if not found.

Definition at line 57 of file RegistrationCollection.cc.

References consumers_, lock_, and pos.

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 }
boost::shared_ptr< RegistrationInfoBase > RegPtr
bool RegistrationCollection::registrationIsAllowed ( const ConsumerID  cid) const

Test if registration is allowed.

Definition at line 119 of file RegistrationCollection.cc.

References consumers_, lock_, pos, and registrationAllowed_.

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 }

Member Data Documentation

RegistrationMap stor::RegistrationCollection::consumers_
private
boost::mutex stor::RegistrationCollection::lock_
mutableprivate
ConsumerID stor::RegistrationCollection::nextConsumerId_
private

Definition at line 90 of file RegistrationCollection.h.

Referenced by getConsumerId(), and RegistrationCollection().

bool stor::RegistrationCollection::registrationAllowed_
private