Gaudi Framework, version v21r4

Home   Generated: 7 Sep 2009

RecordDataSvc Class Reference

#include <RecordDataSvc.h>

Inheritance diagram for RecordDataSvc:

Inheritance graph
[legend]
Collaboration diagram for RecordDataSvc:

Collaboration graph
[legend]

List of all members.


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.


Public Member Functions

virtual StatusCode initialize ()
 Service initialisation.
virtual StatusCode reinitialize ()
 Service reinitialisation.
virtual StatusCode finalize ()
 Service finalization.
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 IInterface override: Query interfaces of Interface.
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 >

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

00187 : DataSvc(name,svc), m_cnvSvc(0)
00188 {
00189   m_rootName = "/Records";
00190   declareProperty("AutoLoad",       m_autoLoad = true);
00191   declareProperty("IncidentName",   m_incidentName = "");
00192   declareProperty("SaveIncident",   m_saveIncidentName = "SAVE_RECORD");
00193   declareProperty("PersistencySvc", m_persSvcName = "PersistencySvc/RecordPersistencySvc");
00194 }

RecordDataSvc::~RecordDataSvc (  )  [virtual]

Standard Destructor.

Definition at line 197 of file RecordDataSvc.cpp.

00197                                {
00198 }


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 }

StatusCode RecordDataSvc::queryInterface ( const InterfaceID riid,
void **  ppvInterface 
) [virtual]

IInterface override: Query interfaces of Interface.

Query interfaces of Interface.

Parameters:
riid ID of Interface to be retrieved
ppvInterface Pointer to Location for interface pointer

Implements IInterface.

Definition at line 101 of file RecordDataSvc.cpp.

00101                                                                               {
00102   if ( 0 == ppvIf )
00103     return StatusCode::FAILURE;
00104   else if ( IIncidentListener::interfaceID().versionMatch(riid) )
00105     *ppvIf = static_cast<IIncidentListener*>( this );
00106   else
00107     return DataSvc::queryInterface(riid,ppvIf);
00108   // increment reference counter
00109   addRef();
00110   return SUCCESS;
00111 }

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

00114                                                    {
00115   if ( incident.type() == "FILE_OPEN_READ" ) {
00116     typedef ContextIncident<IOpaqueAddress*> Ctxt;
00117     const Ctxt* inc = dynamic_cast<const Ctxt*>(&incident);
00118     if ( inc ) {
00119       registerRecord(inc->source(),inc->tag());
00120       return;
00121     }
00122     MsgStream log(msgSvc(),name());
00123     log << MSG::ALWAYS << "Received invalid incident of type:" << incident.type() << endmsg;
00124   }
00125   else if ( incident.type() == IncidentType::BeginEvent ) {
00126     if ( !m_incidentName.empty() ) {
00127       StringV incidents(m_incidents);
00128       m_incidents.clear();
00129       for( StringV::const_iterator i=incidents.begin(); i!=incidents.end();++i)
00130         m_incidentSvc->fireIncident(Incident(*i,m_incidentName));
00131     }
00132   }
00133   else if ( incident.type() == m_saveIncidentName ) {
00134     MsgStream log(msgSvc(),name());
00135     log << MSG::ALWAYS << "Saving records not implemented." << endmsg;
00136   }
00137 }

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

00163                                                                               {
00164   if ( !data.empty() && 0 != pAddr ) {
00165     MsgStream log(msgSvc(),name());
00166     string fid = data;
00167     log << MSG::DEBUG << "Request to load record for file " << fid << endmsg;
00168     StatusCode sc = registerAddress(m_root,fid,pAddr);
00169     if ( !sc.isSuccess() ) {
00170       log << MSG::ERROR << "Failed to register record for:" << fid << endmsg;
00171       pAddr->release();
00172       return;
00173     }
00174     if ( m_autoLoad ) {
00175       loadRecords(pAddr->registry());
00176     }
00177     m_incidents.push_back(pAddr->registry()->identifier());
00178   }
00179   else if ( !data.empty() && 0 == pAddr ) {
00180     MsgStream log(msgSvc(),name());
00181     log << MSG::ERROR << "Failed to register run record for:" << data << " [Invalid Address]" << endmsg;
00182   }
00183 }

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

Load dependent records into memory.

Definition at line 140 of file RecordDataSvc.cpp.

00140                                                {
00141   if ( 0 != pObj )    {
00142     typedef vector<IRegistry*> Leaves;
00143     Leaves leaves;
00144     DataObject* p = 0;
00145     MsgStream log(msgSvc(),name());
00146     const string& id0 = pObj->identifier();
00147     StatusCode sc = retrieveObject(id0, p);
00148     if ( sc.isSuccess() ) {
00149       log << MSG::DEBUG << "Loaded records object: " << id0 << endmsg;
00150       sc = objectLeaves(pObj, leaves);
00151       if ( sc.isSuccess() )  {
00152         for ( Leaves::const_iterator i=leaves.begin(); i != leaves.end(); i++ )
00153           loadRecords(*i);
00154       }
00155     }
00156     else  {
00157       log << MSG::ERROR << "Failed to load records object: " << pObj->identifier() << endmsg;
00158     }
00159   }
00160 }


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 59 of file RecordDataSvc.h.

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

Definition at line 61 of file RecordDataSvc.h.

Property: name of the "save" incident.

Definition at line 63 of file RecordDataSvc.h.

Property: name of the persistency service.

Definition at line 65 of file RecordDataSvc.h.

Pending new file incidents.

Definition at line 67 of file RecordDataSvc.h.

Reference to the main data conversion service.

Definition at line 69 of file RecordDataSvc.h.


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

Generated at Mon Sep 7 18:21:55 2009 for Gaudi Framework, version v21r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004