00001
00002 #ifndef _RUNCHANGEHANDLERSVC_H_
00003 #define _RUNCHANGEHANDLERSVC_H_
00004
00005 #include "GaudiKernel/Service.h"
00006 #include "GaudiKernel/Map.h"
00007 #include "GaudiKernel/IIncidentListener.h"
00008 #include "GaudiKernel/IDataProviderSvc.h"
00009 #include "GaudiKernel/IIncidentSvc.h"
00010 #include "GaudiKernel/IEventProcessor.h"
00011 #include "GaudiKernel/IUpdateManagerSvc.h"
00012 #include "GaudiKernel/GaudiException.h"
00013 #include "GaudiKernel/SmartDataPtr.h"
00014
00015 #include <list>
00016
00025 class RunChangeHandlerSvc:
00026 public Service,
00027 public virtual IIncidentListener {
00028
00029 public:
00030
00032 RunChangeHandlerSvc(const std::string& name, ISvcLocator* svcloc);
00033
00034 virtual ~RunChangeHandlerSvc();
00035
00040 virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown);
00041
00043 virtual StatusCode initialize();
00044
00046 virtual StatusCode finalize();
00047
00048
00050 virtual void handle(const Incident &inc);
00051
00052 private:
00053
00055 template <class I>
00056 inline I * getService(const std::string &name, I *&ptr) const {
00057 if (0 == ptr) {
00058 StatusCode sc = service(name, ptr, true);
00059 if( sc.isFailure() ) {
00060 throw GaudiException("Service ["+name+"] not found", this->name(), sc);
00061 }
00062 }
00063 return ptr;
00064 }
00065
00067 template <class I>
00068 inline void release(I *&ptr) const {
00069 if (ptr) {
00070 ptr->release();
00071 ptr = 0;
00072 }
00073 }
00074
00076 inline IDataProviderSvc *eventSvc() const {
00077 return getService("EventDataSvc",m_evtSvc);
00078 }
00079
00081 inline IDataProviderSvc *detectorSvc() const {
00082 return getService("DetectorDataSvc",m_detSvc);
00083 }
00084
00086 inline IIncidentSvc *incidentSvc() const {
00087 return getService("IncidentSvc",m_incSvc);
00088 }
00089
00091 inline IUpdateManagerSvc *updMgrSvc() const {
00092 return getService("UpdateManagerSvc",m_ums);
00093 }
00094
00096 inline IEventProcessor *evtProc() const {
00097 return getService("ApplicationMgr",m_evtProc);
00098 }
00099
00101 struct CondData {
00102 CondData(IDataProviderSvc* pService,
00103 const std::string& fullPath,
00104 const std::string &pathTempl):
00105 object(pService, fullPath),
00106 pathTemplate(pathTempl) {}
00107 SmartDataPtr<ValidDataObject> object;
00108 std::string pathTemplate;
00109 };
00110
00112 void update(CondData &cond);
00113
00114 typedef GaudiUtils::Map<std::string,std::string> CondDescMap;
00115 CondDescMap m_condDesc;
00116
00117 typedef std::list<CondData> Conditions;
00119 Conditions m_conditions;
00120
00122 unsigned long m_currentRun;
00123
00125 mutable IDataProviderSvc *m_evtSvc;
00126
00128 mutable IDataProviderSvc *m_detSvc;
00129
00131 mutable IIncidentSvc *m_incSvc;
00132
00134 mutable IUpdateManagerSvc *m_ums;
00135
00138 mutable IEventProcessor *m_evtProc;
00139
00140 };
00141
00142 #endif