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 // ============================================================================
31 struct isSingleShot_t;
32 
33 class IncidentSvc : public extends<Service,
34  IIncidentSvc>
35 {
36  public:
37  struct Listener final
38  {
40  long priority;
41  bool rethrow;
42  bool singleShot;
43 
44  Listener(IIncidentListener* il, long pri, bool thr=false, bool single=false):
45  iListener(il), priority(pri), rethrow(thr), singleShot(single){}
46  };
47  private:
48 
49  // Typedefs
52 
53 public:
54  // Inherited Service overrides:
55  //
56  StatusCode initialize() override;
57  StatusCode finalize() override;
58 
59  // IIncidentSvc interfaces overwrite
60  //
61  void addListener( IIncidentListener* lis ,
62  const std::string& type = "" ,
63  long priority = 0 ,
64  bool rethrow = false ,
65  bool singleShot = false ) override;
66 
67  void removeListener( IIncidentListener* l, const std::string& type = "" ) override;
68  void fireIncident( const Incident& incident) override;
69  //TODO: return by value instead...
71  const std::string& type = "") const override;
72 
73  // Standard Constructor.
74  IncidentSvc( const std::string& name, ISvcLocator* svc );
75  // Destructor.
76  ~IncidentSvc() override;
77 
78 private:
81  bool scheduleRemoval);
82  // ==========================================================================
84  void i_fireIncident(const Incident& incident, const std::string& type);
85 
87  ListenerMap m_listenerMap;
88 
92 
95 
98  mutable bool m_timerLock = false ;
99  // ==========================================================================
100 
101 };
102 // ============================================================================
103 // The END
104 // ============================================================================
105 #endif
106 // ============================================================================
ChronoEntity m_timer
timer & it's lock
Definition: IncidentSvc.h:97
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:98
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
STL class.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
string type
Definition: gaudirun.py:151
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:94
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:50
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:91
Listener(IIncidentListener *il, long pri, bool thr=false, bool single=false)
Definition: IncidentSvc.h:44
IIncidentListener * iListener
Definition: IncidentSvc.h:39
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
STL class.
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:17
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:87
Default implementation of the IIncidentSvc interface.
Definition: IncidentSvc.h:33
GaudiUtils::HashMap< Gaudi::StringKey, std::unique_ptr< ListenerList > > ListenerMap
Definition: IncidentSvc.h:51