Gaudi Framework, version v23r7

Home   Generated: Wed Mar 20 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DataSvcFileEntriesTool Class Reference

Tool to scan a transient store branch that collects all the objects that belong to the same source (file). More...

Inheritance diagram for DataSvcFileEntriesTool:
Inheritance graph
[legend]
Collaboration diagram for DataSvcFileEntriesTool:
Collaboration graph
[legend]

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.
 
- Public Member Functions inherited from extends2< AlgTool, IDataStoreLeaves, IIncidentListener >
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends2 (A1 a1)
 Templated constructor with 1 argument.
 
 extends2 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends2 ()
 Virtual destructor.
 
- Public Member Functions inherited from AlgTool
virtual const std::stringname () const
 Retrieve full identifying name of the concrete tool object.
 
virtual const std::stringtype () const
 Retrieve type (concrete class) of the sub-algtool.
 
virtual const IInterfaceparent () const
 Retrieve parent of the sub-algtool.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode sysInitialize ()
 Initialize AlgTool.
 
virtual StatusCode sysStart ()
 Start AlgTool.
 
virtual StatusCode sysStop ()
 Stop AlgTool.
 
virtual StatusCode sysFinalize ()
 Finalize AlgTool.
 
virtual StatusCode sysReinitialize ()
 Initialize AlgTool.
 
virtual StatusCode sysRestart ()
 Start AlgTool.
 
virtual StatusCode setProperty (const Property &p)
 Default implementations for IProperty interface.
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
PropertyMgrgetPropertyMgr ()
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 AlgTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Constructor.
 
ISvcLocatorserviceLocator () const
 Retrieve pointer to service locator.
 
ISvcLocatorsvcLoc () const
 shortcut for the method service locator
 
IMessageSvcmsgSvc () const
 Retrieve pointer to message service.
 
IToolSvctoolSvc () const
 The standard ToolSvc service, Return a pointer to the service if present.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified in the jobOptions via the job option service.
 
template<class T >
StatusCode service (const std::string &name, T *&svc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
 
template<class T >
StatusCode service (const std::string &type, const std::string &name, T *&svc) const
 Access a service by name, type creating it if it doesn't already exist.
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true, const bool quiet=false) const
 Return a pointer to the service identified by name (or "type/name")
 
void declInterface (const InterfaceID &, void *)
 declare interface
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
IAuditorSvcauditorSvc () const
 Access the auditor service.
 
IMonitorSvcmonitorSvc () const
 Access the monitor service.
 
template<class T >
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
 Declare monitoring information.
 
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
 Declare monitoring information (special case)
 
- Public Member Functions inherited from extend_interfaces2< I1, I2 >
virtual ~extend_interfaces2 ()
 Virtual destructor.
 

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.
 
IRegistryi_getRootNode ()
 Return the pointer to the IRegistry object associated to the node specified as Root.
 

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< IIncidentSvcm_incidentSvc
 Pointer to the incident service.
 
SmartIF< IDataManagerSvcm_dataMgrSvc
 Pointer to the IDataManagerSvc interface of the data service.
 
SmartIF< IDataProviderSvcm_dataSvc
 Pointer to the IDataProviderSvc interface of the data service.
 
LeavesList m_leaves
 Internal cache for the list of objects found during the scan.
 
std::string m_initialBase
 File ID of the Root node.
 
bool m_ignoreOriginChange
 Variable for the property ScanOnBeginEvent.
 

Additional Inherited Members

- Public Types inherited from extends2< AlgTool, IDataStoreLeaves, IIncidentListener >
typedef extends2 base_class
 Typedef to this class.
 
typedef extend_interfaces2
< IDataStoreLeaves,
IIncidentListener
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Protected Member Functions inherited from AlgTool
int outputLevel () const
 get tool's output level
 
IntegerPropertyoutputLevelProperty ()
 Accessor for the Message level property.
 
void initOutputLevel (Property &prop)
 callback for output level property
 
virtual ~AlgTool ()
 

Detailed Description

Tool to scan a transient store branch that collects all the objects that belong to the same source (file).

By default, the list of entries is cached and the cache is cleared at every BeginEvent incident.

Properties:
DataService (string): Name of the data service to use [EventDataSvc]
Root (string): Path to the element from which to start the scan [root of the data service]
ScanOnBeginEvent (bool): If the scan has to be started during the BeginEvent incident (true) or on demand (false, default)

Definition at line 26 of file DataSvcFileEntriesTool.cpp.

Constructor & Destructor Documentation

DataSvcFileEntriesTool::DataSvcFileEntriesTool ( const std::string type,
const std::string name,
const IInterface parent 
)

Standard constructor.

Definition at line 102 of file DataSvcFileEntriesTool.cpp.

:
base_class(type, name, parent) {
declareProperty("DataService", m_dataSvcName = "EventDataSvc",
"Name of the data service to use");
"Path to the element from which to start the scan");
declareProperty("ScanOnBeginEvent", m_scanOnBeginEvent = false,
"If the scan has to be started during the BeginEvent incident (true) or on demand (false, default)");
declareProperty("IgnoreOriginChange", m_ignoreOriginChange = false,
"Disable the detection of the change in the origin of object between the BeginEvent and the scan");
}
DataSvcFileEntriesTool::~DataSvcFileEntriesTool ( )
virtual

Destructor.

Definition at line 120 of file DataSvcFileEntriesTool.cpp.

{}

Member Function Documentation

StatusCode DataSvcFileEntriesTool::finalize ( )
virtual

Finalize the tool.

Reimplemented from AlgTool.

Definition at line 155 of file DataSvcFileEntriesTool.cpp.

{
// unregister from the incident service
m_incidentSvc->removeListener(this, IncidentType::BeginEvent);
}
// Release the services
}
void DataSvcFileEntriesTool::handle ( const Incident incident)
virtual

Call-back function for the BeginEvent incident.

Clears the internal cache, cache the file ID of the Root node and, if the property ScanOnBeginEvent is set to true, scans the data service.

Definition at line 168 of file DataSvcFileEntriesTool.cpp.

{
// Get the file id of the root node at every event
if (addr)
m_initialBase = addr->par()[0];
else
m_initialBase.clear(); // use empty file id if there is no address
m_leaves.clear();
log << MSG::VERBOSE << "::handle scanning on " << incident.type() << endmsg;
}
}
void DataSvcFileEntriesTool::i_collectLeaves ( )
private

Scan the data service starting from the node specified as Root.

Definition at line 201 of file DataSvcFileEntriesTool.cpp.

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 206 of file DataSvcFileEntriesTool.cpp.

{
// I do not put sanity checks on the pointers because I know how I'm calling the function
IOpaqueAddress *addr = reg->address();
if (addr) { // we consider only objects that are in a file
log << MSG::VERBOSE << "::i_collectLeaves added " << reg->identifier() << endmsg;
m_leaves.push_back(reg->object()); // add this object
// Origin of the current object
const std::string& base = addr->par()[0];
// Compare with the origin seen during BeginEvent
if ( !m_ignoreOriginChange && (m_initialBase != base) )
throw GaudiException("Origin of data has changed ('"
+ m_initialBase + "' != '" + base
+ "'), probably OutputStream was called before "
"InputCopyStream: check options",
std::vector<IRegistry*> lfs; // leaves of the current object
StatusCode sc = m_dataMgrSvc->objectLeaves(reg, lfs);
if (sc.isSuccess()) {
for(std::vector<IRegistry*>::iterator i = lfs.begin(); i != lfs.end(); ++i) {
// Continue if the leaf has the same database as the parent
if ( (*i)->address() && (*i)->address()->par()[0] == base ) {
DataObject* obj = 0;
sc = m_dataSvc->retrieveObject(reg, (*i)->name(), obj);
if (sc.isSuccess()) {
} else {
throw GaudiException("Cannot get " + (*i)->identifier() + " from " + m_dataSvcName, name(), StatusCode::FAILURE);
}
}
}
}
}
}
IRegistry * DataSvcFileEntriesTool::i_getRootNode ( )
private

Return the pointer to the IRegistry object associated to the node specified as Root.

Definition at line 191 of file DataSvcFileEntriesTool.cpp.

{
DataObject * obj = 0;
StatusCode sc = m_dataSvc->retrieveObject(m_rootNode, obj);
if (sc.isFailure()) {
throw GaudiException("Cannot get " + m_rootNode + " from " + m_dataSvcName, name(), StatusCode::FAILURE);
}
return obj->registry();
}
StatusCode DataSvcFileEntriesTool::initialize ( )
virtual

Initialize the tool.

Reimplemented from AlgTool.

Definition at line 122 of file DataSvcFileEntriesTool.cpp.

{
if (sc.isFailure()) return sc;
// Retrieve the pointer to the needed services.
m_incidentSvc = serviceLocator()->service("IncidentSvc");
if ( ! m_incidentSvc ) {
log << MSG::ERROR << "Cannot get IncidentSvc" << endmsg;
}
if ( ! m_dataSvc || ! m_dataMgrSvc ) {
log << MSG::ERROR << "Cannot get IDataProviderSvc+IDataManagerSvc " << m_dataSvcName << endmsg;
}
// Register ourself to the incident service as listener for BeginEvent
// If the Root node is not specified, take the name from the data service itself.
if (m_rootNode.empty()) {
m_rootNode = m_dataMgrSvc->rootName();
}
// Clear the cache (in case the instance is re-initilized).
m_leaves.clear();
}
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 184 of file DataSvcFileEntriesTool.cpp.

{
if (m_leaves.empty()) {
const_cast<DataSvcFileEntriesTool*>(this)->i_collectLeaves();
}
return m_leaves;
}

Member Data Documentation

SmartIF<IDataManagerSvc> DataSvcFileEntriesTool::m_dataMgrSvc
private

Pointer to the IDataManagerSvc interface of the data service.

Definition at line 65 of file DataSvcFileEntriesTool.cpp.

SmartIF<IDataProviderSvc> DataSvcFileEntriesTool::m_dataSvc
private

Pointer to the IDataProviderSvc interface of the data service.

Definition at line 67 of file DataSvcFileEntriesTool.cpp.

std::string DataSvcFileEntriesTool::m_dataSvcName
private

Variable for the property DataService.

Definition at line 56 of file DataSvcFileEntriesTool.cpp.

bool DataSvcFileEntriesTool::m_ignoreOriginChange
private

Variable for the property ScanOnBeginEvent.

Definition at line 88 of file DataSvcFileEntriesTool.cpp.

SmartIF<IIncidentSvc> DataSvcFileEntriesTool::m_incidentSvc
private

Pointer to the incident service.

Definition at line 63 of file DataSvcFileEntriesTool.cpp.

std::string DataSvcFileEntriesTool::m_initialBase
private

File ID of the Root node.

It is cached every BeginEvent to be compared with the one seen during the collection of the leaves, to avoid that the collection is altered by previous calls to an OutputStream.

Definition at line 85 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.

std::string DataSvcFileEntriesTool::m_rootNode
private

Variable for the property Root.

Definition at line 58 of file DataSvcFileEntriesTool.cpp.

bool DataSvcFileEntriesTool::m_scanOnBeginEvent
private

Variable for the property ScanOnBeginEvent.

Definition at line 60 of file DataSvcFileEntriesTool.cpp.


The documentation for this class was generated from the following file:
Generated at Wed Mar 20 2013 17:59:43 for Gaudi Framework, version v23r7 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004