18 #define DATASVC_RECORDDATASVC_CPP
20 #include "GaudiKernel/SmartIF.h"
21 #include "GaudiKernel/MsgStream.h"
22 #include "GaudiKernel/IProperty.h"
23 #include "GaudiKernel/DataObject.h"
24 #include "GaudiKernel/ISvcLocator.h"
25 #include "GaudiKernel/IIncidentSvc.h"
26 #include "GaudiKernel/IConversionSvc.h"
27 #include "GaudiKernel/IOpaqueAddress.h"
28 #include "GaudiKernel/DataIncident.h"
29 #include "GaudiKernel/RegistryEntry.h"
48 m_cnvSvc = service(m_persSvcName,
true);
57 sc = setDataLoader( m_cnvSvc.get() );
59 log <<
MSG::ERROR <<
"Failed to attach dataloader RecordPersistencySvc." <<
endmsg;
69 if( !m_incidentSvc ) {
78 m_incidentSvc->addListener(
this,
"FILE_OPEN_READ");
79 m_incidentSvc->addListener(
this,m_saveIncidentName);
85 if( m_incidentSvc ) m_incidentSvc->removeListener(
this);
93 if ( incident.
type() ==
"FILE_OPEN_READ" ) {
95 auto inc =
dynamic_cast<const Ctxt*
>(&incident);
100 registerRecord(inc->source(),inc->tag());
101 if ( !m_incidentName.empty() ) {
102 auto incidents = m_incidents;
104 for(
const auto&
i : incidents)
105 m_incidentSvc->fireIncident(
Incident{
i,m_incidentName});
108 }
else if ( incident.
type() == m_saveIncidentName ) {
120 vector<IRegistry*> leaves;
126 sc = objectLeaves(pObj, leaves);
128 for (
const auto&
i : leaves) loadRecords(
i);
136 if ( !data.empty() && pAddr ) {
151 else if ( !data.empty() && !pAddr ) {
153 log <<
MSG::INFO <<
"Failed to register record for:" << data <<
" [Invalid Address]" <<
endmsg;
161 m_rootName =
"/Records";
162 declareProperty(
"AutoLoad",
m_autoLoad =
true);
165 declareProperty(
"PersistencySvc",
m_persSvcName =
"PersistencySvc/RecordPersistencySvc");
Definition of the MsgStream class used to transmit messages.
StatusCode finalize() override
Service finalization.
std::string m_persSvcName
Property: name of the persistency service.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
const std::string & type() const
Access to the incident type.
std::string m_incidentName
Property: name of incident to be fired if new record arrives.
bool isSuccess() const
Test for a status code of SUCCESS.
bool m_autoLoad
Property: autoload of records (default: true)
virtual unsigned long release()=0
release reference to object
A RecordDataSvc is the base class for event services.
std::string m_saveIncidentName
Property: name of the "save" incident.
virtual IRegistry * registry() const =0
Update branch name.
This class is used for returning status codes from appropriate routines.
void clear(STATE_TYPE _i=std::ios_base::failbit)
#define DECLARE_COMPONENT(type)
The IRegistry represents the entry door to the environment any data object residing in a transient da...
StatusCode finalize() override
Service initialization.
Base class used to extend a class implementing other interfaces.
StatusCode initialize() override
Service initialization.
Base class for all Incidents (computing events).
RecordDataSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
virtual const id_type & identifier() const =0
Full identifier (or key)
void handle(const Incident &incident) override
IIncidentListener override: Inform that a new incident has occured.
void registerRecord(const std::string &data, IOpaqueAddress *pAddr)
Load new record into the data store if necessary.
Opaque address interface definition.
The IProperty is the basic interface for all components which have properties that can be set or get...
A DataObject is the base class of any identifiable object on any data store.
void loadRecords(IRegistry *pReg)
Load dependent records into memory.