| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 extends<Service,
34 IIncidentSvc>
35 {
36 public:
37 struct Listener final
38 {
39 IIncidentListener* iListener;
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
50 typedef std::vector<Listener> ListenerList;
51 typedef GaudiUtils::HashMap<Gaudi::StringKey, std::unique_ptr<ListenerList>> ListenerMap;
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...
70 void getListeners (std::vector<IIncidentListener*>& lis,
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:
79 ListenerMap::iterator removeListenerFromList(ListenerMap::iterator,
80 IIncidentListener* item,
81 bool scheduleRemoval);
82 // ==========================================================================
84 void i_fireIncident(const Incident& incident, const std::string& type);
85
87 ListenerMap m_listenerMap;
88
91 const std::string *m_currentIncidentType = nullptr;
92
94 mutable std::recursive_mutex m_listenerMapMutex;
95
97 mutable ChronoEntity m_timer ;
98 mutable bool m_timerLock = false ;
99 // ==========================================================================
100
101 };
102 // ============================================================================
103 // The END
104 // ============================================================================
105 #endif
106 // ============================================================================
IncidentSvc::m_timer
ChronoEntity m_timer
timer & it's lock
Definition: IncidentSvc.h:97
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
IncidentSvc::finalize
StatusCode finalize() override
Definition: IncidentSvc.cpp:80
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
IncidentSvc::m_timerLock
bool m_timerLock
Definition: IncidentSvc.h:98
IncidentSvc::Listener::rethrow
bool rethrow
Definition: IncidentSvc.h:41
IncidentSvc::addListener
void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false) override
Definition: IncidentSvc.cpp:94
IncidentSvc::removeListenerFromList
ListenerMap::iterator removeListenerFromList(ListenerMap::iterator, IIncidentListener *item, bool scheduleRemoval)
Definition: IncidentSvc.cpp:124
IncidentSvc::Listener::singleShot
bool singleShot
Definition: IncidentSvc.h:42
HashMap.h
IncidentSvc::IncidentSvc
IncidentSvc(const std::string &name, ISvcLocator *svc)
Definition: IncidentSvc.cpp:51
IncidentSvc::~IncidentSvc
~IncidentSvc() override
Definition: IncidentSvc.cpp:55
std::string
STL class.
Service.h
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
gaudirun.type
string type
Definition: gaudirun.py:151
IIncidentListener
The interface implemented by any class wanting to listen to Incidents.
Definition: IIncidentListener.h:13
IncidentSvc::m_listenerMapMutex
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:94
IIncidentSvc.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IncidentSvc::removeListener
void removeListener(IIncidentListener *l, const std::string &type="") override
Definition: IncidentSvc.cpp:148
std::recursive_mutex
IncidentSvc::Listener::priority
long priority
Definition: IncidentSvc.h:40
StringKey.h
IncidentSvc::initialize
StatusCode initialize() override
Definition: IncidentSvc.cpp:62
IncidentSvc::ListenerList
std::vector< Listener > ListenerList
Definition: IncidentSvc.h:50
IncidentSvc::m_currentIncidentType
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:91
IncidentSvc::Listener::Listener
Listener(IIncidentListener *il, long pri, bool thr=false, bool single=false)
Definition: IncidentSvc.h:44
IncidentSvc::Listener::iListener
IIncidentListener * iListener
Definition: IncidentSvc.h:39
IncidentSvc::getListeners
void getListeners(std::vector< IIncidentListener * > &lis, const std::string &type="") const override
Definition: IncidentSvc.cpp:261
gaudirun.l
dictionary l
Definition: gaudirun.py:421
GaudiUtils::Map::iterator
map_type::iterator iterator
Definition: Map.h:99
std::vector
STL class.
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
IncidentSvc::i_fireIncident
void i_fireIncident(const Incident &incident, const std::string &type)
Internal function to allow incidents listening to all events.
Definition: IncidentSvc.cpp:174
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
IncidentSvc::Listener
Definition: IncidentSvc.h:37
GaudiUtils::HashMap
Common class providing an architecture-independent hash map.
Definition: HashMap.h:77
ana.item
tuple item
print s1,s2
Definition: ana.py:146
IncidentSvc::fireIncident
void fireIncident(const Incident &incident) override
Definition: IncidentSvc.cpp:246
IncidentSvc::m_listenerMap
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:87
IncidentSvc
Default implementation of the IIncidentSvc interface.
Definition: IncidentSvc.h:33
ChronoEntity.h
IncidentSvc::ListenerMap
GaudiUtils::HashMap< Gaudi::StringKey, std::unique_ptr< ListenerList > > ListenerMap
Definition: IncidentSvc.h:51