| # Gaudi Framework, version v22r0 |

Home |  | Generated: 9 Feb 2011

# 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:
[legend]
Collaboration diagram for DataSvcFileEntriesTool:
[legend]

List of all members.

## 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.
IRegistry * | i_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< 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.
std::string | m_initialBase
| File ID of the Root node.
bool | m_ignoreOriginChange
| Variable for the property ScanOnBeginEvent.

## 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.

    00105                                :
    00106    base_class(type, name, parent) {
    00107
    00108   declareProperty("DataService", m_dataSvcName = "EventDataSvc",
    00109       "Name of the data service to use");
    00110
    00111   declareProperty("Root", m_rootNode,
    00112       "Path to the element from which to start the scan");
    00113
    00114   declareProperty("ScanOnBeginEvent", m_scanOnBeginEvent = false,
    00115       "If the scan has to be started during the BeginEvent incident (true) or on demand (false, default)");
    00116
    00117   declareProperty("IgnoreOriginChange", m_ignoreOriginChange = false,
    00118       "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.

    00120 {}

## Member Function Documentation

StatusCode DataSvcFileEntriesTool::finalize | ( |  | ) | `[virtual]`

Finalize the tool.

Reimplemented from AlgTool.

Definition at line 155 of file DataSvcFileEntriesTool.cpp.

    00155                                            {
    00156   // unregister from the incident service
    00157   if (m_incidentSvc) {
    00158     m_incidentSvc->removeListener(this, IncidentType::BeginEvent);
    00159   }
    00160   // Release the services
    00161   m_incidentSvc.reset();
    00162   m_dataMgrSvc.reset();
    00163   m_dataSvc.reset();
    00164
    00165   return AlgTool::finalize();
    00166 }

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.

    00168                                                             {
    00169   // Get the file id of the root node at every event
    00170   IOpaqueAddress *addr = i_getRootNode()->address();
    00171   if (addr)
    00172     m_initialBase = addr->par()[0];
    00173   else
    00174     m_initialBase.clear(); // use empty file id if there is no address
    00175
    00176   m_leaves.clear();
    00177   if (m_scanOnBeginEvent) {
    00178     MsgStream log(msgSvc(), name());
    00179     log << MSG::VERBOSE << "::handle scanning on " << incident.type() << endmsg;
    00180     i_collectLeaves();
    00181   }
    00182 }

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.

    00206                                                            {
    00207   MsgStream log(msgSvc(), name());
    00208   // I do not put sanity checks on the pointers because I know how I'm calling the function
    00209   IOpaqueAddress *addr = reg->address();
    00210   if (addr) { // we consider only objects that are in a file
    00211     if (outputLevel() <= MSG::VERBOSE)
    00212       log << MSG::VERBOSE << "::i_collectLeaves added " << reg->identifier() << endmsg;
    00213     m_leaves.push_back(reg->object()); // add this object
    00214     // Origin of the current object
    00215     const std::string& base = addr->par()[0];
    00216     // Compare with the origin seen during BeginEvent
    00217     if ( !m_ignoreOriginChange && (m_initialBase != base) )
    00218       throw GaudiException("Origin of data has changed ('"
    00219                            + m_initialBase + "' !=  '" + base
    00220                            + "'), probably OutputStream was called before "
    00221                                "InputCopyStream: check options",
    00222                            name(), StatusCode::FAILURE);
    00223
    00224     std::vector<IRegistry*> lfs; // leaves of the current object
    00225     StatusCode sc = m_dataMgrSvc->objectLeaves(reg, lfs);
    00226     if (sc.isSuccess()) {
    00227       for(std::vector<IRegistry*>::iterator i = lfs.begin(); i != lfs.end(); ++i)  {
    00228         // Continue if the leaf has the same database as the parent
    00229         if ( (*i)->address() && (*i)->address()->par()[0] == base )  {
    00230           DataObject* obj = 0;
    00231           sc = m_dataSvc->retrieveObject(reg, (*i)->name(), obj);
    00232           if (sc.isSuccess())  {
    00233             i_collectLeaves(*i);
    00234           } else {
    00235             throw GaudiException("Cannot get " + (*i)->identifier() + " from " + m_dataSvcName, name(), StatusCode::FAILURE);
    00236           }
    00237         }
    00238       }
    00239     }
    00240   }
    00241 }

void DataSvcFileEntriesTool::i_collectLeaves | ( |  | ) | `[private]`

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

Definition at line 201 of file DataSvcFileEntriesTool.cpp.

    00201                                              {
    00202   i_collectLeaves(i_getRootNode());
    00203 }

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.

    00191                                                  {
    00192   DataObject * obj = 0;
    00193   StatusCode sc = m_dataSvc->retrieveObject(m_rootNode, obj);
    00194   if (sc.isFailure()) {
    00195     throw GaudiException("Cannot get " + m_rootNode + " from " + m_dataSvcName, name(), StatusCode::FAILURE);
    00196   }
    00197   return obj->registry();
    00198 }

StatusCode DataSvcFileEntriesTool::initialize | ( |  | ) | `[virtual]`

Initialize the tool.

Reimplemented from AlgTool.

Definition at line 122 of file DataSvcFileEntriesTool.cpp.

    00122                                              {
    00123   StatusCode sc = AlgTool::initialize();
    00124   if (sc.isFailure()) return sc;
    00125
    00126   // Retrieve the pointer to the needed services.
    00127
    00128   m_incidentSvc = serviceLocator()->service("IncidentSvc");
    00129   if ( ! m_incidentSvc ) {
    00130     MsgStream log(msgSvc(), name());
    00131     log << MSG::ERROR << "Cannot get IncidentSvc" << endmsg;
    00132     return StatusCode::FAILURE;
    00133   }
    00134
    00135   m_dataMgrSvc = m_dataSvc = serviceLocator()->service(m_dataSvcName);
    00136   if ( ! m_dataSvc || ! m_dataMgrSvc ) {
    00137     MsgStream log(msgSvc(), name());
    00138     log << MSG::ERROR << "Cannot get IDataProviderSvc+IDataManagerSvc " << m_dataSvcName << endmsg;
    00139     return StatusCode::FAILURE;
    00140   }
    00141
    00142   // Register ourself to the incident service as listener for BeginEvent
    00143   m_incidentSvc->addListener(this, IncidentType::BeginEvent);
    00144
    00145   // If the Root node is not specified, take the name from the data service itself.
    00146   if (m_rootNode.empty()) {
    00147     m_rootNode = m_dataMgrSvc->rootName();
    00148   }
    00149
    00150   // Clear the cache (in case the instance is re-initilized).
    00151   m_leaves.clear();
    00152   return StatusCode::SUCCESS;
    00153 }

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.

    00184                                                                         {
    00185   if (m_leaves.empty()) {
    00186     const_cast<DataSvcFileEntriesTool*>(this)->i_collectLeaves();
    00187   }
    00188   return m_leaves;
    00189 }

## 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:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r0/GaudiSvc/src/PersistencySvc/DataSvcFileEntriesTool.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines