The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
PersistencySvc Class Reference

PersistencySvc class implementation definition. More...

#include </builds/gaudi/Gaudi/GaudiCommonSvc/src/PersistencySvc/PersistencySvc.h>

Inheritance diagram for PersistencySvc:
Collaboration diagram for PersistencySvc:

Classes

class  ServiceEntry
 

Public Member Functions

IPersistencySvc Interface implementation
long repSvcType () const override
 Return default service type.
 
const CLIDobjType () const override
 Retrieve the class type of objects the converter produces. (DUMMY)
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Implementation of IConverter: Create the transient representation of an object.
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the created transient object.
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Implementation of IConverter: Update the transient object from the other representation.
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an updated transient object.
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Implementation of IConverter: Convert the transient object to the requested representation.
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the converted object.
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the converted representation of a transient object.
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an already converted object.
 
StatusCode setDataProvider (IDataProviderSvc *pStore) override
 Define transient datastore.
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Access reference to transient datastore.
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Set conversion service the converter is connected to.
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Get conversion service the converter is connected to.
 
StatusCode setAddressCreator (IAddressCreator *creator) override
 Set address creator facility.
 
SmartIF< IAddressCreator > & addressCreator () const override
 Retrieve address creator facility.
 
StatusCode addConverter (IConverter *pConverter) override
 Add converter object to conversion service.
 
StatusCode addConverter (const CLID &clid) override
 Add converter object to conversion service.
 
IConverterconverter (const CLID &clid) override
 Retrieve converter from list.
 
StatusCode removeConverter (const CLID &clid) override
 Remove converter object from conversion service (if present).
 
StatusCode connectOutput (const std::string &outputFile, const std::string &openMode) override
 Connect the output file to the service with open mode.
 
StatusCode connectOutput (const std::string &outputFile) override
 Connect the output file to the service.
 
StatusCode commitOutput (const std::string &output, bool do_commit) override
 Commit pending output.
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string *pars, const unsigned long *ipars, IOpaqueAddress *&refpAddress) override
 Create a Generic address using explicit arguments to identify a single object.
 
StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress) override
 Convert an address to string form.
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) override
 Convert an address in string form to object form.
 
: IPersistencySvc implementation
StatusCode addCnvService (IConversionSvc *service) override
 Add a new Service.
 
StatusCode removeCnvService (long type) override
 Remove a Service.
 
StatusCode setDefaultCnvService (long type) override
 Set default service type.
 
StatusCode getService (long service_type, IConversionSvc *&refpSvc) override
 Retrieve conversion service identified by technology.
 
StatusCode getService (const std::string &service_type, IConversionSvc *&refpSvc) override
 Retrieve conversion service identified by technology.
 
: IService implementation
StatusCode initialize () override
 Initialize the service.
 
StatusCode finalize () override
 stop the service.
 
- Public Member Functions inherited from extends< Service, IConversionSvc, IPersistencySvc, IAddressCreator >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service.
 
StatusCode sysStart () override
 Initialize Service.
 
StatusCode sysStop () override
 Initialize Service.
 
StatusCode sysFinalize () override
 Finalize Service.
 
StatusCode sysReinitialize () override
 Re-initialize the Service.
 
StatusCode sysRestart () override
 Re-initialize the Service.
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool.
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T>
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Protected Types

typedef std::map< long, ServiceEntryServices
 

: Object implementation

long m_cnvDefType = TEST_StorageType
 Default service type.
 
SmartIF< IDataProviderSvcm_dataSvc
 Pointer to data provider service.
 
Services m_cnvServices
 List of conversion workers.
 
std::recursive_mutex m_servicesMutex
 Mutex to protect accesses to m_cnvServices.
 
SmartIF< IConversionSvcm_cnvDefault
 Default output service.
 
Gaudi::Property< std::vector< std::string > > m_svcNames
 
bool m_enable = true
 Flag to indicate that the service is enabled.
 
SmartIF< IAddressCreatorm_addrCreator
 Pointer to the IAddressCreator interface of this, for addressCreator().
 
SmartIF< IConversionSvc > & service (const std::string &nam)
 Retrieve conversion service by name.
 
SmartIF< IConversionSvc > & service (long service_type)
 Retrieve conversion service from list.
 
SmartIF< IAddressCreator > & addressCreator (long service_type)
 Retrieve address creator from list.
 
void encodeAddrHdr (long service_type, const CLID &clid, std::string &address) const
 Retrieve string from storage type and clid.
 
void decodeAddrHdr (const std::string &address, long &service_type, CLID &clid, std::string &address_trailer) const
 Retrieve storage type and clid from address header of string.
 
StatusCode makeCall (int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
 Implementation helper.
 
bool enable (bool value)
 Set enabled flag.
 

Additional Inherited Members

- Public Types inherited from extends< Service, IConversionSvc, IPersistencySvc, IAddressCreator >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory<IService*( const std::string&, ISvcLocator* )>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 
- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 
int outputLevel () const
 get the Service's output level
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
 
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
 
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
 
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
 
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
 
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
 
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service.
 

Detailed Description

PersistencySvc class implementation definition.

System: The LHCb Offline System

Package: PersistencySvc

Dependencies:

  • STL: <vector>, <algorithm>, <functional>
  • Generic service definition: "Kernel/Service.h"
  • IConversionSvc definition: "Kernel/IConversionSvc.h"
  • PersistencySvc definition: "Kernel/Interfaces/IPersistencySvc.h"

History:

 +---------+----------------------------------------------+---------+
 |    Date |                 Comment                      | Who     |
 +---------+----------------------------------------------+---------+
 | 3/11/98 | Initial version                              | M.Frank |
 +---------+----------------------------------------------+---------+
 
Author
Markus Frank
Version
1.0

Definition at line 57 of file PersistencySvc.h.

Member Typedef Documentation

◆ Services

typedef std::map<long, ServiceEntry> PersistencySvc::Services
protected

Definition at line 80 of file PersistencySvc.h.

Member Function Documentation

◆ addCnvService()

StatusCode PersistencySvc::addCnvService ( IConversionSvc * service)
override

Add a new Service.

Add data service.

Definition at line 230 of file PersistencySvc.cpp.

230 {
231 std::scoped_lock _{ m_servicesMutex };
232 if ( !servc ) return Status::BAD_STORAGE_TYPE;
233 long type = servc->repSvcType();
234 long def_typ = ( m_cnvDefault ? m_cnvDefault->repSvcType() : 0 );
235 auto it = m_cnvServices.find( type );
236 auto cnv_svc = ( it != m_cnvServices.end() ? it->second.conversionSvc() : nullptr );
237 if ( type == def_typ ) m_cnvDefault = servc;
238 if ( cnv_svc == servc ) return StatusCode::SUCCESS;
239
240 auto iservc = make_SmartIF( servc );
241 auto icr = iservc.as<IAddressCreator>();
242 if ( icr ) {
243 auto isvc = iservc.as<IService>();
244 if ( isvc ) {
245 if ( cnv_svc ) removeCnvService( type ).ignore();
246 auto p = m_cnvServices.emplace( type, ServiceEntry( type, isvc, iservc, icr ) );
247 if ( !p.second ) {
248 error() << "Cannot add Conversion service " << isvc->name() << endmsg;
249 return StatusCode::FAILURE;
250 }
251 info() << "Added successfully Conversion service " << isvc->name() << endmsg;
252 iservc->setAddressCreator( this ).ignore();
253 iservc->setDataProvider( m_dataSvc ).ignore();
254 return StatusCode::SUCCESS;
255 }
256 }
257 error() << "Cannot add Conversion service for type " << type << endmsg;
258 return StatusCode::FAILURE;
259}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
SmartIF< IFace > make_SmartIF(IFace *iface)
Definition SmartIF.h:143
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::recursive_mutex m_servicesMutex
Mutex to protect accesses to m_cnvServices.
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
StatusCode removeCnvService(long type) override
Remove a Service.
Services m_cnvServices
List of conversion workers.
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ addConverter() [1/2]

StatusCode PersistencySvc::addConverter ( const CLID & clid)
override

Add converter object to conversion service.

Definition at line 170 of file PersistencySvc.cpp.

170{ return StatusCode::FAILURE; }

◆ addConverter() [2/2]

StatusCode PersistencySvc::addConverter ( IConverter * pConverter)
override

Add converter object to conversion service.

Definition at line 173 of file PersistencySvc.cpp.

173 {
174 if ( !pConverter ) return Status::NO_CONVERTER;
175 IConversionSvc* svc = service( pConverter->repSvcType() );
176 return svc ? svc->addConverter( pConverter ) : Status::BAD_STORAGE_TYPE;
177}
virtual StatusCode addConverter(IConverter *pConverter)=0
Add converter object to conversion service.
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.

◆ addressCreator() [1/2]

SmartIF< IAddressCreator > & PersistencySvc::addressCreator ( ) const
override

Retrieve address creator facility.

Definition at line 402 of file PersistencySvc.cpp.

402{ return m_addrCreator; }
SmartIF< IAddressCreator > m_addrCreator
Pointer to the IAddressCreator interface of this, for addressCreator().

◆ addressCreator() [2/2]

SmartIF< IAddressCreator > & PersistencySvc::addressCreator ( long service_type)
protected

Retrieve address creator from list.

Retrieve address creator service from list.

Definition at line 132 of file PersistencySvc.cpp.

132 {
133 std::scoped_lock _{ m_servicesMutex };
134
135 long typ = type;
136 auto it = m_cnvServices.find( typ );
137 if ( it == m_cnvServices.end() ) {
138 IConversionSvc* s = service( type );
139 if ( s ) {
140 it = m_cnvServices.find( typ );
141 if ( it != m_cnvServices.end() ) return it->second.addrCreator();
142 }
143 static SmartIF<IAddressCreator> no_creator;
144 return no_creator;
145 }
146 return it->second.addrCreator();
147}

◆ commitOutput()

StatusCode PersistencySvc::commitOutput ( const std::string & output,
bool do_commit )
override

Commit pending output.

Definition at line 291 of file PersistencySvc.cpp.

291{ return StatusCode::SUCCESS; }

◆ connectOutput() [1/2]

StatusCode PersistencySvc::connectOutput ( const std::string & outputFile)
override

Connect the output file to the service.

Definition at line 288 of file PersistencySvc.cpp.

288{ return StatusCode::SUCCESS; }

◆ connectOutput() [2/2]

StatusCode PersistencySvc::connectOutput ( const std::string & outputFile,
const std::string & openMode )
override

Connect the output file to the service with open mode.

Definition at line 283 of file PersistencySvc.cpp.

283 {
284 return connectOutput( outputFile );
285}
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.

◆ conversionSvc()

SmartIF< IConversionSvc > & PersistencySvc::conversionSvc ( ) const
override

Get conversion service the converter is connected to.

Definition at line 167 of file PersistencySvc.cpp.

167{ return m_cnvDefault; }

◆ convertAddress()

StatusCode PersistencySvc::convertAddress ( const IOpaqueAddress * pAddress,
std::string & refAddress )
override

Convert an address to string form.

Definition at line 302 of file PersistencySvc.cpp.

302 {
303 // Assumption is that the Persistency service prepends a header
304 // and requests the conversion service referred to by the service
305 // type to encode the rest
306 long svc_type = 0;
307 CLID clid = 0;
308 if ( pAddress ) {
309 svc_type = pAddress->svcType();
310 clid = pAddress->clID();
311 }
312 IAddressCreator* svc = addressCreator( svc_type );
313 StatusCode status = Status::BAD_STORAGE_TYPE; // Preset error
314 refAddress.clear();
315
316 if ( svc ) {
317 // Found service, set header
318 encodeAddrHdr( svc_type, clid, refAddress );
319 std::string address;
320 // Get rest of address from conversion service
321 status = svc->convertAddress( pAddress, address );
322 refAddress += address;
323 }
324 return status;
325}
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress)=0
Convert an address to string form.
virtual long svcType() const =0
Retrieve service type.
virtual const CLID & clID() const =0
Retrieve class information from link.
void encodeAddrHdr(long service_type, const CLID &clid, std::string &address) const
Retrieve string from storage type and clid.
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.

◆ converter()

IConverter * PersistencySvc::converter ( const CLID & clid)
override

Retrieve converter from list.

Definition at line 192 of file PersistencySvc.cpp.

192{ return nullptr; }

◆ createAddress() [1/2]

StatusCode PersistencySvc::createAddress ( long svc_type,
const CLID & clid,
const std::string & refAddress,
IOpaqueAddress *& refpAddress )
override

Convert an address in string form to object form.

Definition at line 328 of file PersistencySvc.cpp.

329 {
330 // Assumption is that the Persistency service decodes that header
331 // and requests the conversion service referred to by the service
332 // type to decode the rest
333 long new_svc_type = 0;
334 CLID new_clid = 0;
335 std::string address_trailer;
336 decodeAddrHdr( refAddress, new_svc_type, new_clid, address_trailer );
337 IAddressCreator* svc = addressCreator( new_svc_type );
338 return svc ? svc->createAddress( new_svc_type, new_clid, address_trailer, refpAddress ) : Status::BAD_STORAGE_TYPE;
339}
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ipar, IOpaqueAddress *&refpAddress)=0
Create a Generic address using explicit arguments to identify a single object.
void decodeAddrHdr(const std::string &address, long &service_type, CLID &clid, std::string &address_trailer) const
Retrieve storage type and clid from address header of string.

◆ createAddress() [2/2]

StatusCode PersistencySvc::createAddress ( long svc_type,
const CLID & clid,
const std::string * pars,
const unsigned long * ipars,
IOpaqueAddress *& refpAddress )
override

Create a Generic address using explicit arguments to identify a single object.

Definition at line 294 of file PersistencySvc.cpp.

295 {
296 refpAddress = nullptr;
297 IAddressCreator* svc = addressCreator( svc_type );
298 return svc ? svc->createAddress( svc_type, clid, pars, ipars, refpAddress ) : Status::BAD_STORAGE_TYPE;
299}

◆ createObj()

StatusCode PersistencySvc::createObj ( IOpaqueAddress * pAddress,
DataObject *& refpObject )
override

Implementation of IConverter: Create the transient representation of an object.

Create the transient representation of an object.

Definition at line 92 of file PersistencySvc.cpp.

92 {
93 return makeCall( CREATE_OBJ, pAddr, refpObj );
94}
@ CREATE_OBJ
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.

◆ createRep()

StatusCode PersistencySvc::createRep ( DataObject * pObject,
IOpaqueAddress *& refpAddress )
override

Implementation of IConverter: Convert the transient object to the requested representation.

Convert the transient object to the requested representation.

Definition at line 112 of file PersistencySvc.cpp.

112 {
113 return makeCall( CREATE_REP, refpAddr, pObj );
114}
@ CREATE_REP

◆ dataProvider()

SmartIF< IDataProviderSvc > & PersistencySvc::dataProvider ( ) const
override

Access reference to transient datastore.

Access the dataprovider service.

Definition at line 158 of file PersistencySvc.cpp.

158{ return m_dataSvc; }

◆ decodeAddrHdr()

void PersistencySvc::decodeAddrHdr ( const std::string & address,
long & service_type,
CLID & clid,
std::string & address_trailer ) const
protected

Retrieve storage type and clid from address header of string.

Definition at line 352 of file PersistencySvc.cpp.

353 {
354 // For address header, use xml-style format of
355 // <address_header service_type="xxx" clid="yyy" />
356 service_type = 0;
357 clid = 0;
358 address_trailer.clear();
359
360 // Check for address_header tag
361 size_t pos = address.find( "<address_header" );
362 if ( std::string::npos != pos ) {
363 // Get service_type
364 pos = address.find( "service_type=\"" );
365 if ( std::string::npos != pos ) {
366 pos += 14;
367 size_t end = address.find( '"', pos );
368 if ( std::string::npos != end ) {
369 service_type = std::stol( address.substr( pos, end - pos ) );
370 // Get clid
371 pos = address.find( "clid=\"" );
372 if ( std::string::npos != pos ) {
373 pos += 6;
374 end = address.find( '\"', pos );
375 if ( std::string::npos != end ) {
376 std::istringstream str;
377 str.str( address.substr( pos, end - pos ) );
378 str >> clid;
379 // Get trailer_address
380 pos = address.find( '>' );
381 if ( pos < ( address.size() - 2 ) ) { // this means that '>' was found (pos != npos)
382 // it is before the last char
383 address_trailer = address.substr( pos + 1 );
384 }
385 }
386 }
387 }
388 }
389 }
390}

◆ enable()

bool PersistencySvc::enable ( bool value)
protected

Set enabled flag.

Definition at line 507 of file PersistencySvc.cpp.

507 {
508 std::swap( value, m_enable );
509 return value;
510}
bool m_enable
Flag to indicate that the service is enabled.
void swap(GaudiUtils::VectorMap< KEY, VALUE, KEYCOMPARE, ALLOCATOR > &left, GaudiUtils::VectorMap< KEY, VALUE, KEYCOMPARE, ALLOCATOR > &right)
the definition of specialized algorithm for swapping
Definition VectorMap.h:726

◆ encodeAddrHdr()

void PersistencySvc::encodeAddrHdr ( long service_type,
const CLID & clid,
std::string & address ) const
protected

Retrieve string from storage type and clid.

Definition at line 342 of file PersistencySvc.cpp.

342 {
343 // For address header, use xml-style format of
344 // <addrhdr service_type="xxx" clid="yyy" />
345 std::stringstream stream;
346 int svctyp = service_type; // must put int into stream, not char
347 stream << "<address_header service_type=\"" << svctyp << "\" clid=\"" << clid << "\" /> ";
348 address = stream.str();
349}
stream
Definition Write.py:32

◆ fillObjRefs()

StatusCode PersistencySvc::fillObjRefs ( IOpaqueAddress * pAddress,
DataObject * pObject )
override

Implementation of IConverter: Resolve the references of the created transient object.

Resolve the references of the created transient object.

Definition at line 97 of file PersistencySvc.cpp.

97 {
98 return makeCall( FILL_OBJ_REFS, pAddr, pObj );
99}
@ FILL_OBJ_REFS

◆ fillRepRefs()

StatusCode PersistencySvc::fillRepRefs ( IOpaqueAddress * pAddress,
DataObject * pObject )
override

Implementation of IConverter: Resolve the references of the converted object.

Resolve the references of the converted object.

Definition at line 117 of file PersistencySvc.cpp.

117 {
118 return makeCall( FILL_REP_REFS, pAddr, pObj );
119}
@ FILL_REP_REFS

◆ finalize()

StatusCode PersistencySvc::finalize ( )
override

stop the service.

Definition at line 497 of file PersistencySvc.cpp.

497 {
498 std::scoped_lock _{ m_servicesMutex };
499 // Release all workers
500 m_cnvServices.clear();
501 // Release references to this to avoid loops
502 m_addrCreator = nullptr;
503 return StatusCode::SUCCESS;
504}

◆ getService() [1/2]

StatusCode PersistencySvc::getService ( const std::string & service_type,
IConversionSvc *& refpSvc )
override

Retrieve conversion service identified by technology.

Definition at line 411 of file PersistencySvc.cpp.

411 {
412 const char* imp = service_type.c_str();
413 long len = service_type.length();
414 if ( ::strncasecmp( imp, "SICB", len ) == 0 )
415 return getService( SICB_StorageType, refpSvc );
416 else if ( ::strncasecmp( imp, "ZEBRA", len ) == 0 )
417 return getService( SICB_StorageType, refpSvc );
418 else if ( ::strncasecmp( imp, "MS Access", len ) == 0 )
419 return getService( ACCESS_StorageType, refpSvc );
420 else if ( ::strncasecmp( imp, "Microsoft Access", strlen( "Microsoft Access" ) ) == 0 )
421 return getService( ACCESS_StorageType, refpSvc );
422 else if ( ::strncasecmp( imp, "SQL Server", len ) == 0 )
423 return getService( SQLSERVER_StorageType, refpSvc );
424 else if ( ::strncasecmp( imp, "Microsoft ODBC for Oracle", len ) == 0 )
425 return getService( ORACLE_StorageType, refpSvc );
426 else if ( ::strncasecmp( imp, "Oracle ODBC", strlen( "Oracle ODBC" ) ) == 0 )
427 return getService( ORACLE_StorageType, refpSvc );
428 else if ( ::strncasecmp( imp, "Oracle OCI", strlen( "Oracle OCI" ) ) == 0 )
429 return getService( ORACLE_StorageType, refpSvc );
430 else if ( ::strncasecmp( imp, "MySQL", len ) == 0 )
431 return getService( MYSQL_StorageType, refpSvc );
432 else if ( ::strncasecmp( imp, "ROOT", len ) == 0 )
433 return getService( ROOT_StorageType, refpSvc );
434 else if ( ::strncasecmp( imp, "OBJY", len ) == 0 )
435 return getService( OBJY_StorageType, refpSvc );
436 else if ( ::strncasecmp( imp, "OBJYECTI", 7 ) == 0 )
437 return getService( OBJY_StorageType, refpSvc );
438 else if ( ::strncasecmp( imp, "POOL_ROOTKEY", 12 ) == 0 )
439 return getService( POOL_ROOTKEY_StorageType, refpSvc );
440 else if ( ::strncasecmp( imp, "POOL_ROOTTREE", 12 ) == 0 )
441 return getService( POOL_ROOTTREE_StorageType, refpSvc );
442 else if ( ::strncasecmp( imp, "POOL_ROOT", 9 ) == 0 )
443 return getService( POOL_ROOT_StorageType, refpSvc );
444 else if ( ::strncasecmp( imp, "POOL_MySQL", 8 ) == 0 )
445 return getService( POOL_MYSQL_StorageType, refpSvc );
446 else if ( ::strncasecmp( imp, "POOL_ORACLE", 8 ) == 0 )
447 return getService( POOL_ORACLE_StorageType, refpSvc );
448 else if ( ::strncasecmp( imp, "POOL_ACCESS", 8 ) == 0 )
449 return getService( POOL_ACCESS_StorageType, refpSvc );
450 else if ( ::strncasecmp( imp, "POOL", 4 ) == 0 )
451 return getService( POOL_StorageType, refpSvc );
452
453 std::scoped_lock _{ m_servicesMutex };
454 for ( const auto& i : m_cnvServices ) {
455 SmartIF<IService> svc( i.second.conversionSvc() );
456 if ( svc ) {
457 // Check wether this is already an active service: first check by service name
458 if ( svc->name() == service_type ) {
459 refpSvc = i.second.conversionSvc();
460 return StatusCode::SUCCESS;
461 }
462 // Check wether this is already an active service: now check by service type
463 auto instance = svc.get();
464 if ( System::typeinfoName( typeid( *instance ) ) == service_type ) {
465 refpSvc = i.second.conversionSvc();
466 return StatusCode::SUCCESS;
467 }
468 }
469 }
470 // if not, check if the service is in the list and may be requested
471 for ( const auto& i : m_svcNames.value() ) {
472 Gaudi::Utils::TypeNameString itm( i );
473 if ( itm.name() == service_type || itm.type() == service_type ) {
474 IConversionSvc* svc = service( i );
475 if ( svc ) {
476 refpSvc = svc;
477 return StatusCode::SUCCESS;
478 }
479 }
480 }
481 return StatusCode::FAILURE;
482}
const long POOL_MYSQL_StorageType
Definition ClassID.h:80
const long POOL_ORACLE_StorageType
Definition ClassID.h:81
const long POOL_ROOTKEY_StorageType
Definition ClassID.h:77
const long ORACLE_StorageType
Definition ClassID.h:73
const long MYSQL_StorageType
Definition ClassID.h:72
const long OBJY_StorageType
Definition ClassID.h:61
const long POOL_StorageType
Definition ClassID.h:75
const long SQLSERVER_StorageType
Definition ClassID.h:71
const long ACCESS_StorageType
Definition ClassID.h:68
const long POOL_ROOT_StorageType
Definition ClassID.h:76
const long POOL_ACCESS_StorageType
Definition ClassID.h:79
const long SICB_StorageType
Definition ClassID.h:59
const long POOL_ROOTTREE_StorageType
Definition ClassID.h:78
const long ROOT_StorageType
Definition ClassID.h:60
virtual SmartIF< IConversionSvc > & conversionSvc() const =0
Get conversion service the converter is connected to.
Gaudi::Property< std::vector< std::string > > m_svcNames
StatusCode getService(long service_type, IConversionSvc *&refpSvc) override
Retrieve conversion service identified by technology.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260

◆ getService() [2/2]

StatusCode PersistencySvc::getService ( long service_type,
IConversionSvc *& refpSvc )
override

Retrieve conversion service identified by technology.

Definition at line 405 of file PersistencySvc.cpp.

405 {
406 refpSvc = service( service_type );
407 return refpSvc ? StatusCode::SUCCESS : StatusCode::FAILURE;
408}

◆ initialize()

StatusCode PersistencySvc::initialize ( )
override

Initialize the service.

Definition at line 488 of file PersistencySvc.cpp.

488 {
489 m_addrCreator = this; // initialize internal pointer to IAddressCreator interface
490 // Initialize basic service
491 StatusCode status = Service::initialize();
492 if ( !status.isSuccess() ) { error() << "Error initializing Service base class." << endmsg; }
493 return status;
494}
StatusCode initialize() override
Definition Service.cpp:118
bool isSuccess() const
Definition StatusCode.h:314

◆ makeCall()

StatusCode PersistencySvc::makeCall ( int typ,
IOpaqueAddress *& pAddress,
DataObject *& pObject )
protected

Implementation helper.

Definition at line 37 of file PersistencySvc.cpp.

37 {
38 if ( m_enable ) {
39 IConversionSvc* svc = nullptr;
40 switch ( typ ) {
41 case CREATE_REP:
42 case FILL_REP_REFS:
43 case UPDATE_REP:
44 case UPDATE_REP_REFS:
45 svc = m_cnvDefault;
46 break;
47 default:
48 if ( !pAddress ) return Status::INVALID_ADDRESS;
49 svc = service( pAddress->svcType() );
50 if ( !svc ) return Status::BAD_STORAGE_TYPE;
51 break;
52 }
53
54 StatusCode status = StatusCode::FAILURE;
55 switch ( typ ) {
56 case CREATE_OBJ:
57 pObject = nullptr;
58 status = svc->createObj( pAddress, pObject );
59 break;
60 case FILL_OBJ_REFS:
61 status = svc->fillObjRefs( pAddress, pObject );
62 break;
63 case UPDATE_OBJ:
64 status = svc->updateObj( pAddress, pObject );
65 break;
66 case UPDATE_OBJ_REFS:
67 status = svc->updateObjRefs( pAddress, pObject );
68 break;
69 case CREATE_REP:
70 status = svc->createRep( pObject, pAddress );
71 break;
72 case FILL_REP_REFS:
73 status = svc->fillRepRefs( pAddress, pObject );
74 break;
75 case UPDATE_REP:
76 status = svc->updateRep( pAddress, pObject );
77 break;
78 case UPDATE_REP_REFS:
79 status = svc->updateRepRefs( pAddress, pObject );
80 break;
81 default:
82 status = StatusCode::FAILURE;
83 break;
84 }
85 status.ignore();
86 return status;
87 }
89}
@ UPDATE_OBJ
@ UPDATE_REP
@ UPDATE_REP_REFS
@ UPDATE_OBJ_REFS
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.

◆ objType()

const CLID & PersistencySvc::objType ( ) const
override

Retrieve the class type of objects the converter produces. (DUMMY)

Retrieve the class type of objects the converter produces.

Definition at line 485 of file PersistencySvc.cpp.

485{ return CLID_NULL; }

◆ removeCnvService()

StatusCode PersistencySvc::removeCnvService ( long type)
override

Remove a Service.

Remove conversion service.

Definition at line 262 of file PersistencySvc.cpp.

262 {
263 std::scoped_lock _{ m_servicesMutex };
264
265 auto it = m_cnvServices.find( svctype );
266 if ( it == m_cnvServices.end() ) return Status::BAD_STORAGE_TYPE;
267 it->second.service()->release();
268 it->second.addrCreator()->release();
269 m_cnvServices.erase( it );
270 return StatusCode::SUCCESS;
271}

◆ removeConverter()

StatusCode PersistencySvc::removeConverter ( const CLID & clid)
override

Remove converter object from conversion service (if present).

Definition at line 180 of file PersistencySvc.cpp.

180 {
181 std::scoped_lock _{ m_servicesMutex };
182 // Remove converter type from all services
183 StatusCode status = Status::NO_CONVERTER, iret = StatusCode::SUCCESS;
184 for ( auto& i : m_cnvServices ) {
185 iret = i.second.conversionSvc()->removeConverter( clid );
186 if ( iret.isSuccess() ) status = iret;
187 }
188 return status;
189}

◆ repSvcType()

long PersistencySvc::repSvcType ( ) const
override

Return default service type.

Retrieve the class type of the data store the converter uses.

Definition at line 274 of file PersistencySvc.cpp.

274{ return m_cnvDefault ? m_cnvDefault->repSvcType() : 0; }

◆ service() [1/2]

SmartIF< IConversionSvc > & PersistencySvc::service ( const std::string & nam)
protected

Retrieve conversion service by name.

Definition at line 195 of file PersistencySvc.cpp.

195 {
196 Gaudi::Utils::TypeNameString tn( nam );
197
198 std::scoped_lock _{ m_servicesMutex };
199
200 auto it = std::find_if( m_cnvServices.begin(), m_cnvServices.end(),
201 [&]( Services::const_reference i ) { return i.second.service()->name() == tn.name(); } );
202 if ( it != m_cnvServices.end() ) return it->second.conversionSvc();
203
204 auto svc = Service::service<IConversionSvc>( nam, true );
205 if ( svc && addCnvService( svc.get() ).isSuccess() ) {
206 return service( nam ); // now it is in the list
207 }
208
209 error() << "Cannot access Conversion service " << nam << endmsg;
210 static SmartIF<IConversionSvc> no_svc;
211 return no_svc;
212}
StatusCode addCnvService(IConversionSvc *service) override
Add a new Service.
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
Definition Service.h:79

◆ service() [2/2]

SmartIF< IConversionSvc > & PersistencySvc::service ( long service_type)
protected

Retrieve conversion service from list.

Definition at line 215 of file PersistencySvc.cpp.

215 {
216 std::scoped_lock _{ m_servicesMutex };
217 // Check wether this is already an active service
218 auto it = m_cnvServices.find( type );
219 if ( it != m_cnvServices.end() ) return it->second.conversionSvc();
220 // if not, check if the service is in the list and may be requested
221 for ( const auto& i : m_svcNames.value() ) {
222 auto& svc = service( i );
223 if ( svc && svc->repSvcType() == type ) return svc;
224 }
225 static SmartIF<IConversionSvc> no_svc;
226 return no_svc;
227}

◆ setAddressCreator()

StatusCode PersistencySvc::setAddressCreator ( IAddressCreator * creator)
override

Set address creator facility.

Definition at line 393 of file PersistencySvc.cpp.

393 {
394 // The persistency service is an address creation dispatcher itself.
395 // The persistency service can NEVER create addresses itself.
396 // The entry point must only be provided in order to fulfill the needs of the
397 // implementing interfaces.
398 return StatusCode::FAILURE;
399}

◆ setConversionSvc()

StatusCode PersistencySvc::setConversionSvc ( IConversionSvc * svc)
override

Set conversion service the converter is connected to.

Definition at line 161 of file PersistencySvc.cpp.

161 {
162 m_cnvDefault = svc;
163 return StatusCode::SUCCESS;
164}

◆ setDataProvider()

StatusCode PersistencySvc::setDataProvider ( IDataProviderSvc * pStore)
override

Define transient datastore.

Define transient data store.

Definition at line 150 of file PersistencySvc.cpp.

150 {
151 std::scoped_lock _{ m_servicesMutex };
152 m_dataSvc = pDataSvc;
153 for ( auto& i : m_cnvServices ) { i.second.conversionSvc()->setDataProvider( m_dataSvc ).ignore(); }
154 return StatusCode::SUCCESS;
155}

◆ setDefaultCnvService()

StatusCode PersistencySvc::setDefaultCnvService ( long type)
override

Set default service type.

Set default conversion service.

Definition at line 277 of file PersistencySvc.cpp.

277 {
278 m_cnvDefault = service( type );
279 return StatusCode::SUCCESS;
280}

◆ updateObj()

StatusCode PersistencySvc::updateObj ( IOpaqueAddress * pAddress,
DataObject * refpObject )
override

Implementation of IConverter: Update the transient object from the other representation.

Update the transient object from the other representation.

Definition at line 102 of file PersistencySvc.cpp.

102 {
103 return makeCall( UPDATE_OBJ, pAddr, pObj );
104}

◆ updateObjRefs()

StatusCode PersistencySvc::updateObjRefs ( IOpaqueAddress * pAddress,
DataObject * pObject )
override

Implementation of IConverter: Update the references of an updated transient object.

Update the references of an updated transient object.

Definition at line 107 of file PersistencySvc.cpp.

107 {
108 return makeCall( UPDATE_OBJ_REFS, pAddr, pObj );
109}

◆ updateRep()

StatusCode PersistencySvc::updateRep ( IOpaqueAddress * pAddress,
DataObject * pObject )
override

Implementation of IConverter: Update the converted representation of a transient object.

Update the converted representation of a transient object.

Definition at line 122 of file PersistencySvc.cpp.

122 {
123 return makeCall( UPDATE_REP, pAddr, pObj );
124}

◆ updateRepRefs()

StatusCode PersistencySvc::updateRepRefs ( IOpaqueAddress * pAddress,
DataObject * pObject )
override

Implementation of IConverter: Update the references of an already converted object.

Update the references of an already converted object.

Definition at line 127 of file PersistencySvc.cpp.

127 {
128 return makeCall( UPDATE_REP_REFS, pAddr, pObj );
129}

Member Data Documentation

◆ m_addrCreator

SmartIF<IAddressCreator> PersistencySvc::m_addrCreator
mutableprotected

Pointer to the IAddressCreator interface of this, for addressCreator().

Definition at line 246 of file PersistencySvc.h.

◆ m_cnvDefault

SmartIF<IConversionSvc> PersistencySvc::m_cnvDefault
mutableprotected

Default output service.

Definition at line 230 of file PersistencySvc.h.

◆ m_cnvDefType

long PersistencySvc::m_cnvDefType = TEST_StorageType
protected

Default service type.

Definition at line 221 of file PersistencySvc.h.

◆ m_cnvServices

Services PersistencySvc::m_cnvServices
protected

List of conversion workers.

Definition at line 225 of file PersistencySvc.h.

◆ m_dataSvc

SmartIF<IDataProviderSvc> PersistencySvc::m_dataSvc
mutableprotected

Pointer to data provider service.

Definition at line 223 of file PersistencySvc.h.

◆ m_enable

bool PersistencySvc::m_enable = true
protected

Flag to indicate that the service is enabled.

Definition at line 243 of file PersistencySvc.h.

◆ m_servicesMutex

std::recursive_mutex PersistencySvc::m_servicesMutex
mutableprotected

Mutex to protect accesses to m_cnvServices.

Definition at line 227 of file PersistencySvc.h.

◆ m_svcNames

Gaudi::Property<std::vector<std::string> > PersistencySvc::m_svcNames
protected
Initial value:
{
this,
"CnvServices",
{},
[this]( auto& p ) {
if ( this->msgLevel( MSG::DEBUG ) ) this->debug() << p << endmsg;
},
"Names of services to be requested from the service locator and added by default",
"OrderedSet<std::string>" }
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
@ DEBUG
Definition IMessageSvc.h:22

Definition at line 232 of file PersistencySvc.h.

232 {
233 this,
234 "CnvServices",
235 {},
236 [this]( auto& p ) {
237 if ( this->msgLevel( MSG::DEBUG ) ) this->debug() << p << endmsg;
238 },
239 "Names of services to be requested from the service locator and added by default",
240 "OrderedSet<std::string>" };

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