#include <RunChangeHandlerSvc.h>
Inheritance diagram for RunChangeHandlerSvc:
Public Types | |
| SUCCESS | |
| NO_INTERFACE | |
| VERSMISMATCH | |
| LAST_ERROR | |
| enum | Status |
| SUCCESS | |
| NO_INTERFACE | |
| VERSMISMATCH | |
| LAST_ERROR | |
| enum | Status |
Public Member Functions | |
| RunChangeHandlerSvc (const std::string &name, ISvcLocator *svcloc) | |
| Standard constructor. | |
| virtual | ~RunChangeHandlerSvc () |
| Destructor. | |
| virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown) |
| Query interfaces (. | |
| virtual StatusCode | initialize () |
| Initialize Service. | |
| virtual StatusCode | finalize () |
| Finalize Service. | |
| virtual void | handle (const Incident &inc) |
| Handle RunChange incident. | |
| virtual unsigned long | addRef () |
| virtual unsigned long | release () |
| virtual const std::string & | name () const |
| virtual const InterfaceID & | type () const |
| virtual StatusCode | configure () |
| virtual StatusCode | start () |
| virtual StatusCode | stop () |
| virtual StatusCode | terminate () |
| virtual Gaudi::StateMachine::State | FSMState () const |
| virtual Gaudi::StateMachine::State | targetFSMState () const |
| virtual StatusCode | reinitialize () |
| virtual StatusCode | restart () |
| virtual StatusCode | sysInitialize () |
| virtual StatusCode | sysStart () |
| virtual StatusCode | sysStop () |
| virtual StatusCode | sysFinalize () |
| virtual StatusCode | sysReinitialize () |
| virtual StatusCode | sysRestart () |
| virtual StatusCode | setProperty (const Property &p) |
| virtual StatusCode | setProperty (const std::string &s) |
| virtual StatusCode | setProperty (const std::string &n, const std::string &v) |
| StatusCode | setProperty (const std::string &name, const TYPE &value) |
| virtual StatusCode | getProperty (Property *p) const |
| virtual const Property & | getProperty (const std::string &name) const |
| virtual StatusCode | getProperty (const std::string &n, std::string &v) const |
| virtual const std::vector< Property * > & | getProperties () const |
| ISvcLocator * | serviceLocator () const |
| IMessageSvc * | msgSvc () |
| IMessageSvc * | msgSvc () const |
| IMessageSvc * | messageService () |
| IMessageSvc * | messageService () const |
| StatusCode | setProperties () |
| StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const |
| StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const |
| Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const |
| Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const |
| IAuditorSvc * | auditorSvc () const |
| virtual unsigned long | addRef ()=0 |
| virtual unsigned long | release ()=0 |
Static Public Member Functions | |
| static const InterfaceID & | interfaceID () |
| static const InterfaceID & | interfaceID () |
| static const InterfaceID & | interfaceID () |
| static const InterfaceID & | interfaceID () |
Public Attributes | |
| SUCCESS | |
| NO_INTERFACE | |
| VERSMISMATCH | |
| LAST_ERROR | |
Protected Member Functions | |
| int | outputLevel () const |
Protected Attributes | |
| IntegerProperty | m_outputLevel |
| Gaudi::StateMachine::State | m_state |
| Gaudi::StateMachine::State | m_targetState |
| IMessageSvc * | m_messageSvc |
Private Types | |
| typedef GaudiUtils::Map< std::string, std::string > | CondDescMap |
| typedef std::list< CondData > | Conditions |
Private Member Functions | |
| template<class I> | |
| I * | getService (const std::string &name, I *&ptr) const |
| Helper function to retrieve a service and cache the pointer to it. | |
| template<class I> | |
| void | release (I *&ptr) const |
| Helper function to release acquired interfaces. | |
| IDataProviderSvc * | eventSvc () const |
| Get pointer to the event data service. | |
| IDataProviderSvc * | detectorSvc () const |
| Get pointer to the detector data service. | |
| IIncidentSvc * | incidentSvc () const |
| Get pointer to the incident service. | |
| IUpdateManagerSvc * | updMgrSvc () const |
| Get pointer to the detector data service. | |
| IEventProcessor * | evtProc () const |
| Get pointer to the detector data service. | |
| void | update (CondData &cond) |
| Modify the object opaque address. | |
Private Attributes | |
| CondDescMap | m_condDesc |
| Conditions | m_conditions |
| List of objects to modify. | |
| unsigned long | m_currentRun |
| Current run number. | |
| IDataProviderSvc * | m_evtSvc |
| EventDataSvc, for ODIN. | |
| IDataProviderSvc * | m_detSvc |
| SetectorDataSvc, for the objects to invalidate. | |
| IIncidentSvc * | m_incSvc |
| Incident service, to register as listener. | |
| IUpdateManagerSvc * | m_ums |
| UpdateMangerSvc, to invalidate objects. | |
| IEventProcessor * | m_evtProc |
| Pointer to the event processor in order to be able to stop the run if something goes wrong during the incident handling. | |
Friends | |
| friend class | ServiceManager |
Classes | |
| struct | CondData |
| Class to simplify handling of the objects to modify. More... | |
Definition at line 25 of file RunChangeHandlerSvc.h.
typedef GaudiUtils::Map<std::string,std::string> RunChangeHandlerSvc::CondDescMap [private] |
Definition at line 114 of file RunChangeHandlerSvc.h.
typedef std::list<CondData> RunChangeHandlerSvc::Conditions [private] |
Definition at line 117 of file RunChangeHandlerSvc.h.
| RunChangeHandlerSvc::RunChangeHandlerSvc | ( | const std::string & | name, | |
| ISvcLocator * | svcloc | |||
| ) |
Standard constructor.
Definition at line 26 of file RunChangeHandlerSvc.cpp.
00026 : 00027 Service(name,svcLoc), 00028 m_currentRun(0), 00029 m_evtSvc(0),m_detSvc(0),m_incSvc(0),m_ums(0),m_evtProc(0) 00030 { 00031 declareProperty("Conditions", m_condDesc, 00032 "Map defining what to use to replace the location of the source XML files."); 00033 }
| RunChangeHandlerSvc::~RunChangeHandlerSvc | ( | ) | [virtual] |
| StatusCode RunChangeHandlerSvc::queryInterface | ( | const InterfaceID & | riid, | |
| void ** | ppvUnknown | |||
| ) | [virtual] |
Query interfaces (.
| riid | ID of Interface to be retrieved | |
| ppvUnknown | Pointer to Location for interface pointer |
Implements IIncidentListener.
Definition at line 43 of file RunChangeHandlerSvc.cpp.
00043 { 00044 if ( IIncidentListener::interfaceID().versionMatch(riid) ) { 00045 *ppvUnknown = (IIncidentListener*)this; 00046 addRef(); 00047 return StatusCode::SUCCESS; 00048 } 00049 return Service::queryInterface(riid,ppvUnknown); 00050 }
| StatusCode RunChangeHandlerSvc::initialize | ( | ) | [virtual] |
Initialize Service.
Reimplemented from Service.
Definition at line 55 of file RunChangeHandlerSvc.cpp.
00055 { 00056 // base class initialization 00057 StatusCode sc = Service::initialize(); 00058 if (!sc.isSuccess()) return sc; 00059 // local initialization 00060 MsgStream log(msgSvc(),name()); 00061 log << MSG::DEBUG << "--- initialize ---" << endmsg; 00062 00063 incidentSvc()->addListener(this, IncidentType::RunChange); 00064 // ensure that we can call evtProc() and updMgrSvc() while in handle 00065 evtProc(); 00066 updMgrSvc(); 00067 00068 // Prepare the list of conditions 00069 CondDescMap::iterator condDesc; 00070 for (condDesc = m_condDesc.begin(); condDesc != m_condDesc.end(); ++condDesc) { 00071 m_conditions.push_back(CondData(detectorSvc(),condDesc->first,condDesc->second)); 00072 updMgrSvc()->registerCondition(this,condDesc->first); 00073 } 00074 // FIXME: (MCl) This is a hack to be sure that the UMS knows about all the 00075 // objects we have to modify before we get to the first event. 00076 return updMgrSvc()->update(this); 00077 }
| StatusCode RunChangeHandlerSvc::finalize | ( | ) | [virtual] |
Finalize Service.
Reimplemented from Service.
Definition at line 82 of file RunChangeHandlerSvc.cpp.
00082 { 00083 // local finalization 00084 MsgStream log(msgSvc(),name()); 00085 log << MSG::DEBUG << "--- finalize ---" << endmsg; 00086 00087 if (m_incSvc) 00088 incidentSvc()->removeListener(this, IncidentType::RunChange); 00089 00090 // release acquired interfaces 00091 release(m_evtSvc); 00092 release(m_detSvc); 00093 release(m_incSvc); 00094 release(m_ums); 00095 release(m_evtProc); 00096 00097 // base class finalization 00098 return Service::finalize(); 00099 }
| void RunChangeHandlerSvc::handle | ( | const Incident & | inc | ) | [virtual] |
Handle RunChange incident.
Implements IIncidentListener.
Definition at line 104 of file RunChangeHandlerSvc.cpp.
00104 { 00105 MsgStream log( msgSvc(), name() ); 00106 log << MSG::DEBUG << inc.type() << " incident received" << endmsg; 00107 00108 const RunChangeIncident* rci = dynamic_cast<const RunChangeIncident*>(&inc); 00109 if (!rci) { 00110 log << MSG::ERROR << "Cannot dynamic_cast the incident to RunChangeIncident, " 00111 " run change ignored" << endmsg; 00112 return; 00113 } 00114 00115 if (m_currentRun != rci->runNumber()) { 00116 log << MSG::DEBUG << "Change of run number detected " << m_currentRun; 00117 m_currentRun = rci->runNumber(); 00118 log << "->" << m_currentRun << endmsg; 00119 00120 // loop over the object to update 00121 Conditions::iterator cond; 00122 for (cond = m_conditions.begin(); cond != m_conditions.end(); ++cond) { 00123 update(*cond); 00124 } 00125 } 00126 }
| I* RunChangeHandlerSvc::getService | ( | const std::string & | name, | |
| I *& | ptr | |||
| ) | const [inline, private] |
Helper function to retrieve a service and cache the pointer to it.
Definition at line 56 of file RunChangeHandlerSvc.h.
00056 { 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 }
| void RunChangeHandlerSvc::release | ( | I *& | ptr | ) | const [inline, private] |
Helper function to release acquired interfaces.
Definition at line 68 of file RunChangeHandlerSvc.h.
| IDataProviderSvc* RunChangeHandlerSvc::eventSvc | ( | ) | const [inline, private] |
Get pointer to the event data service.
Definition at line 76 of file RunChangeHandlerSvc.h.
00076 { 00077 return getService("EventDataSvc",m_evtSvc); 00078 }
| IDataProviderSvc* RunChangeHandlerSvc::detectorSvc | ( | ) | const [inline, private] |
Get pointer to the detector data service.
Definition at line 81 of file RunChangeHandlerSvc.h.
00081 { 00082 return getService("DetectorDataSvc",m_detSvc); 00083 }
| IIncidentSvc* RunChangeHandlerSvc::incidentSvc | ( | ) | const [inline, private] |
Get pointer to the incident service.
Definition at line 86 of file RunChangeHandlerSvc.h.
00086 { 00087 return getService("IncidentSvc",m_incSvc); 00088 }
| IUpdateManagerSvc* RunChangeHandlerSvc::updMgrSvc | ( | ) | const [inline, private] |
Get pointer to the detector data service.
Definition at line 91 of file RunChangeHandlerSvc.h.
00091 { 00092 return getService("UpdateManagerSvc",m_ums); 00093 }
| IEventProcessor* RunChangeHandlerSvc::evtProc | ( | ) | const [inline, private] |
Get pointer to the detector data service.
Definition at line 96 of file RunChangeHandlerSvc.h.
00096 { 00097 return getService("ApplicationMgr",m_evtProc); 00098 }
| void RunChangeHandlerSvc::update | ( | CondData & | cond | ) | [private] |
Modify the object opaque address.
Definition at line 131 of file RunChangeHandlerSvc.cpp.
00131 { 00132 // get the object and its registry 00133 if (cond.object) { 00134 IRegistry *reg = cond.object->registry(); 00135 if (reg) { 00136 // get the opaque address 00137 IOpaqueAddress *addr = reg->address(); 00138 if (addr) { 00139 // This is a bit of a hack, but it is the only way of replacing the 00140 // URL to use for an object. 00141 std::string* par = const_cast<std::string*>(addr->par()); 00142 par[0] = (boost::format(cond.pathTemplate) % m_currentRun).str(); 00143 // notify the UMS and the object that they have to be updated. 00144 cond.object->forceUpdateMode(); 00145 updMgrSvc()->invalidate(cond.object.ptr()); 00146 // exit to avoid the trap at the end of the function 00147 return; 00148 } 00149 } 00150 } 00151 // If we get here, it means that we cannot manipulate the address 00152 evtProc()->stopRun(); // schedule a stop 00153 throw GaudiException("Cannot modify address for object at " + cond.object.path(), name(), StatusCode::FAILURE); 00154 }
CondDescMap RunChangeHandlerSvc::m_condDesc [private] |
Definition at line 115 of file RunChangeHandlerSvc.h.
Conditions RunChangeHandlerSvc::m_conditions [private] |
unsigned long RunChangeHandlerSvc::m_currentRun [private] |
IDataProviderSvc* RunChangeHandlerSvc::m_evtSvc [mutable, private] |
IDataProviderSvc* RunChangeHandlerSvc::m_detSvc [mutable, private] |
SetectorDataSvc, for the objects to invalidate.
Definition at line 128 of file RunChangeHandlerSvc.h.
IIncidentSvc* RunChangeHandlerSvc::m_incSvc [mutable, private] |
IUpdateManagerSvc* RunChangeHandlerSvc::m_ums [mutable, private] |
IEventProcessor* RunChangeHandlerSvc::m_evtProc [mutable, private] |
Pointer to the event processor in order to be able to stop the run if something goes wrong during the incident handling.
Definition at line 138 of file RunChangeHandlerSvc.h.
1.4.7