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"
14 #include "GaudiKernel/IIncidentSvc.h"
15 #include "GaudiKernel/StringKey.h"
16 #include "GaudiKernel/StringKey.h"
17 #include "GaudiKernel/HashMap.h"
18 #include "GaudiKernel/ChronoEntity.h"
19 // ============================================================================
31 struct isSingleShot_t;
32 
33 class IncidentSvc : public extends1<Service, IIncidentSvc>
34 {
35  public:
36  struct Listener final
37  {
39  long priority;
40  bool rethrow;
41  bool singleShot;
42 
43  Listener(IIncidentListener* il, long pri, bool thr=false, bool single=false):
44  iListener(il), priority(pri), rethrow(thr), singleShot(single){}
45  };
46  private:
47 
48  // Typedefs
49  typedef std::vector<Listener> ListenerList;
51 
52 public:
53  // Inherited Service overrides:
54  //
55  StatusCode initialize() override;
56  StatusCode finalize() override;
57 
58  // IIncidentSvc interfaces overwrite
59  //
60  void addListener( IIncidentListener* lis ,
61  const std::string& type = "" ,
62  long priority = 0 ,
63  bool rethrow = false ,
64  bool singleShot = false ) override;
65 
66  void removeListener( IIncidentListener* l, const std::string& type = "" ) override;
67  void fireIncident( const Incident& incident) override;
68  //TODO: return by value instead...
69  void getListeners (std::vector<IIncidentListener*>& lis,
70  const std::string& type = "") const override;
71 
72  // Standard Constructor.
73  IncidentSvc( const std::string& name, ISvcLocator* svc );
74  // Destructor.
75  ~IncidentSvc() override;
76 
77 private:
80  bool scheduleRemoval);
81  // ==========================================================================
83  void i_fireIncident(const Incident& incident, const std::string& type);
84 
86  ListenerMap m_listenerMap;
87 
90  const std::string *m_currentIncidentType = nullptr;
91 
93  mutable std::recursive_mutex m_listenerMapMutex;
94 
97  mutable bool m_timerLock = false ;
98  // ==========================================================================
99 
100 };
101 // ============================================================================
102 // The END
103 // ============================================================================
104 #endif
105 // ============================================================================
ChronoEntity m_timer
timer & it's lock
Definition: IncidentSvc.h:96
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
StatusCode finalize() override
Definition: IncidentSvc.cpp:80
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:97
void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false) override
Definition: IncidentSvc.cpp:94
ListenerMap::iterator removeListenerFromList(ListenerMap::iterator, IIncidentListener *item, bool scheduleRemoval)
IncidentSvc(const std::string &name, ISvcLocator *svc)
Definition: IncidentSvc.cpp:51
~IncidentSvc() override
Definition: IncidentSvc.cpp:55
The interface implemented by any class wanting to listen to Incidents.
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:93
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
void removeListener(IIncidentListener *l, const std::string &type="") override
StatusCode initialize() override
Definition: IncidentSvc.cpp:62
std::vector< Listener > ListenerList
Definition: IncidentSvc.h:49
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:90
Listener(IIncidentListener *il, long pri, bool thr=false, bool single=false)
Definition: IncidentSvc.h:43
IIncidentListener * iListener
Definition: IncidentSvc.h:38
void getListeners(std::vector< IIncidentListener * > &lis, const std::string &type="") const override
dictionary l
Definition: gaudirun.py:421
map_type::iterator iterator
Definition: Map.h:99
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
void i_fireIncident(const Incident &incident, const std::string &type)
Internal function to allow incidents listening to all events.
Base class for all Incidents (computing events).
Definition: Incident.h:16
Common class providing an architecture-independent hash map.
Definition: HashMap.h:77
tuple item
print s1,s2
Definition: ana.py:146
void fireIncident(const Incident &incident) override
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:86
Default implementation of the IIncidentSvc interface.
Definition: IncidentSvc.h:33
GaudiUtils::HashMap< Gaudi::StringKey, std::unique_ptr< ListenerList > > ListenerMap
Definition: IncidentSvc.h:50
string type
Definition: gaudirun.py:151