| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Member Functions | Private Member Functions | Private Attributes

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

                                   :
       base_class(type, name, parent) {

      declareProperty("DataService", m_dataSvcName = "EventDataSvc",
          "Name of the data service to use");

      declareProperty("Root", m_rootNode,
          "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 | ( | void | ) | `[virtual]`

Finalize the tool.

Reimplemented from AlgTool.

Definition at line 155 of file DataSvcFileEntriesTool.cpp.

                                               {
      // unregister from the incident service
      if (m_incidentSvc) {
        m_incidentSvc->removeListener(this, IncidentType::BeginEvent);
      }
      // Release the services
      m_incidentSvc.reset();
      m_dataMgrSvc.reset();
      m_dataSvc.reset();

      return AlgTool::finalize();
    }

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
      IOpaqueAddress *addr = i_getRootNode()->address();
      if (addr)
        m_initialBase = addr->par()[0];
      else
        m_initialBase.clear(); // use empty file id if there is no address

      m_leaves.clear();
      if (m_scanOnBeginEvent) {
        MsgStream log(msgSvc(), name());
        log << MSG::VERBOSE << "::handle scanning on " << incident.type() << endmsg;
        i_collectLeaves();
      }
    }

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

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

Definition at line 201 of file DataSvcFileEntriesTool.cpp.

                                                 {
      i_collectLeaves(i_getRootNode());
    }

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.

                                                               {
      MsgStream log(msgSvc(), name());
      // 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
        if (outputLevel() <= MSG::VERBOSE)
          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",
                               name(), StatusCode::FAILURE);

        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())  {
                i_collectLeaves(*i);
              } 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 | ( | void | ) | `[virtual]`

Initialize the tool.

Reimplemented from AlgTool.

Definition at line 122 of file DataSvcFileEntriesTool.cpp.

                                                 {
      StatusCode sc = AlgTool::initialize();
      if (sc.isFailure()) return sc;

      // Retrieve the pointer to the needed services.

      m_incidentSvc = serviceLocator()->service("IncidentSvc");
      if ( ! m_incidentSvc ) {
        MsgStream log(msgSvc(), name());
        log << MSG::ERROR << "Cannot get IncidentSvc" << endmsg;
        return StatusCode::FAILURE;
      }

      m_dataMgrSvc = m_dataSvc = serviceLocator()->service(m_dataSvcName);
      if ( ! m_dataSvc || ! m_dataMgrSvc ) {
        MsgStream log(msgSvc(), name());
        log << MSG::ERROR << "Cannot get IDataProviderSvc+IDataManagerSvc " << m_dataSvcName << endmsg;
        return StatusCode::FAILURE;
      }

      // Register ourself to the incident service as listener for BeginEvent
      m_incidentSvc->addListener(this, IncidentType::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();
      return StatusCode::SUCCESS;
    }

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:

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

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