![]() |
|
|
Generated: 8 Jan 2009 |
00001 // $Id: FastContainersSvc.cpp,v 1.2 2006/11/24 09:56:53 hmd Exp $ 00002 00003 // Include files 00004 #include "GaudiKernel/DataObject.h" 00005 #include "GaudiKernel/MsgStream.h" 00006 #include "GaudiKernel/SvcFactory.h" 00007 #include "GaudiKernel/Incident.h" 00008 #include "GaudiKernel/IIncidentSvc.h" 00009 00010 // local 00011 #include "FastContainersSvc.h" 00012 00013 // Instantiation of a static factory class used by clients to create 00014 // instances of this service 00015 DECLARE_SERVICE_FACTORY(FastContainersSvc) 00016 00017 //----------------------------------------------------------------------------- 00018 // Implementation file for class : FastContainersSvc 00019 // 00020 // 2006-05-03 : Marco Clemencic 00021 //----------------------------------------------------------------------------- 00022 00023 //============================================================================= 00024 // Standard constructor, initializes variables 00025 //============================================================================= 00026 FastContainersSvc::FastContainersSvc(const std::string& name,ISvcLocator* svc): 00027 DataSvc(name,svc) 00028 { 00029 declareProperty("RootDirName", m_rootDirName = "fc" ); 00030 m_rootName = "/" + m_rootDirName; 00031 } 00032 00033 //============================================================================= 00034 // Destructor 00035 //============================================================================= 00036 FastContainersSvc::~FastContainersSvc() {} 00037 00038 //============================================================================= 00039 // Find the appropriate interface 00040 //============================================================================= 00041 StatusCode FastContainersSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) { 00042 00043 if ( IIncidentListener::interfaceID().versionMatch(riid) ) { 00044 *ppvInterface = (IIncidentListener*)this; 00045 } 00046 else { 00047 return DataSvc::queryInterface(riid, ppvInterface); 00048 } 00049 00050 addRef(); 00051 return StatusCode::SUCCESS; 00052 } 00053 00054 //========================================================================= 00055 // Initialization 00056 //========================================================================= 00057 StatusCode FastContainersSvc::initialize() { 00058 // initialize base class 00059 StatusCode status = DataSvc::initialize(); 00060 if (!status.isSuccess()) return status; 00061 00062 MsgStream log(msgSvc(), name()); 00063 // create root node 00064 log << MSG::VERBOSE << "creating root node" << endmsg; 00065 status = setRoot(m_rootName,new DataObject); 00066 if (!status.isSuccess()){ 00067 log << MSG::FATAL << "failed to create the root node" << endmsg; 00068 return status; 00069 } 00070 00071 // register to the incident service 00072 log << MSG::VERBOSE << "registering to the incident service for " << IncidentType::BeginEvent << endmsg; 00073 m_incidentSvc->addListener(this,IncidentType::BeginEvent); 00074 00075 return status; 00076 } 00077 00078 //========================================================================= 00079 // Empty reinitialization 00080 //========================================================================= 00081 StatusCode FastContainersSvc::reinitialize() { 00082 // do nothing 00083 return StatusCode::SUCCESS; 00084 } 00085 00086 //========================================================================= 00087 // Finalize the service 00088 //========================================================================= 00089 StatusCode FastContainersSvc::finalize() { 00090 MsgStream log(msgSvc(), name()); 00091 // de-register to the incident service 00092 log << MSG::VERBOSE << "de-registering from the incident service" << endmsg; 00093 m_incidentSvc->removeListener(this,IncidentType::BeginEvent); 00094 00095 return DataSvc::finalize(); 00096 } 00097 00098 //========================================================================= 00099 // reset all the fast containers in the transient store 00100 //========================================================================= 00101 void FastContainersSvc::resetStore() { 00102 traverseTree(&m_storeResetter).ignore(); 00103 } 00104 00105 //========================================================================= 00106 // handle BeginEvent incident 00107 //========================================================================= 00108 void FastContainersSvc::handle(const Incident& incident) { 00109 if (incident.type() == IncidentType::BeginEvent) 00110 resetStore(); 00111 } 00112 //=============================================================================