| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends

# 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 170 of file RecordDataSvc.cpp.

    : base_class(name,svc), m_cnvSvc(0)
    {
      m_rootName = "/Records";
      declareProperty("AutoLoad",       m_autoLoad = true);
      declareProperty("IncidentName",   m_incidentName = "");
      declareProperty("SaveIncident",   m_saveIncidentName = "SAVE_RECORD");
      declareProperty("PersistencySvc", m_persSvcName = "PersistencySvc/RecordPersistencySvc");
    }

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

Standard Destructor.

Definition at line 181 of file RecordDataSvc.cpp.

                                   {
    }

## Member Function Documentation

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

Service finalization.

Reimplemented from DataSvc.

Definition at line 91 of file RecordDataSvc.cpp.

                                          {
      if( m_incidentSvc ) m_incidentSvc->removeListener(this);
      if( m_cnvSvc ) m_cnvSvc->release();
      m_cnvSvc = 0;
      DataSvc::finalize().ignore();
      return StatusCode::SUCCESS ;
    }

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 100 of file RecordDataSvc.cpp.

                                                       {
      if ( incident.type() == "FILE_OPEN_READ" ) {
        typedef ContextIncident<IOpaqueAddress*> Ctxt;
        const Ctxt* inc = dynamic_cast<const Ctxt*>(&incident);
        if ( inc ) {
          registerRecord(inc->source(),inc->tag());
          if ( !m_incidentName.empty() ) {
            StringV incidents(m_incidents);
            m_incidents.clear();
            for( StringV::const_iterator i=incidents.begin(); i!=incidents.end();++i)
              m_incidentSvc->fireIncident(Incident(*i,m_incidentName));
          }
          return;
        }
        MsgStream log(msgSvc(),name());
        log << MSG::ALWAYS << "Received invalid incident of type:" << incident.type() << endmsg;
      }
      else if ( incident.type() == m_saveIncidentName ) {
        MsgStream log(msgSvc(),name());
        log << MSG::ALWAYS << "Saving records not implemented." << endmsg;
      }
    }

StatusCode RecordDataSvc::initialize | ( | void | ) | `[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.

                                            {
      // Nothing to do: just call base class initialisation
      StatusCode      sc  = DataSvc::initialize();
      MsgStream log(msgSvc(),name());

      if ( !sc.isSuccess() ) { // Base class failure
        return sc;
      }
      // Attach data loader facility
      sc = service(m_persSvcName, m_cnvSvc, true);
      if ( !sc.isSuccess() ) {
        log << MSG::ERROR << "Failed to access RecordPersistencySvc." << endmsg;
        return sc;
      }
      SmartIF<IProperty> prp(m_cnvSvc);
      if ( prp ) {
        //prp->setProperty();
      }
      sc = setDataLoader( m_cnvSvc );
      if ( !sc.isSuccess() ) {
        log << MSG::ERROR << "Failed to attach dataloader RecordPersistencySvc." << endmsg;
        return sc;
      }

      sc = setRoot(m_rootName, new DataObject());
      if( !sc.isSuccess() )  {
        log << MSG::WARNING << "Error declaring Record root DataObject" << endmsg;
        return sc;
      }

      if( !m_incidentSvc )  {
        log << MSG::FATAL << "IncidentSvc is invalid--base class failed." << endmsg;
        return sc;
      }

      m_incidentSvc->addListener(this,"FILE_OPEN_READ");
      m_incidentSvc->addListener(this,m_saveIncidentName);
      return sc;
    }

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

Load dependent records into memory.

Definition at line 124 of file RecordDataSvc.cpp.

                                                   {
      if ( 0 != pObj )    {
        typedef vector<IRegistry*> Leaves;
        Leaves leaves;
        DataObject* p = 0;
        MsgStream log(msgSvc(),name());
        const string& id0 = pObj->identifier();
        StatusCode sc = retrieveObject(id0, p);
        if ( sc.isSuccess() ) {
          log << MSG::DEBUG << "Loaded records object: " << id0 << endmsg;
          sc = objectLeaves(pObj, leaves);
          if ( sc.isSuccess() )  {
            for ( Leaves::const_iterator i=leaves.begin(); i != leaves.end(); i++ )
              loadRecords(*i);
          }
        }
        else  {
          log << MSG::ERROR << "Failed to load records object: " << pObj->identifier() << endmsg;
        }
      }
    }

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 147 of file RecordDataSvc.cpp.

                                                                                  {
      if ( !data.empty() && 0 != pAddr ) {
        MsgStream log(msgSvc(),name());
        string fid = data;
        log << MSG::DEBUG << "Request to load record for file " << fid << endmsg;
        StatusCode sc = registerAddress(m_root,fid,pAddr);
        if ( !sc.isSuccess() ) {
          log << MSG::WARNING << "Failed to register record for:" << fid << endmsg;
          pAddr->release();
          return;
        }
        if ( m_autoLoad ) {
          loadRecords(pAddr->registry());
        }
        m_incidents.push_back(pAddr->registry()->identifier());
      }
      else if ( !data.empty() && 0 == pAddr ) {
        MsgStream log(msgSvc(),name());
        log << MSG::INFO << "Failed to register record for:" << data << " [Invalid Address]" << endmsg;
      }
    }

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

Service reinitialisation.

Reimplemented from DataSvc.

Definition at line 85 of file RecordDataSvc.cpp.

                                              {
      // Do nothing for this service
      return StatusCode::SUCCESS;
    }

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

IConversionSvc* RecordDataSvc::m_cnvSvc`[protected]`

Reference to the main data conversion service.

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

StringV RecordDataSvc::m_incidents`[protected]`

Pending new file incidents.

Definition at line 61 of file RecordDataSvc.h.

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

Property: name of the persistency service.

Definition at line 59 of file RecordDataSvc.h.

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

Property: name of the "save" incident.

Definition at line 57 of file RecordDataSvc.h.

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

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

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