Gaudi Framework, version v22r0

Home   Generated: 9 Feb 2011

RecordDataSvc Class Reference

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

#include <RecordDataSvc.h>

Inheritance diagram for RecordDataSvc:
Inheritance graph
[legend]
Collaboration diagram for RecordDataSvc:
Collaboration graph
[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::stringStringV

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

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.

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

RecordDataSvc::~RecordDataSvc (  )  [virtual]

Standard Destructor.

Definition at line 181 of file RecordDataSvc.cpp.

00181                                {
00182 }


Member Function Documentation

StatusCode RecordDataSvc::finalize (  )  [virtual]

Service finalization.

Reimplemented from DataSvc.

Definition at line 91 of file RecordDataSvc.cpp.

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

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.

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

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,"FILE_OPEN_READ");
00080   m_incidentSvc->addListener(this,m_saveIncidentName);
00081   return sc;
00082 }

void RecordDataSvc::loadRecords ( IRegistry pReg  )  [protected]

Load dependent records into memory.

Definition at line 124 of file RecordDataSvc.cpp.

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

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.

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

StatusCode RecordDataSvc::reinitialize (  )  [virtual]

Service reinitialisation.

Reimplemented from DataSvc.

Definition at line 85 of file RecordDataSvc.cpp.

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


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.

Reference to the main data conversion service.

Definition at line 63 of file RecordDataSvc.h.

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

Definition at line 55 of file RecordDataSvc.h.

Pending new file incidents.

Definition at line 61 of file RecordDataSvc.h.

Property: name of the persistency service.

Definition at line 59 of file RecordDataSvc.h.

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Wed Feb 9 16:31:42 2011 for Gaudi Framework, version v22r0 by Doxygen version 1.6.2 written by Dimitri van Heesch, © 1997-2004