All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IncidentSvc Class Reference

Default implementation of the IIncidentSvc interface. More...

#include <src/IncidentSvc/IncidentSvc.h>

Inheritance diagram for IncidentSvc:
Collaboration diagram for IncidentSvc:

Classes

struct  Listener
 

Public Types

typedef std::list< ListenerListenerList
 
typedef GaudiUtils::HashMap
< Gaudi::StringKey,
ListenerList * > 
ListenerMap
 
- Public Types inherited from extends1< Service, IIncidentSvc >
typedef extends1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1
< IIncidentSvc
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef
Gaudi::PluginService::Factory2
< IService *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename
IService::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces1< IIncidentSvc >
typedef
IIncidentSvc::iid::iids::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 

Public Member Functions

virtual StatusCode initialize ()
 Initialization (from CONFIGURED to INITIALIZED). More...
 
virtual StatusCode finalize ()
 Finalize (from INITIALIZED to CONFIGURED). More...
 
virtual void addListener (IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)
 Add listener. More...
 
virtual void removeListener (IIncidentListener *lis, const std::string &type="")
 Remove listener. More...
 
virtual void fireIncident (const Incident &incident)
 Fire an Incident. More...
 
virtual void getListeners (std::vector< IIncidentListener * > &lis, const std::string &type="") const
 
 IncidentSvc (const std::string &name, ISvcLocator *svc)
 
virtual ~IncidentSvc ()
 
- Public Member Functions inherited from extends1< Service, IIncidentSvc >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends1 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends1 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Get list of properties. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces1< IIncidentSvc >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IIncidentSvc
 DeclareInterfaceID (IIncidentSvc, 2, 0)
 InterfaceID. More...
 

Private Member Functions

void i_fireIncident (const Incident &incident, const std::string &type)
 Internal function to allow incidents listening to all events. More...
 

Private Attributes

ListenerMap m_listenerMap
 List of auditor names. More...
 
const std::string * m_currentIncidentType
 Incident being fired. More...
 
boost::recursive_mutex m_listenerMapMutex
 Mutex to synchronize access to m_listenerMap. More...
 
ChronoEntity m_timer
 timer & it's lock More...
 
bool m_timerLock
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

Default implementation of the IIncidentSvc interface.

This implementation is thread-safe with the following features:

Definition at line 34 of file IncidentSvc.h.

Member Typedef Documentation

typedef std::list<Listener> IncidentSvc::ListenerList

Definition at line 52 of file IncidentSvc.h.

Constructor & Destructor Documentation

IncidentSvc::IncidentSvc ( const std::string &  name,
ISvcLocator svc 
)

Definition at line 50 of file IncidentSvc.cpp.

51  : base_class(name, svc)
53  , m_timer()
54  , m_timerLock ( false )
55 {}
ChronoEntity m_timer
timer & it's lock
Definition: IncidentSvc.h:100
bool m_timerLock
Definition: IncidentSvc.h:101
extends1 base_class
Typedef to this class.
Definition: extends.h:12
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:94
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
IncidentSvc::~IncidentSvc ( )
virtual

Definition at line 57 of file IncidentSvc.cpp.

58 {
59  boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);
60 
62  i != m_listenerMap.end();
63  ++i) {
64  delete i->second;
65  }
66 }
boost::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:97
def lock
Definition: locker.py:16
iterator end()
Definition: Map.h:131
iterator begin()
Definition: Map.h:130
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:90
list i
Definition: ana.py:128

Member Function Documentation

void IncidentSvc::addListener ( IIncidentListener lis,
const std::string &  type = "",
long  priority = 0,
bool  rethrow = false,
bool  singleShot = false 
)
virtual

Add listener.

Parameters
lisListener address
typeIncident type
priorityPriority in handling incident

Implements IIncidentSvc.

Definition at line 106 of file IncidentSvc.cpp.

109 {
110 
111  boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);
112 
113  std::string ltype;
114  if( type == "" ) ltype = "ALL";
115  else ltype = type;
116  // find if the type already exists
117  ListenerMap::iterator itMap = m_listenerMap.find( ltype );
118  if( itMap == m_listenerMap.end() ) {
119  // if not found, create and insert now a list of listeners
120  ListenerList* newlist = new ListenerList();
121  std::pair<ListenerMap::iterator, bool> p;
122  p = m_listenerMap.insert(ListenerMap::value_type(ltype, newlist));
123  if( p.second ) itMap = p.first;
124  }
125  ListenerList* llist = (*itMap).second;
126  // add Listener in the ListenerList according to the priority
127  ListenerList::iterator itlist;
128  for( itlist = llist->begin(); itlist != llist->end(); itlist++ ) {
129  if( (*itlist).priority < prio ) {
130  // We insert before the current position
131  break;
132  }
133  }
134 
135  DEBMSG << "Adding [" << type << "] listener '" << getListenerName(lis)
136  << "' with priority " << prio << endmsg;
137 
138  llist->insert(itlist, Listener(lis, prio, rethrow, singleShot));
139 }
boost::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:97
def lock
Definition: locker.py:16
std::list< Listener > ListenerList
Definition: IncidentSvc.h:52
#define DEBMSG
Definition: IncidentSvc.cpp:44
std::pair< iterator, bool > insert(const value_type &val)
Definition: Map.h:165
iterator end()
Definition: Map.h:131
string type
Definition: gaudirun.py:126
std::pair< const Gaudi::StringKey, ListenerList * > value_type
Definition: Map.h:94
iterator find(const key_type &key)
Definition: Map.h:148
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:90
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
StatusCode IncidentSvc::finalize ( )
virtual

Finalize (from INITIALIZED to CONFIGURED).

Reimplemented from Service.

Definition at line 91 of file IncidentSvc.cpp.

92 {
93  DEBMSG << m_timer.outputUserTime( "Incident timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
94  << m_timer.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
95 
96  // Finalize this specific service
98  if ( UNLIKELY(sc.isFailure()) ) { return sc; }
99 
100  return StatusCode::SUCCESS;
101 }
#define UNLIKELY(x)
Definition: Kernel.h:127
ChronoEntity m_timer
timer & it's lock
Definition: IncidentSvc.h:100
#define DEBMSG
Definition: IncidentSvc.cpp:44
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
std::string outputUserTime() const
print the chrono ;
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: Service.cpp:199
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
void IncidentSvc::fireIncident ( const Incident incident)
virtual

Fire an Incident.

Parameters
Incidentbeing fired

Implements IIncidentSvc.

Definition at line 283 of file IncidentSvc.cpp.

284 {
285 
287 
288  // Call specific listeners
289  i_fireIncident(incident, incident.type());
290  // Try listeners registered for ALL incidents
291  if ( incident.type() != "ALL" ){ // avoid double calls if somebody fires the incident "ALL"
292  i_fireIncident(incident, "ALL");
293  }
294 
295 }
ChronoEntity m_timer
timer & it's lock
Definition: IncidentSvc.h:100
const std::string & type() const
Access to the incident type.
Definition: Incident.h:34
bool m_timerLock
Definition: IncidentSvc.h:101
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:54
void i_fireIncident(const Incident &incident, const std::string &type)
Internal function to allow incidents listening to all events.
void IncidentSvc::getListeners ( std::vector< IIncidentListener * > &  lis,
const std::string &  type = "" 
) const
virtual

Implements IIncidentSvc.

Definition at line 299 of file IncidentSvc.cpp.

301 {
302 
303  boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);
304 
305  std::string ltype;
306  if (type == "") { ltype = "ALL"; } else { ltype = type; }
307 
308  lis.clear();
309 
311  if (itr == m_listenerMap.end()) return;
312 
313  ListenerList::const_iterator itlist;
314  for (itlist = itr->second->begin(); itlist != itr->second->end(); ++itlist) {
315  lis.push_back(itlist->iListener);
316  }
317 
318 
319 }
boost::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:97
def lock
Definition: locker.py:16
iterator end()
Definition: Map.h:131
string type
Definition: gaudirun.py:126
iterator find(const key_type &key)
Definition: Map.h:148
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:90
void IncidentSvc::i_fireIncident ( const Incident incident,
const std::string &  type 
)
private

Internal function to allow incidents listening to all events.

Definition at line 211 of file IncidentSvc.cpp.

213 {
214 
215  boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);
216 
217  // Special case: FailInputFile incident must set the application return code
218  if (incident.type() == IncidentType::FailInputFile
219  || incident.type() == IncidentType::CorruptedInputFile) {
221  if (incident.type() == IncidentType::FailInputFile)
222  // Set the return code to Gaudi::ReturnCode::FailInput (2)
224  else
226  }
227 
228  ListenerMap::iterator itmap = m_listenerMap.find( listenerType );
229  if ( m_listenerMap.end() == itmap ) return;
230 
231  // setting this pointer will avoid that a call to removeListener() during
232  // the loop triggers a segfault
233  m_currentIncidentType = &(incident.type());
234 
235  ListenerList* llist = (*itmap).second;
236  ListenerList::iterator itlist;
237  bool weHaveToCleanUp = false;
238  // loop over all registered Listeners
239 
240  for( itlist = llist->begin(); itlist != llist->end(); itlist++ )
241  {
242 
243  VERMSG << "Calling '" << getListenerName((*itlist).iListener)
244  << "' for incident [" << incident.type() << "]" << endmsg;
245 
246  // handle exceptions if they occur
247  try {
248  (*itlist).iListener->handle(incident);
249  }
250  catch( const GaudiException& exc ) {
251  error() << "Exception with tag=" << exc.tag() << " is caught"
252  " handling incident" << m_currentIncidentType << endmsg;
253  error() << exc << endmsg;
254  if ( (*itlist).rethrow ) { throw (exc); }
255  }
256  catch( const std::exception& exc ) {
257  error() << "Standard std::exception is caught"
258  " handling incident" << m_currentIncidentType << endmsg;
259  error() << exc.what() << endmsg;
260  if ( (*itlist).rethrow ) { throw (exc); }
261  }
262  catch(...) {
263  error() << "UNKNOWN Exception is caught"
264  " handling incident" << m_currentIncidentType << endmsg;
265  if ( (*itlist).rethrow ) { throw; }
266  }
267  // check if at least one of the listeners is a one-shot
268  weHaveToCleanUp |= itlist->singleShot;
269  }
270  if (weHaveToCleanUp) {
271  // remove all the listeners that need to be removed from the list
272  llist->remove_if( listenerToBeRemoved() );
273  // if the list is empty, we can remove it
274  if( llist->size() == 0) {
275  delete llist;
276  m_listenerMap.erase(itmap);
277  }
278  }
279 
281 }
boost::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:97
Define general base for Gaudi exception.
const std::string & type() const
Access to the incident type.
Definition: Incident.h:34
def lock
Definition: locker.py:16
std::list< Listener > ListenerList
Definition: IncidentSvc.h:52
const std::string FailInputFile
could not open or read from this file
Definition: Incident.h:78
void erase(iterator pos)
Definition: Map.h:173
iterator end()
Definition: Map.h:131
iterator find(const key_type &key)
Definition: Map.h:148
virtual const std::string & tag() const
name tag for the exception, or exception type
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:94
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:50
const int CorruptedInput
Definition: AppReturnCode.h:28
#define VERMSG
Definition: IncidentSvc.cpp:45
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:90
const int FailInput
Definition: AppReturnCode.h:23
void ignore() const
Definition: StatusCode.h:94
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
const std::string CorruptedInputFile
the input file has shown a corruption
Definition: Incident.h:81
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Service.cpp:336
StatusCode IncidentSvc::initialize ( )
virtual

Initialization (from CONFIGURED to INITIALIZED).

Reimplemented from Service.

Definition at line 70 of file IncidentSvc.cpp.

71 {
72  // initialize the Service Base class
74  if ( sc.isFailure() ) {
75  return sc;
76  }
77 
79 
80  // set my own (IncidentSvc) properties via the jobOptionService
81  sc = setProperties();
82  if ( UNLIKELY(sc.isFailure()) )
83  {
84  error() << "Could not set my properties" << endmsg;
85  return sc;
86  }
87 
88  return StatusCode::SUCCESS;
89 }
#define UNLIKELY(x)
Definition: Kernel.h:127
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:72
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:94
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:371
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: Service.cpp:74
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243
void IncidentSvc::removeListener ( IIncidentListener lis,
const std::string &  type = "" 
)
virtual

Remove listener.

Parameters
lisListener address
typeIncident type

Implements IIncidentSvc.

Definition at line 142 of file IncidentSvc.cpp.

144 {
145 
146  boost::recursive_mutex::scoped_lock lock(m_listenerMapMutex);
147 
148  if( type == "") {
149  // remove Listener from all the lists
150  ListenerMap::iterator itmap;
151  for ( itmap = m_listenerMap.begin(); itmap != m_listenerMap.end();)
152  {
153  // since the current entry may be eventually deleted
154  // we need to keep a memory of the next index before
155  // calling recursively this method
156  ListenerMap::iterator itmap_old = itmap;
157  itmap++;
158  removeListener( lis, (*itmap_old).first );
159  }
160  }
161  else {
163 
164  if( itmap == m_listenerMap.end() ) {
165  // if not found the incident type then return
166  return;
167  }
168  else {
169  ListenerList* llist = (*itmap).second;
170  ListenerList::iterator itlist;
171  bool justScheduleForRemoval = ( 0!= m_currentIncidentType )
172  && (type == *m_currentIncidentType);
173  // loop over all the entries in the Listener list
174  // to remove all of them than matches
175  // the listener address. Remember the next index
176  // before erasing the current one
177  for( itlist = llist->begin(); itlist != llist->end(); ) {
178  if( (*itlist).iListener == lis || lis == 0) {
179  if (justScheduleForRemoval) {
180  (itlist++)->singleShot = true; // remove it as soon as it is safe
181  }
182  else {
183  DEBMSG << "Removing [" << type << "] listener '"
184  << getListenerName(lis) << "'" << endmsg;
185  itlist = llist->erase(itlist); // remove from the list now
186  }
187  }
188  else {
189  itlist++;
190  }
191  }
192  if( llist->size() == 0) {
193  delete llist;
194  m_listenerMap.erase(itmap);
195  }
196  }
197  }
198 }
boost::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:97
def lock
Definition: locker.py:16
std::list< Listener > ListenerList
Definition: IncidentSvc.h:52
#define DEBMSG
Definition: IncidentSvc.cpp:44
void erase(iterator pos)
Definition: Map.h:173
iterator end()
Definition: Map.h:131
string type
Definition: gaudirun.py:126
iterator find(const key_type &key)
Definition: Map.h:148
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:94
virtual void removeListener(IIncidentListener *lis, const std::string &type="")
Remove listener.
iterator begin()
Definition: Map.h:130
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:90
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:243

Member Data Documentation

const std::string* IncidentSvc::m_currentIncidentType
private

Incident being fired.

It is used to know if we can safely remove a listener or we have to schedule its removal for later.

Definition at line 94 of file IncidentSvc.h.

ListenerMap IncidentSvc::m_listenerMap
private

List of auditor names.

Definition at line 90 of file IncidentSvc.h.

boost::recursive_mutex IncidentSvc::m_listenerMapMutex
mutableprivate

Mutex to synchronize access to m_listenerMap.

Definition at line 97 of file IncidentSvc.h.

ChronoEntity IncidentSvc::m_timer
mutableprivate

timer & it's lock

Definition at line 100 of file IncidentSvc.h.

bool IncidentSvc::m_timerLock
mutableprivate

Definition at line 101 of file IncidentSvc.h.


The documentation for this class was generated from the following files: