RecordDataSvc Class Reference

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

#include <src/DataSvc/RecordDataSvc.h>

Inheritance diagram for RecordDataSvc:
Collaboration diagram for RecordDataSvc:

Public Member Functions

StatusCode initialize () override
 Service initialisation. More...
 
StatusCode finalize () override
 Service finalization. More...
 
void handle (const Incident &incident) override
 IIncidentListener override: Inform that a new incident has occured. More...
 
 RecordDataSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
 ~RecordDataSvc () override=default
 Standard Destructor. More...
 
- Public Member Functions inherited from extends< BASE, Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Member Functions

void registerRecord (const std::string &data, IOpaqueAddress *pAddr)
 Load new record into the data store if necessary. More...
 
void loadRecords (IRegistry *pReg)
 Load dependent records into memory. More...
 

Protected Attributes

bool m_autoLoad
 Property: autoload of records (default: true) More...
 
std::string m_incidentName
 Property: name of incident to be fired if new record arrives. More...
 
std::string m_saveIncidentName
 Property: name of the "save" incident. More...
 
std::string m_persSvcName
 Property: name of the persistency service. More...
 
std::vector< std::string > m_incidents
 Pending new file incidents. More...
 
SmartIF< IConversionSvcm_cnvSvc
 Reference to the main data conversion service. More...
 

Additional Inherited Members

- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 

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

Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 158 of file RecordDataSvc.cpp.

159 : base_class(name,svc)
160 {
161  m_rootName = "/Records";
162  declareProperty("AutoLoad", m_autoLoad = true);
163  declareProperty("IncidentName", m_incidentName = "");
164  declareProperty("SaveIncident", m_saveIncidentName = "SAVE_RECORD");
165  declareProperty("PersistencySvc", m_persSvcName = "PersistencySvc/RecordPersistencySvc");
166 }
std::string m_persSvcName
Property: name of the persistency service.
Definition: RecordDataSvc.h:54
std::string m_incidentName
Property: name of incident to be fired if new record arrives.
Definition: RecordDataSvc.h:50
bool m_autoLoad
Property: autoload of records (default: true)
Definition: RecordDataSvc.h:48
extends base_class
Typedef to this class.
Definition: extends.h:14
std::string m_saveIncidentName
Property: name of the "save" incident.
Definition: RecordDataSvc.h:52
RecordDataSvc::~RecordDataSvc ( )
overridedefault

Standard Destructor.

Member Function Documentation

StatusCode RecordDataSvc::finalize ( )
override

Service finalization.

Definition at line 84 of file RecordDataSvc.cpp.

84  {
85  if( m_incidentSvc ) m_incidentSvc->removeListener(this);
86  m_cnvSvc.reset();
88  return StatusCode::SUCCESS ;
89 }
StatusCode finalize() override
Service initialization.
Definition: DataSvc.cpp:1188
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
void ignore() const
Definition: StatusCode.h:108
SmartIF< IConversionSvc > m_cnvSvc
Reference to the main data conversion service.
Definition: RecordDataSvc.h:58
void RecordDataSvc::handle ( const Incident incident)
override

IIncidentListener override: Inform that a new incident has occured.

Inform that a new incident has occured.

Definition at line 92 of file RecordDataSvc.cpp.

92  {
93  if ( incident.type() == "FILE_OPEN_READ" ) {
95  auto inc = dynamic_cast<const Ctxt*>(&incident);
96  if ( !inc ) {
97  MsgStream log(msgSvc(),name());
98  log << MSG::ALWAYS << "Received invalid incident of type:" << incident.type() << endmsg;
99  } else {
100  registerRecord(inc->source(),inc->tag());
101  if ( !m_incidentName.empty() ) {
102  auto incidents = m_incidents;
103  m_incidents.clear();
104  for( const auto& i : incidents)
105  m_incidentSvc->fireIncident(Incident{i,m_incidentName});
106  }
107  }
108  } else if ( incident.type() == m_saveIncidentName ) {
109  MsgStream log(msgSvc(),name());
110  log << MSG::ALWAYS << "Saving records not implemented." << endmsg;
111  }
112 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
const std::string & type() const
Access to the incident type.
Definition: Incident.h:34
std::string m_incidentName
Property: name of incident to be fired if new record arrives.
Definition: RecordDataSvc.h:50
std::string m_saveIncidentName
Property: name of the "save" incident.
Definition: RecordDataSvc.h:52
std::vector< std::string > m_incidents
Pending new file incidents.
Definition: RecordDataSvc.h:56
Base class for all Incidents (computing events).
Definition: Incident.h:16
void registerRecord(const std::string &data, IOpaqueAddress *pAddr)
Load new record into the data store if necessary.
list i
Definition: ana.py:128
StatusCode RecordDataSvc::initialize ( )
override

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.

Definition at line 39 of file RecordDataSvc.cpp.

39  {
40  // Nothing to do: just call base class initialisation
42  MsgStream log(msgSvc(),name());
43 
44  if ( !sc.isSuccess() ) { // Base class failure
45  return sc;
46  }
47  // Attach data loader facility
48  m_cnvSvc = service(m_persSvcName, true);
49  if ( !m_cnvSvc) {
50  log << MSG::ERROR << "Failed to access RecordPersistencySvc." << endmsg;
51  return StatusCode::FAILURE;
52  }
53  auto prp = m_cnvSvc.as<IProperty>();
54  if ( prp ) {
55  //prp->setProperty();
56  }
57  sc = setDataLoader( m_cnvSvc.get() );
58  if ( !sc.isSuccess() ) {
59  log << MSG::ERROR << "Failed to attach dataloader RecordPersistencySvc." << endmsg;
60  return sc;
61  }
62 
63  sc = setRoot(m_rootName, new DataObject());
64  if( !sc.isSuccess() ) {
65  log << MSG::WARNING << "Error declaring Record root DataObject" << endmsg;
66  return sc;
67  }
68 
69  if( !m_incidentSvc ) {
70  log << MSG::FATAL << "IncidentSvc is invalid--base class failed." << endmsg;
71  return sc;
72  }
73 
78  m_incidentSvc->addListener(this,"FILE_OPEN_READ");
79  m_incidentSvc->addListener(this,m_saveIncidentName);
80  return sc;
81 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::string m_persSvcName
Property: name of the persistency service.
Definition: RecordDataSvc.h:54
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition: SmartIF.h:110
std::string m_saveIncidentName
Property: name of the "save" incident.
Definition: RecordDataSvc.h:52
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode initialize() override
Service initialization.
Definition: DataSvc.cpp:1153
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:21
SmartIF< IConversionSvc > m_cnvSvc
Reference to the main data conversion service.
Definition: RecordDataSvc.h:58
void RecordDataSvc::loadRecords ( IRegistry pReg)
protected

Load dependent records into memory.

Definition at line 115 of file RecordDataSvc.cpp.

115  {
116  MsgStream log(msgSvc(),name());
117  if ( !pObj ) {
118  log << MSG::ERROR << "Failed to load records object: " << pObj->identifier() << endmsg;
119  } else {
120  vector<IRegistry*> leaves;
121  DataObject* p = nullptr;
122  const string& id0 = pObj->identifier();
123  StatusCode sc = retrieveObject(id0, p);
124  if ( sc.isSuccess() ) {
125  log << MSG::DEBUG << "Loaded records object: " << id0 << endmsg;
126  sc = objectLeaves(pObj, leaves);
127  if ( sc.isSuccess() ) {
128  for ( const auto& i : leaves) loadRecords(i);
129  }
130  }
131  }
132 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
list i
Definition: ana.py:128
void loadRecords(IRegistry *pReg)
Load dependent records into memory.
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 135 of file RecordDataSvc.cpp.

135  {
136  if ( !data.empty() && pAddr ) {
137  MsgStream log(msgSvc(),name());
138  string fid = data;
139  log << MSG::DEBUG << "Request to load record for file " << fid << endmsg;
140  StatusCode sc = registerAddress(m_root,fid,pAddr);
141  if ( !sc.isSuccess() ) {
142  log << MSG::WARNING << "Failed to register record for:" << fid << endmsg;
143  pAddr->release();
144  return;
145  }
146  if ( m_autoLoad ) {
147  loadRecords(pAddr->registry());
148  }
149  m_incidents.push_back(pAddr->registry()->identifier());
150  }
151  else if ( !data.empty() && !pAddr ) {
152  MsgStream log(msgSvc(),name());
153  log << MSG::INFO << "Failed to register record for:" << data << " [Invalid Address]" << endmsg;
154  }
155 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
bool m_autoLoad
Property: autoload of records (default: true)
Definition: RecordDataSvc.h:48
virtual unsigned long release()=0
release reference to object
virtual IRegistry * registry() const =0
Update branch name.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::vector< std::string > m_incidents
Pending new file incidents.
Definition: RecordDataSvc.h:56
virtual const id_type & identifier() const =0
Full identifier (or key)
void loadRecords(IRegistry *pReg)
Load dependent records into memory.

Member Data Documentation

bool RecordDataSvc::m_autoLoad
protected

Property: autoload of records (default: true)

Definition at line 48 of file RecordDataSvc.h.

SmartIF<IConversionSvc> RecordDataSvc::m_cnvSvc
protected

Reference to the main data conversion service.

Definition at line 58 of file RecordDataSvc.h.

std::string RecordDataSvc::m_incidentName
protected

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

Definition at line 50 of file RecordDataSvc.h.

std::vector<std::string> RecordDataSvc::m_incidents
protected

Pending new file incidents.

Definition at line 56 of file RecordDataSvc.h.

std::string RecordDataSvc::m_persSvcName
protected

Property: name of the persistency service.

Definition at line 54 of file RecordDataSvc.h.

std::string RecordDataSvc::m_saveIncidentName
protected

Property: name of the "save" incident.

Definition at line 52 of file RecordDataSvc.h.


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