All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
IncidentSvc.h
Go to the documentation of this file.
1 #ifndef IncidentSvc_IncidentSvc_H
2 #define IncidentSvc_IncidentSvc_H
3 // ============================================================================
4 // Include Files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <map>
9 #include <list>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
13 #include "GaudiKernel/Service.h"
15 #include "GaudiKernel/StringKey.h"
16 #include "GaudiKernel/StringKey.h"
17 #include "GaudiKernel/HashMap.h"
19 // ============================================================================
20 // Boost
21 // ============================================================================
22 #include "boost/thread/recursive_mutex.hpp"
23 // ============================================================================
34 class IncidentSvc : public extends1<Service, IIncidentSvc>
35 {
36  // ==========================================================================
37 public:
38  // ==========================================================================
39  struct Listener
40  {
42  long priority;
43  bool rethrow;
44  bool singleShot;
45 
46  Listener(IIncidentListener* il, long pri, bool thr=false, bool single=false):
47  iListener(il), priority(pri), rethrow(thr), singleShot(single){}
48 
49  };
50 
51  // Typedefs
52  typedef std::list<Listener> ListenerList;
53  // typedef std::map<std::string, ListenerList*> ListenerMap;
55 
56  // Inherited Service overrides:
57  //
58  virtual StatusCode initialize();
59  virtual StatusCode finalize();
60 
61  // IIncidentSvc interfaces overwrite
62  //
63  virtual void addListener
64  ( IIncidentListener* lis ,
65  const std::string& type = "" ,
66  long priority = 0 ,
67  bool rethrow = false ,
68  bool singleShot = false ) ;
69 
70  virtual void removeListener
71  ( IIncidentListener* lis ,
72  const std::string& type = "" ) ;
73  virtual void fireIncident
74  ( const Incident& incident ) ;
75 
76  virtual void getListeners (std::vector<IIncidentListener*>& lis,
77  const std::string& type = "") const ;
78 
79  // Standard Constructor.
80  IncidentSvc( const std::string& name, ISvcLocator* svc );
81  // Destructor.
82  virtual ~IncidentSvc();
83 
84 private:
85  // ==========================================================================
87  void i_fireIncident(const Incident& incident, const std::string& type);
88 
91 
94  const std::string *m_currentIncidentType;
95 
97  mutable boost::recursive_mutex m_listenerMapMutex;
98 
101  mutable bool m_timerLock ;
102  // ==========================================================================
103 
104 };
105 // ============================================================================
106 // The END
107 // ============================================================================
108 #endif
109 // ============================================================================
110 
111 
boost::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:97
ChronoEntity m_timer
timer & it's lock
Definition: IncidentSvc.h:100
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
GaudiUtils::HashMap< Gaudi::StringKey, ListenerList * > ListenerMap
Definition: IncidentSvc.h:54
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
bool m_timerLock
Definition: IncidentSvc.h:101
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: IncidentSvc.cpp:70
std::list< Listener > ListenerList
Definition: IncidentSvc.h:52
IncidentSvc(const std::string &name, ISvcLocator *svc)
Definition: IncidentSvc.cpp:50
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: IncidentSvc.cpp:91
virtual void getListeners(std::vector< IIncidentListener * > &lis, const std::string &type="") const
string type
Definition: gaudirun.py:126
The interface implemented by any class wanting to listen to Incidents.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:94
Listener(IIncidentListener *il, long pri, bool thr=false, bool single=false)
Definition: IncidentSvc.h:46
IIncidentListener * iListener
Definition: IncidentSvc.h:41
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
virtual void removeListener(IIncidentListener *lis, const std::string &type="")
Remove listener.
void i_fireIncident(const Incident &incident, const std::string &type)
Internal function to allow incidents listening to all events.
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)
Add listener.
Base class for all Incidents (computing events).
Definition: Incident.h:16
virtual ~IncidentSvc()
Definition: IncidentSvc.cpp:57
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:90
Default implementation of the IIncidentSvc interface.
Definition: IncidentSvc.h:34
virtual void fireIncident(const Incident &incident)
Fire an Incident.