| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# RecordDataSvc Class Reference

A RecordDataSvc is the base class for event services. More...

`#include <RecordDataSvc.h>`

Inheritance diagram for RecordDataSvc:

[legend]
Collaboration diagram for RecordDataSvc:

[legend]

List of all members.

## Public Member Functions
virtual StatusCode | initialize ()
| Service initialisation.
virtual StatusCode | reinitialize ()
| Service reinitialisation.
virtual StatusCode | finalize ()
| Service finalization.
virtual void | handle (const Incident &incident)
| IIncidentListener override: Inform that a new incident has occured.
| RecordDataSvc (const std::string &name, ISvcLocator *svc)
| Standard Constructor.
virtual | ~RecordDataSvc ()
| Standard Destructor.
## Protected Types
typedef std::vector< std::string > | StringV
## Protected Member Functions
void | registerRecord (const std::string &data, IOpaqueAddress *pAddr)
| Load new record into the data store if necessary.
void | loadRecords (IRegistry *pReg)
| Load dependent records into memory.
## Protected Attributes
bool | m_autoLoad
| Property: autoload of records (default: true).
std::string | m_incidentName
| Property: name of incident to be fired if new record arrives.
std::string | m_saveIncidentName
| Property: name of the "save" incident.
std::string | m_persSvcName
| Property: name of the persistency service.
StringV | m_incidents
| Pending new file incidents.
IConversionSvc * | m_cnvSvc
| Reference to the main data conversion service.
## Friends
class | SvcFactory< RecordDataSvc >

## Detailed Description

A RecordDataSvc is the base class for event services.

When a new datafile is opened the data service retrieves an incident from the persistency area (currently only from POOL) together with an opaque address describing the record. These history records are put onto the run-records datastore under the name of the logical file (FID): /Records/<FID>/.....

Hence, each history records can be addresses the same way: /Record/<FID> (/EOR)

Author:
  M.Frank

Version:
  1.0

Definition at line 26 of file RecordDataSvc.h.

## Member Typedef Documentation

typedef std::vector<std::string> RecordDataSvc::StringV`[protected]`

Definition at line 29 of file RecordDataSvc.h.

## Constructor & Destructor Documentation

RecordDataSvc::RecordDataSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc |
| ) |  |  |

Standard Constructor.

Definition at line 173 of file RecordDataSvc.cpp.

    00174 : base_class(name,svc), m_cnvSvc(0)
    00175 {
    00176   m_rootName = "/Records";
    00177   declareProperty("AutoLoad",       m_autoLoad = true);
    00178   declareProperty("IncidentName",   m_incidentName = "");
    00179   declareProperty("SaveIncident",   m_saveIncidentName = "SAVE_RECORD");
    00180   declareProperty("PersistencySvc", m_persSvcName = "PersistencySvc/RecordPersistencySvc");
    00181 }

RecordDataSvc::~RecordDataSvc | ( |  | ) | `[virtual]`

Standard Destructor.

Definition at line 184 of file RecordDataSvc.cpp.

    00184                                {
    00185 }

## Member Function Documentation

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

Service initialisation.

We need to subscribe to 2 incident: 1) FILE_OPEN_READ: fired by conversion service on open file 2) IncidentType::BeginEvent fired by event loop BEFORE the event processing starts. Do everything to bootstract access to the old event record.

Reimplemented from DataSvc.

Definition at line 40 of file RecordDataSvc.cpp.

    00040                                         {
    00041   // Nothing to do: just call base class initialisation
    00042   StatusCode      sc  = DataSvc::initialize();
    00043   MsgStream log(msgSvc(),name());
    00044
    00045   if ( !sc.isSuccess() ) { // Base class failure
    00046     return sc;
    00047   }
    00048   // Attach data loader facility
    00049   sc = service(m_persSvcName, m_cnvSvc, true);
    00050   if ( !sc.isSuccess() ) {
    00051     log << MSG::ERROR << "Failed to access RecordPersistencySvc." << endmsg;
    00052     return sc;
    00053   }
    00054   SmartIF<IProperty> prp(m_cnvSvc);
    00055   if ( prp ) {
    00056     //prp->setProperty();
    00057   }
    00058   sc = setDataLoader( m_cnvSvc );
    00059   if ( !sc.isSuccess() ) {
    00060     log << MSG::ERROR << "Failed to attach dataloader RecordPersistencySvc." << endmsg;
    00061     return sc;
    00062   }
    00063
    00064   sc = setRoot(m_rootName, new DataObject());
    00065   if( !sc.isSuccess() )  {
    00066     log << MSG::WARNING << "Error declaring Record root DataObject" << endmsg;
    00067     return sc;
    00068   }
    00069
    00070   if( !m_incidentSvc )  {
    00071     log << MSG::FATAL << "IncidentSvc is invalid--base class failed." << endmsg;
    00072     return sc;
    00073   }
    00074
    00079   m_incidentSvc->addListener(this,IncidentType::BeginEvent);
    00080   m_incidentSvc->addListener(this,"FILE_OPEN_READ");
    00081   m_incidentSvc->addListener(this,m_saveIncidentName);
    00082   return sc;
    00083 }

StatusCode RecordDataSvc::reinitialize | ( |  | ) | `[virtual]`

Service reinitialisation.

Reimplemented from DataSvc.

Definition at line 86 of file RecordDataSvc.cpp.

    00086                                           {
    00087   // Do nothing for this service
    00088   return StatusCode::SUCCESS;
    00089 }

StatusCode RecordDataSvc::finalize | ( | void |  | ) | `[virtual]`

Service finalization.

Reimplemented from DataSvc.

Definition at line 92 of file RecordDataSvc.cpp.

    00092                                       {
    00093   if( m_incidentSvc ) m_incidentSvc->removeListener(this);
    00094   if( m_cnvSvc ) m_cnvSvc->release();
    00095   m_cnvSvc = 0;
    00096   DataSvc::finalize().ignore();
    00097   return StatusCode::SUCCESS ;
    00098 }

void RecordDataSvc::handle | ( | const Incident & | incident | ) | `[virtual]`

IIncidentListener override: Inform that a new incident has occured.

Inform that a new incident has occured.

Implements IIncidentListener.

Definition at line 101 of file RecordDataSvc.cpp.

    00101                                                    {
    00102   if ( incident.type() == "FILE_OPEN_READ" ) {
    00103     typedef ContextIncident<IOpaqueAddress*> Ctxt;
    00104     const Ctxt* inc = dynamic_cast<const Ctxt*>(&incident);
    00105     if ( inc ) {
    00106       registerRecord(inc->source(),inc->tag());
    00107       return;
    00108     }
    00109     MsgStream log(msgSvc(),name());
    00110     log << MSG::ALWAYS << "Received invalid incident of type:" << incident.type() << endmsg;
    00111   }
    00112   else if ( incident.type() == IncidentType::BeginEvent ) {
    00113     if ( !m_incidentName.empty() ) {
    00114       StringV incidents(m_incidents);
    00115       m_incidents.clear();
    00116       for( StringV::const_iterator i=incidents.begin(); i!=incidents.end();++i)
    00117         m_incidentSvc->fireIncident(Incident(*i,m_incidentName));
    00118     }
    00119   }
    00120   else if ( incident.type() == m_saveIncidentName ) {
    00121     MsgStream log(msgSvc(),name());
    00122     log << MSG::ALWAYS << "Saving records not implemented." << endmsg;
    00123   }
    00124 }

void RecordDataSvc::registerRecord | ( | const std::string & | data,
|  | IOpaqueAddress * | pAddr |
| ) |  |  | `[protected]`

Load new record into the data store if necessary.

Load new run record into the data store if necessary.

Definition at line 150 of file RecordDataSvc.cpp.

    00150                                                                               {
    00151   if ( !data.empty() && 0 != pAddr ) {
    00152     MsgStream log(msgSvc(),name());
    00153     string fid = data;
    00154     log << MSG::DEBUG << "Request to load record for file " << fid << endmsg;
    00155     StatusCode sc = registerAddress(m_root,fid,pAddr);
    00156     if ( !sc.isSuccess() ) {
    00157       log << MSG::ERROR << "Failed to register record for:" << fid << endmsg;
    00158       pAddr->release();
    00159       return;
    00160     }
    00161     if ( m_autoLoad ) {
    00162       loadRecords(pAddr->registry());
    00163     }
    00164     m_incidents.push_back(pAddr->registry()->identifier());
    00165   }
    00166   else if ( !data.empty() && 0 == pAddr ) {
    00167     MsgStream log(msgSvc(),name());
    00168     log << MSG::ERROR << "Failed to register run record for:" << data << " [Invalid Address]" << endmsg;
    00169   }
    00170 }

void RecordDataSvc::loadRecords | ( | IRegistry * | pReg | ) | `[protected]`

Load dependent records into memory.

Definition at line 127 of file RecordDataSvc.cpp.

    00127                                                {
    00128   if ( 0 != pObj )    {
    00129     typedef vector<IRegistry*> Leaves;
    00130     Leaves leaves;
    00131     DataObject* p = 0;
    00132     MsgStream log(msgSvc(),name());
    00133     const string& id0 = pObj->identifier();
    00134     StatusCode sc = retrieveObject(id0, p);
    00135     if ( sc.isSuccess() ) {
    00136       log << MSG::DEBUG << "Loaded records object: " << id0 << endmsg;
    00137       sc = objectLeaves(pObj, leaves);
    00138       if ( sc.isSuccess() )  {
    00139         for ( Leaves::const_iterator i=leaves.begin(); i != leaves.end(); i++ )
    00140           loadRecords(*i);
    00141       }
    00142     }
    00143     else  {
    00144       log << MSG::ERROR << "Failed to load records object: " << pObj->identifier() << endmsg;
    00145     }
    00146   }
    00147 }

## Friends And Related Function Documentation

friend class SvcFactory< RecordDataSvc >`[friend]`

Definition at line 27 of file RecordDataSvc.h.

## Member Data Documentation

bool RecordDataSvc::m_autoLoad`[protected]`

Property: autoload of records (default: true).

Definition at line 53 of file RecordDataSvc.h.

std::string RecordDataSvc::m_incidentName`[protected]`

Property: name of incident to be fired if new record arrives.

Definition at line 55 of file RecordDataSvc.h.

std::string RecordDataSvc::m_saveIncidentName`[protected]`

Property: name of the "save" incident.

Definition at line 57 of file RecordDataSvc.h.

std::string RecordDataSvc::m_persSvcName`[protected]`

Property: name of the persistency service.

Definition at line 59 of file RecordDataSvc.h.

StringV RecordDataSvc::m_incidents`[protected]`

Pending new file incidents.

Definition at line 61 of file RecordDataSvc.h.

IConversionSvc* RecordDataSvc::m_cnvSvc`[protected]`

Reference to the main data conversion service.

Definition at line 63 of file RecordDataSvc.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiSvc/src/DataSvc/RecordDataSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiSvc/src/DataSvc/RecordDataSvc.cpp