IncidentSvc.h
Go to the documentation of this file.00001
00002 #ifndef IncidentSvc_IncidentSvc_H
00003 #define IncidentSvc_IncidentSvc_H
00004
00005
00006 #include "GaudiKernel/Service.h"
00007 #include "GaudiKernel/SvcFactory.h"
00008 #include "GaudiKernel/IIncidentSvc.h"
00009
00010 #include <map>
00011 #include <list>
00012
00013 #include <boost/thread/recursive_mutex.hpp>
00014
00015
00016
00028 class IncidentSvc : public extends1<Service, IIncidentSvc> {
00029
00030 public:
00031
00032 struct Listener {
00033 IIncidentListener* iListener;
00034 long priority;
00035 bool rethrow;
00036 bool singleShot;
00037
00038 Listener(IIncidentListener* il, long pri, bool thr=false, bool single=false):
00039 iListener(il), priority(pri), rethrow(thr), singleShot(single){}
00040
00041 };
00042
00043
00044 typedef std::list<Listener> ListenerList;
00045 typedef std::map<std::string, ListenerList*> ListenerMap;
00046
00047
00048
00049 virtual StatusCode initialize();
00050 virtual StatusCode finalize();
00051
00052
00053
00054 virtual void addListener(IIncidentListener* lis, const std::string& type = "",
00055 long priority = 0, bool rethrow=false, bool singleShot=false);
00056
00057 virtual void removeListener(IIncidentListener* lis, const std::string& type = "");
00058 virtual void fireIncident( const Incident& incident );
00059
00060
00061 IncidentSvc( const std::string& name, ISvcLocator* svc );
00062
00063 virtual ~IncidentSvc();
00064
00065 private:
00067 void i_fireIncident(const Incident& incident, const std::string& type);
00068
00070 ListenerMap m_listenerMap;
00071
00074 const std::string *m_currentIncidentType;
00075
00077 MsgStream m_log;
00078
00080 boost::recursive_mutex m_listenerMapMutex;
00081 };
00082
00083 #endif
00084
00085