|
Gaudi Framework, version v21r11 |
| Home | Generated: 30 Sep 2010 |
Public Member Functions | |
| DataSvcFileEntriesTool (const std::string &type, const std::string &name, const IInterface *parent) | |
| Standard constructor. | |
| virtual | ~DataSvcFileEntriesTool () |
| Destructor. | |
| virtual StatusCode | initialize () |
| Initialize the tool. | |
| virtual StatusCode | finalize () |
| Finalize the tool. | |
| virtual const LeavesList & | leaves () const |
| Return the list of collected objects. | |
| virtual void | handle (const Incident &incident) |
| Call-back function for the BeginEvent incident. | |
Private Member Functions | |
| void | i_collectLeaves () |
| Scan the data service starting from the node specified as Root. | |
| void | i_collectLeaves (IRegistry *reg) |
| Scan the data service starting from the specified node. | |
Private Attributes | |
| std::string | m_dataSvcName |
| Variable for the property DataService. | |
| std::string | m_rootNode |
| Variable for the property Root. | |
| bool | m_scanOnBeginEvent |
| Variable for the property ScanOnBeginEvent. | |
| SmartIF< IIncidentSvc > | m_incidentSvc |
| Pointer to the incident service. | |
| SmartIF< IDataManagerSvc > | m_dataMgrSvc |
| Pointer to the IDataManagerSvc interface of the data service. | |
| SmartIF< IDataProviderSvc > | m_dataSvc |
| Pointer to the IDataProviderSvc interface of the data service. | |
| LeavesList | m_leaves |
| Internal cache for the list of objects found during the scan. | |
By default, the list of entries is cached and the cache is cleared at every BeginEvent incident.
Definition at line 26 of file DataSvcFileEntriesTool.cpp.
| DataSvcFileEntriesTool::DataSvcFileEntriesTool | ( | const std::string & | type, | |
| const std::string & | name, | |||
| const IInterface * | parent | |||
| ) |
Standard constructor.
Definition at line 89 of file DataSvcFileEntriesTool.cpp.
00091 : 00092 base_class(type, name, parent) { 00093 00094 declareProperty("DataService", m_dataSvcName = "EventDataSvc", 00095 "Name of the data service to use"); 00096 00097 declareProperty("Root", m_rootNode, 00098 "Path to the element from which to start the scan"); 00099 00100 declareProperty("ScanOnBeginEvent", m_scanOnBeginEvent = false, 00101 "If the scan has to be started during the BeginEvent incident (true) or on demand (false, default)"); 00102 }
| DataSvcFileEntriesTool::~DataSvcFileEntriesTool | ( | ) | [virtual] |
| StatusCode DataSvcFileEntriesTool::initialize | ( | ) | [virtual] |
Initialize the tool.
Reimplemented from AlgTool.
Definition at line 106 of file DataSvcFileEntriesTool.cpp.
00106 { 00107 StatusCode sc = AlgTool::initialize(); 00108 if (sc.isFailure()) return sc; 00109 00110 // Retrieve the pointer to the needed services. 00111 00112 m_incidentSvc = serviceLocator()->service("IncidentSvc"); 00113 if ( ! m_incidentSvc ) { 00114 MsgStream log(msgSvc(), name()); 00115 log << MSG::ERROR << "Cannot get IncidentSvc" << endmsg; 00116 return StatusCode::FAILURE; 00117 } 00118 00119 m_dataMgrSvc = m_dataSvc = serviceLocator()->service(m_dataSvcName); 00120 if ( ! m_dataSvc || ! m_dataMgrSvc ) { 00121 MsgStream log(msgSvc(), name()); 00122 log << MSG::ERROR << "Cannot get IDataProviderSvc+IDataManagerSvc " << m_dataSvcName << endmsg; 00123 return StatusCode::FAILURE; 00124 } 00125 00126 // Register ourself to the incident service as listener for BeginEvent 00127 m_incidentSvc->addListener(this, IncidentType::BeginEvent); 00128 00129 // If the Root node is not specified, take the name from the data service itself. 00130 if (m_rootNode.empty()) { 00131 m_rootNode = m_dataMgrSvc->rootName(); 00132 } 00133 00134 // Clear the cache (in case the instance is re-initilized). 00135 m_leaves.clear(); 00136 return StatusCode::SUCCESS; 00137 }
| StatusCode DataSvcFileEntriesTool::finalize | ( | ) | [virtual] |
Finalize the tool.
Reimplemented from AlgTool.
Definition at line 139 of file DataSvcFileEntriesTool.cpp.
00139 { 00140 // unregister from the incident service 00141 if (m_incidentSvc) { 00142 m_incidentSvc->removeListener(this, IncidentType::BeginEvent); 00143 } 00144 // Release the services 00145 m_incidentSvc.reset(); 00146 m_dataMgrSvc.reset(); 00147 m_dataSvc.reset(); 00148 00149 return AlgTool::finalize(); 00150 }
| const IDataStoreLeaves::LeavesList & DataSvcFileEntriesTool::leaves | ( | ) | const [virtual] |
Return the list of collected objects.
If the scan was not yet done since the last BeginEvent incident, it is done when calling this function. The result of the scan is cached.
Definition at line 161 of file DataSvcFileEntriesTool.cpp.
00161 { 00162 if (m_leaves.empty()) { 00163 const_cast<DataSvcFileEntriesTool*>(this)->i_collectLeaves(); 00164 } 00165 return m_leaves; 00166 }
| void DataSvcFileEntriesTool::handle | ( | const Incident & | incident | ) | [virtual] |
Call-back function for the BeginEvent incident.
Clears the internal cache and, if the property ScanOnBeginEvent is set to true, scans the data service.
Definition at line 152 of file DataSvcFileEntriesTool.cpp.
00152 { 00153 m_leaves.clear(); 00154 if (m_scanOnBeginEvent) { 00155 MsgStream log(msgSvc(), name()); 00156 log << MSG::VERBOSE << "::handle scanning on " << incident.type() << endmsg; 00157 i_collectLeaves(); 00158 } 00159 }
| void DataSvcFileEntriesTool::i_collectLeaves | ( | ) | [private] |
Scan the data service starting from the node specified as Root.
Definition at line 168 of file DataSvcFileEntriesTool.cpp.
00168 { 00169 DataObject * obj = 0; 00170 StatusCode sc = m_dataSvc->retrieveObject(m_rootNode, obj); 00171 if (sc.isSuccess()) { 00172 MsgStream log(msgSvc(), name()); 00173 log << MSG::DEBUG << "::i_collectLeaves scanning " << m_dataSvcName 00174 << " from " << m_rootNode << endmsg; 00175 i_collectLeaves(obj->registry()); 00176 } else { 00177 throw GaudiException("Cannot get " + m_rootNode + " from " + m_dataSvcName, name(), StatusCode::FAILURE); 00178 } 00179 }
| void DataSvcFileEntriesTool::i_collectLeaves | ( | IRegistry * | reg | ) | [private] |
Scan the data service starting from the specified node.
todo: implement the scanning as an IDataStoreAgent
Definition at line 182 of file DataSvcFileEntriesTool.cpp.
00182 { 00183 MsgStream log(msgSvc(), name()); 00184 // I do not put sanity checks on the pointers because I know how I'm calling the function 00185 IOpaqueAddress *addr = reg->address(); 00186 if (addr) { // we consider only objects that are in a file 00187 if (outputLevel() <= MSG::VERBOSE) 00188 log << MSG::VERBOSE << "::i_collectLeaves added " << reg->identifier() << endmsg; 00189 m_leaves.push_back(reg->object()); // add this object 00190 // Origin of the current object 00191 const std::string& base = addr->par()[0]; 00192 00193 std::vector<IRegistry*> lfs; // leaves of the current object 00194 StatusCode sc = m_dataMgrSvc->objectLeaves(reg, lfs); 00195 if (sc.isSuccess()) { 00196 for(std::vector<IRegistry*>::iterator i = lfs.begin(); i != lfs.end(); ++i) { 00197 // Continue if the leaf has the same database as the parent 00198 if ( (*i)->address() && (*i)->address()->par()[0] == base ) { 00199 DataObject* obj = 0; 00200 sc = m_dataSvc->retrieveObject(reg, (*i)->name(), obj); 00201 if (sc.isSuccess()) { 00202 i_collectLeaves(*i); 00203 } else { 00204 throw GaudiException("Cannot get " + (*i)->identifier() + " from " + m_dataSvcName, name(), StatusCode::FAILURE); 00205 } 00206 } 00207 } 00208 } 00209 } 00210 }
bool DataSvcFileEntriesTool::m_scanOnBeginEvent [private] |
Variable for the property ScanOnBeginEvent.
Definition at line 60 of file DataSvcFileEntriesTool.cpp.
Pointer to the IDataManagerSvc interface of the data service.
Definition at line 65 of file DataSvcFileEntriesTool.cpp.
Pointer to the IDataProviderSvc interface of the data service.
Definition at line 67 of file DataSvcFileEntriesTool.cpp.
LeavesList DataSvcFileEntriesTool::m_leaves [private] |
Internal cache for the list of objects found during the scan.
Definition at line 70 of file DataSvcFileEntriesTool.cpp.