PersistencySvc Class Reference

PersistencySvc class implementation definition. More...

#include <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. More...
 
const CLIDobjType () const override
 Retrieve the class type of objects the converter produces. (DUMMY) More...
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Implementation of IConverter: Create the transient representation of an object. More...
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the created transient object. More...
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Implementation of IConverter: Update the transient object from the other representation. More...
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an updated transient object. More...
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Implementation of IConverter: Convert the transient object to the requested representation. More...
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the converted object. More...
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the converted representation of a transient object. More...
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an already converted object. More...
 
StatusCode setDataProvider (IDataProviderSvc *pStore) override
 Define transient datastore. More...
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Access reference to transient datastore. More...
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Set conversion service the converter is connected to. More...
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Get conversion service the converter is connected to. More...
 
StatusCode setAddressCreator (IAddressCreator *creator) override
 Set address creator facility. More...
 
SmartIF< IAddressCreator > & addressCreator () const override
 Retrieve address creator facility. More...
 
StatusCode addConverter (IConverter *pConverter) override
 Add converter object to conversion service. More...
 
StatusCode addConverter (const CLID &clid) override
 Add converter object to conversion service. More...
 
IConverterconverter (const CLID &clid) override
 Retrieve converter from list. More...
 
StatusCode removeConverter (const CLID &clid) override
 Remove converter object from conversion service (if present). More...
 
StatusCode connectOutput (const std::string &outputFile, const std::string &openMode) override
 Connect the output file to the service with open mode. More...
 
StatusCode connectOutput (const std::string &outputFile) override
 Connect the output file to the service. More...
 
StatusCode commitOutput (const std::string &output, bool do_commit) override
 Commit pending output. More...
 
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. More...
 
StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress) override
 Convert an address to string form. More...
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) override
 Convert an address in string form to object form. More...
 
: IPersistencySvc implementation
StatusCode addCnvService (IConversionSvc *service) override
 Add a new Service. More...
 
StatusCode removeCnvService (long type) override
 Remove a Service. More...
 
StatusCode setDefaultCnvService (long type) override
 Set default service type. More...
 
StatusCode getService (long service_type, IConversionSvc *&refpSvc) override
 Retrieve conversion service identified by technology. More...
 
StatusCode getService (const std::string &service_type, IConversionSvc *&refpSvc) override
 Retrieve conversion service identified by technology. More...
 
: IService implementation
StatusCode initialize () override
 Initialize the service. More...
 
StatusCode finalize () override
 stop the service. More...
 
- Public Member Functions inherited from extends< Service, IConversionSvc, IPersistencySvc, IAddressCreator >
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::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
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. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Types

typedef std::map< long, ServiceEntryServices
 

Protected Member Functions

void svcNamesHandler (Property &theProp)
 Handlers for Service Names Property. More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

long m_cnvDefType = TEST_StorageType
 Default service type. More...
 
SmartIF< IDataProviderSvcm_dataSvc
 Pointer to datma provider service. More...
 
Services m_cnvServices
 List of convermsion workers. More...
 
SmartIF< IConversionSvcm_cnvDefault
 Default output service. More...
 
StringArrayProperty m_svcNames
 Names of services to be requested from the service locator and added by default. More...
 
bool m_enable = true
 Flag to indicate that the service is enabled. More...
 
SmartIF< IAddressCreatorm_addrCreator
 Pointer to the IAddressCreator interface of this, for addressCreator(). More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 

: Object implementation

 PersistencySvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
 ~PersistencySvc () override=default
 Standard Destructor. More...
 
SmartIF< IConversionSvc > & service (const std::string &nam)
 Retrieve conversion service by name. More...
 
SmartIF< IConversionSvc > & service (long service_type)
 Retrieve conversion service from list. More...
 
SmartIF< IAddressCreator > & addressCreator (long service_type)
 Retrieve address creator from list. More...
 
void encodeAddrHdr (long service_type, const CLID &clid, std::string &address) const
 Retrieve string from storage type and clid. More...
 
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. More...
 
StatusCode makeCall (int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
 Implementation helper. More...
 
bool enable (bool value)
 Set enabled flag. More...
 

Additional Inherited Members

- Public Types inherited from extends< Service, IConversionSvc, IPersistencySvc, IAddressCreator >
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 Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- 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...
 

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 50 of file PersistencySvc.h.

Member Typedef Documentation

Definition at line 95 of file PersistencySvc.h.

Constructor & Destructor Documentation

PersistencySvc::PersistencySvc ( const std::string name,
ISvcLocator svc 
)

Standard Constructor.

Definition at line 567 of file PersistencySvc.cpp.

568 : base_class(name, svc)
569 {
570  declareProperty("CnvServices", m_svcNames);
572 }
virtual Property & declareUpdateHandler(std::function< void(Property &)> fun)
set new callback for update
Definition: Property.cpp:72
StringArrayProperty m_svcNames
Names of services to be requested from the service locator and added by default.
void svcNamesHandler(Property &theProp)
Handlers for Service Names Property.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
PersistencySvc::~PersistencySvc ( )
overridedefault

Standard Destructor.

Member Function Documentation

StatusCode PersistencySvc::addCnvService ( IConversionSvc service)
override

Add a new Service.

Add data service.

Definition at line 255 of file PersistencySvc.cpp.

255  {
256  if ( !servc ) return BAD_STORAGE_TYPE;
257  long type = servc->repSvcType();
258  long def_typ = ( m_cnvDefault ? m_cnvDefault->repSvcType() : 0 );
259  auto it = m_cnvServices.find( type );
260  auto cnv_svc = ( it != m_cnvServices.end() ? it->second.conversionSvc() : nullptr );
261  if ( type == def_typ ) m_cnvDefault = servc;
262  if ( cnv_svc == servc ) return StatusCode::SUCCESS;
263 
264  auto iservc = make_SmartIF( servc );
265  auto icr = iservc.as<IAddressCreator>();
266  if ( icr ) {
267  auto isvc = iservc.as<IService>();
268  if ( isvc ) {
269  if ( cnv_svc ) removeCnvService (type).ignore();
270  auto p = m_cnvServices.emplace( type, ServiceEntry(type, isvc, iservc, icr) );
271  if( !p.second ) {
272  info() << "Cannot add Conversion service of type " << isvc->name() << endmsg;
273  return StatusCode::FAILURE;
274  }
275  info() << "Added successfully Conversion service:" << isvc->name() << endmsg;
276  iservc->setAddressCreator(this).ignore();
277  iservc->setDataProvider(m_dataSvc).ignore();
278  return StatusCode::SUCCESS;
279  }
280  }
281  info() << "Cannot add Conversion service of type " << type << endmsg;
282  return StatusCode::FAILURE;
283 }
SmartIF< IConversionSvc > & conversionSvc() const
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
IAddressCreator interface definition.
T end(T...args)
string type
Definition: gaudirun.py:151
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
General service interface definition.
Definition: IService.h:18
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
StatusCode removeCnvService(long type) override
Remove a Service.
T find(T...args)
Services m_cnvServices
List of convermsion workers.
T emplace(T...args)
SmartIF< IFace > make_SmartIF(IFace *iface)
Definition: SmartIF.h:143
void ignore() const
Definition: StatusCode.h:108
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to datma provider service.
StatusCode PersistencySvc::addConverter ( IConverter pConverter)
override

Add converter object to conversion service.

Definition at line 199 of file PersistencySvc.cpp.

199  {
200  if ( !pConverter ) return NO_CONVERTER;
201  IConversionSvc* svc = service(pConverter->repSvcType());
202  return svc ? svc->addConverter(pConverter) : BAD_STORAGE_TYPE;
203 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
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.
StatusCode PersistencySvc::addConverter ( const CLID clid)
override

Add converter object to conversion service.

Definition at line 194 of file PersistencySvc.cpp.

194  {
195  return StatusCode::FAILURE;
196 }
SmartIF< IAddressCreator > & PersistencySvc::addressCreator ( ) const
override

Retrieve address creator facility.

Definition at line 447 of file PersistencySvc.cpp.

447  {
448  return m_addrCreator;
449 }
SmartIF< IAddressCreator > m_addrCreator
Pointer to the IAddressCreator interface of this, for addressCreator().
SmartIF< IAddressCreator > & PersistencySvc::addressCreator ( long  service_type)
protected

Retrieve address creator from list.

Retrieve address creator service from list.

Definition at line 153 of file PersistencySvc.cpp.

153  {
154  long typ = type;
155  auto it = m_cnvServices.find( typ );
156  if( it == m_cnvServices.end() ) {
158  if ( s ) {
159  it = m_cnvServices.find( typ );
160  if ( it != m_cnvServices.end() ) return it->second.addrCreator();
161  }
162  static SmartIF<IAddressCreator> no_creator;
163  return no_creator;
164  }
165  return it->second.addrCreator();
166 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
SmartIF< IAddressCreator > & addrCreator() const
T end(T...args)
string type
Definition: gaudirun.py:151
T find(T...args)
Services m_cnvServices
List of convermsion workers.
string s
Definition: gaudirun.py:245
StatusCode PersistencySvc::commitOutput ( const std::string output,
bool  do_commit 
)
override

Commit pending output.

Definition at line 318 of file PersistencySvc.cpp.

318  {
319  return StatusCode::SUCCESS;
320 }
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 307 of file PersistencySvc.cpp.

308  {
309  return connectOutput(outputFile);
310 }
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
StatusCode PersistencySvc::connectOutput ( const std::string outputFile)
override

Connect the output file to the service.

Definition at line 313 of file PersistencySvc.cpp.

313  {
314  return StatusCode::SUCCESS;
315 }
SmartIF< IConversionSvc > & PersistencySvc::conversionSvc ( ) const
override

Get conversion service the converter is connected to.

Definition at line 189 of file PersistencySvc.cpp.

189  {
190  return m_cnvDefault;
191 }
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
StatusCode PersistencySvc::convertAddress ( const IOpaqueAddress pAddress,
std::string refAddress 
)
override

Convert an address to string form.

Definition at line 335 of file PersistencySvc.cpp.

337 {
338  // Assumuption is that the Persistency service prepends a header
339  // and requests the conversion service refered to by the service
340  // type to encode the rest
341  long svc_type = 0;
342  CLID clid = 0;
343  if ( pAddress ) {
344  svc_type = pAddress->svcType();
345  clid = pAddress->clID();
346  }
347  IAddressCreator* svc = addressCreator(svc_type);
348  StatusCode status = BAD_STORAGE_TYPE; // Preset error
349  refAddress.clear();
350 
351  if ( svc ) {
352  // Found service, set header
353  encodeAddrHdr(svc_type, clid, refAddress);
354  std::string address;
355  // Get rest of address from conversion service
356  status = svc->convertAddress(pAddress, address);
357  refAddress += address;
358  }
359  return status;
360 }
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
IAddressCreator interface definition.
virtual long svcType() const =0
Retrieve service type.
STL class.
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.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
T clear(T...args)
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress)=0
Convert an address to string form.
IConverter * PersistencySvc::converter ( const CLID clid)
override

Retrieve converter from list.

Definition at line 217 of file PersistencySvc.cpp.

217  {
218  return nullptr;
219 }
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 323 of file PersistencySvc.cpp.

327  {
328  refpAddress = nullptr;
329  IAddressCreator* svc = addressCreator(svc_type);
330  return svc ? svc->createAddress(svc_type, clid, pars, ipars, refpAddress)
331  : BAD_STORAGE_TYPE;
332 }
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
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.
IAddressCreator interface definition.
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 363 of file PersistencySvc.cpp.

367 {
368  // Assumption is that the Persistency service decodes that header
369  // and requests the conversion service referred to by the service
370  // type to decode the rest
371  long new_svc_type = 0;
372  CLID new_clid = 0;
373  std::string address_trailer;
374  decodeAddrHdr(refAddress, new_svc_type, new_clid, address_trailer);
375  IAddressCreator* svc = addressCreator(new_svc_type);
376  return svc ? svc->createAddress( new_svc_type, new_clid, address_trailer, refpAddress)
377  : BAD_STORAGE_TYPE;
378 }
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
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.
IAddressCreator interface definition.
STL class.
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
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 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 113 of file PersistencySvc.cpp.

113  {
114  return makeCall(CREATE_OBJ, pAddr, refpObj);
115 }
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
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 133 of file PersistencySvc.cpp.

133  {
134  return makeCall(CREATE_REP, refpAddr, pObj);
135 }
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
SmartIF< IDataProviderSvc > & PersistencySvc::dataProvider ( ) const
override

Access reference to transient datastore.

Access the dataprovider service.

Definition at line 178 of file PersistencySvc.cpp.

178  {
179  return m_dataSvc;
180 }
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to datma provider service.
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 394 of file PersistencySvc.cpp.

398 {
399  // For address header, use xml-style format of
400  // <address_header service_type="xxx" clid="yyy" />
401  service_type = 0;
402  clid = 0;
403  address_trailer.clear();
404 
405  // Check for address_header tag
406  size_t pos = address.find("<address_header");
407  if (std::string::npos != pos) {
408  // Get service_type
409  pos = address.find("service_type=\"");
410  if (std::string::npos != pos) {
411  pos += 14;
412  size_t end = address.find('"', pos);
413  if (std::string::npos != end) {
414  service_type = std::stol(address.substr(pos, end-pos));
415  // Get clid
416  pos = address.find("clid=\"");
417  if (std::string::npos != pos) {
418  pos += 6;
419  end = address.find('\"', pos);
420  if (std::string::npos != end) {
421  std::istringstream str;
422  str.str(address.substr(pos, end-pos));
423  str >> clid;
424  // Get trailer_address
425  pos = address.find('>');
426  if (pos < (address.size()-2)) { // this means that '>' was found (pos != npos)
427  // it is before the last char
428  address_trailer = address.substr(pos+1);
429  }
430  }
431  }
432  }
433  }
434  }
435 }
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
T clear(T...args)
T find(T...args)
T size(T...args)
T substr(T...args)
T stol(T...args)
bool PersistencySvc::enable ( bool  value)
protected

Set enabled flag.

Definition at line 560 of file PersistencySvc.cpp.

561 {
563  return value;
564 }
T swap(T...args)
bool m_enable
Flag to indicate that the service is enabled.
void PersistencySvc::encodeAddrHdr ( long  service_type,
const CLID clid,
std::string address 
) const
protected

Retrieve string from storage type and clid.

Definition at line 381 of file PersistencySvc.cpp.

384 {
385  // For address header, use xml-style format of
386  // <addrhdr service_type="xxx" clid="yyy" />
387  std::stringstream stream;
388  int svctyp = service_type; // must put int into stream, not char
389  stream << "<address_header service_type=\"" << svctyp << "\" clid=\"" << clid << "\" /> ";
390  address = stream.str();
391 }
T str(T...args)
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 118 of file PersistencySvc.cpp.

118  {
119  return makeCall(FILL_OBJ_REFS, pAddr, pObj);
120 }
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
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 138 of file PersistencySvc.cpp.

138  {
139  return makeCall(FILL_REP_REFS, pAddr, pObj);
140 }
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
StatusCode PersistencySvc::finalize ( )
override

stop the service.

Definition at line 547 of file PersistencySvc.cpp.

547  {
548  // Release all workers
550  // Release references to this to avoid loops
551  m_addrCreator = nullptr;
552  return StatusCode::SUCCESS;
553 }
SmartIF< IAddressCreator > m_addrCreator
Pointer to the IAddressCreator interface of this, for addressCreator().
T clear(T...args)
Services m_cnvServices
List of convermsion workers.
StatusCode PersistencySvc::getService ( long  service_type,
IConversionSvc *&  refpSvc 
)
override

Retrieve conversion service identified by technology.

Definition at line 452 of file PersistencySvc.cpp.

452  {
453  refpSvc = service(service_type);
454  return refpSvc ? StatusCode::SUCCESS : StatusCode::FAILURE;
455 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
StatusCode PersistencySvc::getService ( const std::string service_type,
IConversionSvc *&  refpSvc 
)
override

Retrieve conversion service identified by technology.

Definition at line 458 of file PersistencySvc.cpp.

458  {
459  const char* imp = service_type.c_str();
460  long len = service_type.length();
461  if ( ::strncasecmp(imp,"SICB", len) == 0 )
462  return getService(SICB_StorageType, refpSvc);
463  else if ( ::strncasecmp(imp,"ZEBRA", len) == 0 )
464  return getService(SICB_StorageType, refpSvc);
465  else if ( ::strncasecmp(imp,"MS Access", len) == 0 )
466  return getService(ACCESS_StorageType, refpSvc);
467  else if ( ::strncasecmp(imp,"Microsoft Access", strlen("Microsoft Access")) == 0 )
468  return getService(ACCESS_StorageType, refpSvc);
469  else if ( ::strncasecmp(imp,"SQL Server", len) == 0 )
470  return getService(SQLSERVER_StorageType, refpSvc);
471  else if ( ::strncasecmp(imp,"Microsoft ODBC for Oracle", len) == 0 )
472  return getService(ORACLE_StorageType, refpSvc);
473  else if ( ::strncasecmp(imp,"Oracle ODBC", strlen("Oracle ODBC")) == 0 )
474  return getService(ORACLE_StorageType, refpSvc);
475  else if ( ::strncasecmp(imp,"Oracle OCI", strlen("Oracle OCI")) == 0 )
476  return getService(ORACLE_StorageType, refpSvc);
477  else if ( ::strncasecmp(imp,"MySQL", len) == 0 )
478  return getService(MYSQL_StorageType, refpSvc);
479  else if ( ::strncasecmp(imp,"ROOT", len) == 0 )
480  return getService(ROOT_StorageType, refpSvc);
481  else if ( ::strncasecmp(imp,"OBJY", len) == 0 )
482  return getService(OBJY_StorageType, refpSvc);
483  else if ( ::strncasecmp(imp,"OBJYECTI", 7) == 0 )
484  return getService(OBJY_StorageType, refpSvc);
485  else if ( ::strncasecmp(imp,"POOL_ROOTKEY", 12) == 0 )
486  return getService(POOL_ROOTKEY_StorageType, refpSvc);
487  else if ( ::strncasecmp(imp,"POOL_ROOTTREE", 12) == 0 )
488  return getService(POOL_ROOTTREE_StorageType, refpSvc);
489  else if ( ::strncasecmp(imp,"POOL_ROOT", 9) == 0 )
490  return getService(POOL_ROOT_StorageType, refpSvc);
491  else if ( ::strncasecmp(imp,"POOL_MySQL", 8) == 0 )
492  return getService(POOL_MYSQL_StorageType, refpSvc);
493  else if ( ::strncasecmp(imp,"POOL_ORACLE", 8) == 0 )
494  return getService(POOL_ORACLE_StorageType, refpSvc);
495  else if ( ::strncasecmp(imp,"POOL_ACCESS", 8) == 0 )
496  return getService(POOL_ACCESS_StorageType, refpSvc);
497  else if ( ::strncasecmp(imp,"POOL", 4) == 0 )
498  return getService(POOL_StorageType, refpSvc);
499 
500  for(const auto& i : m_cnvServices) {
501  SmartIF<IService> svc(i.second.conversionSvc());
502  if ( svc ) {
503  // Check wether this is already an active service: first check by service name
504  if ( svc->name() == service_type ) {
505  refpSvc = i.second.conversionSvc();
506  return StatusCode::SUCCESS;
507  }
508  // Check wether this is already an active service: now check by service type
509  auto instance = svc.get();
510  if ( System::typeinfoName(typeid(*instance)) == service_type ) {
511  refpSvc = i.second.conversionSvc();
512  return StatusCode::SUCCESS;
513  }
514  }
515  }
516  // if not, check if the service is in the list and may be requested
517  for(const auto& i : m_svcNames.value() ) {
519  if ( itm.name() == service_type || itm.type() == service_type ) {
520  IConversionSvc* svc = service(i);
521  if ( svc ) {
522  refpSvc = svc;
523  return StatusCode::SUCCESS;
524  }
525  }
526  }
527  return StatusCode::FAILURE;
528 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
tuple itm
Definition: ana.py:57
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
const long ACCESS_StorageType
Definition: ClassID.h:60
StringArrayProperty m_svcNames
Names of services to be requested from the service locator and added by default.
const long MYSQL_StorageType
Definition: ClassID.h:64
const long POOL_MYSQL_StorageType
Definition: ClassID.h:72
const long POOL_ROOTKEY_StorageType
Definition: ClassID.h:69
const long POOL_ACCESS_StorageType
Definition: ClassID.h:71
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
T strlen(T...args)
StatusCode getService(long service_type, IConversionSvc *&refpSvc) override
Retrieve conversion service identified by technology.
const long POOL_ORACLE_StorageType
Definition: ClassID.h:73
const long ROOT_StorageType
Definition: ClassID.h:52
const long ORACLE_StorageType
Definition: ClassID.h:65
const long POOL_ROOT_StorageType
Definition: ClassID.h:68
const TYPE & value() const
explicit conversion
Definition: Property.h:341
const long POOL_StorageType
Definition: ClassID.h:67
T length(T...args)
const long POOL_ROOTTREE_StorageType
Definition: ClassID.h:70
T c_str(T...args)
Services m_cnvServices
List of convermsion workers.
const long SQLSERVER_StorageType
Definition: ClassID.h:63
const long OBJY_StorageType
Definition: ClassID.h:53
const long SICB_StorageType
Definition: ClassID.h:51
list i
Definition: ana.py:128
StatusCode PersistencySvc::initialize ( )
override

Initialize the service.

Definition at line 536 of file PersistencySvc.cpp.

536  {
537  m_addrCreator = this; // initialize internal pointer to IAddressCreator interface
538  // Initialize basic service
539  StatusCode status = Service::initialize();
540  if ( UNLIKELY(!status.isSuccess()) ) {
541  error() << "Error initializing Service base class." << endmsg;
542  }
543  return status;
544 }
SmartIF< IAddressCreator > m_addrCreator
Pointer to the IAddressCreator interface of this, for addressCreator().
#define UNLIKELY(x)
Definition: Kernel.h:126
StatusCode initialize() override
Definition: Service.cpp:68
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode PersistencySvc::makeCall ( int  typ,
IOpaqueAddress *&  pAddress,
DataObject *&  pObject 
)
protected

Implementation helper.

Definition at line 56 of file PersistencySvc.cpp.

58  {
59  if ( m_enable ) {
60  IConversionSvc* svc = nullptr;
61  switch(typ) {
62  case CREATE_REP:
63  case FILL_REP_REFS:
64  case UPDATE_REP:
65  case UPDATE_REP_REFS:
66  svc = m_cnvDefault;
67  break;
68  default:
69  if ( !pAddress ) return INVALID_ADDRESS;
70  svc = service(pAddress->svcType());
71  if ( !svc ) return BAD_STORAGE_TYPE;
72  break;
73  }
74 
75  StatusCode status(StatusCode::FAILURE,true);
76  switch( typ ) {
77  case CREATE_OBJ:
78  pObject = nullptr;
79  status = svc->createObj(pAddress, pObject);
80  break;
81  case FILL_OBJ_REFS:
82  status = svc->fillObjRefs(pAddress, pObject);
83  break;
84  case UPDATE_OBJ:
85  status = svc->updateObj(pAddress, pObject);
86  break;
87  case UPDATE_OBJ_REFS:
88  status = svc->updateObjRefs(pAddress, pObject);
89  break;
90  case CREATE_REP:
91  status = svc->createRep(pObject, pAddress);
92  break;
93  case FILL_REP_REFS:
94  status = svc->fillRepRefs(pAddress, pObject);
95  break;
96  case UPDATE_REP:
97  status = svc->updateRep(pAddress, pObject);
98  break;
99  case UPDATE_REP_REFS:
100  status = svc->updateRepRefs(pAddress, pObject);
101  break;
102  default:
103  status = StatusCode::FAILURE;
104  break;
105  }
106  status.ignore();
107  return status;
108  }
109  return StatusCode::SUCCESS;
110 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
bool m_enable
Flag to indicate that the service is enabled.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
virtual long svcType() const =0
Retrieve service type.
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
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 531 of file PersistencySvc.cpp.

531  {
532  return CLID_NULL;
533 }
StatusCode PersistencySvc::removeCnvService ( long  type)
override

Remove a Service.

Remove conversion service.

Definition at line 286 of file PersistencySvc.cpp.

286  {
287  auto it = m_cnvServices.find( svctype );
288  if( it == m_cnvServices.end() ) return BAD_STORAGE_TYPE;
289  it->second.service()->release();
290  it->second.addrCreator()->release();
291  m_cnvServices.erase(it);
292  return StatusCode::SUCCESS;
293 }
SmartIF< IService > & service() const
T end(T...args)
T erase(T...args)
T find(T...args)
Services m_cnvServices
List of convermsion workers.
StatusCode PersistencySvc::removeConverter ( const CLID clid)
override

Remove converter object from conversion service (if present).

Definition at line 206 of file PersistencySvc.cpp.

206  {
207  // Remove converter type from all services
208  StatusCode status = NO_CONVERTER, iret = StatusCode::SUCCESS;
209  for ( auto& i : m_cnvServices ) {
210  iret = i.second.conversionSvc()->removeConverter(clid);
211  if ( iret.isSuccess() ) status = iret;
212  }
213  return status;
214 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Services m_cnvServices
List of convermsion workers.
list i
Definition: ana.py:128
long PersistencySvc::repSvcType ( ) const
override

Return default service type.

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

Definition at line 296 of file PersistencySvc.cpp.

296  {
297  return m_cnvDefault ? m_cnvDefault->repSvcType() : 0;
298 }
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
SmartIF< IConversionSvc > & PersistencySvc::service ( const std::string nam)
protected

Retrieve conversion service by name.

Definition at line 222 of file PersistencySvc.cpp.

222  {
225  [&](Services::const_reference i) {
226  return i.second.service()->name() == tn.name();
227  } );
228  if (it!=m_cnvServices.end()) return it->second.conversionSvc();
229 
230  auto svc = Service::service<IConversionSvc>(nam, true);
231  if ( svc && addCnvService(svc.get()).isSuccess() ) {
232  return service(nam); // now it is in the list
233  }
234 
235  info() << "Cannot access Conversion service:" << nam << endmsg;
236  static SmartIF<IConversionSvc> no_svc;
237  return no_svc;
238 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
T end(T...args)
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
StatusCode addCnvService(IConversionSvc *service) override
Add a new Service.
T find_if(T...args)
T begin(T...args)
Services m_cnvServices
List of convermsion workers.
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< IConversionSvc > & PersistencySvc::service ( long  service_type)
protected

Retrieve conversion service from list.

Definition at line 241 of file PersistencySvc.cpp.

241  {
242  // Check wether this is already an active service
243  auto it = m_cnvServices.find( type );
244  if( it != m_cnvServices.end() ) return it->second.conversionSvc();
245  // if not, check if the service is in the list and may be requested
246  for ( const auto& i : m_svcNames.value() ) {
247  auto& svc = service(i);
248  if ( svc && svc->repSvcType() == type ) return svc;
249  }
250  static SmartIF<IConversionSvc> no_svc;
251  return no_svc;
252 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
SmartIF< IConversionSvc > & conversionSvc() const
T end(T...args)
StringArrayProperty m_svcNames
Names of services to be requested from the service locator and added by default.
string type
Definition: gaudirun.py:151
const TYPE & value() const
explicit conversion
Definition: Property.h:341
T find(T...args)
Services m_cnvServices
List of convermsion workers.
list i
Definition: ana.py:128
StatusCode PersistencySvc::setAddressCreator ( IAddressCreator creator)
override

Set address creator facility.

Definition at line 438 of file PersistencySvc.cpp.

438  {
439  // The persistency service is a address creation dispatcher istelf.
440  // The persistency service can NEVER create addresses itself.
441  // The entry point must only be provided in order to fulfill the needs of the
442  // implementing interfaces.
443  return StatusCode::FAILURE;
444 }
StatusCode PersistencySvc::setConversionSvc ( IConversionSvc svc)
override

Set conversion service the converter is connected to.

Definition at line 183 of file PersistencySvc.cpp.

183  {
184  m_cnvDefault = svc;
185  return StatusCode(StatusCode::SUCCESS,true);
186 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
StatusCode PersistencySvc::setDataProvider ( IDataProviderSvc pStore)
override

Define transient datastore.

Define transient data store.

Definition at line 169 of file PersistencySvc.cpp.

169  {
170  m_dataSvc = pDataSvc;
171  for (auto& i : m_cnvServices) {
172  i.second.conversionSvc()->setDataProvider(m_dataSvc).ignore();
173  }
174  return StatusCode(StatusCode::SUCCESS,true);
175 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Services m_cnvServices
List of convermsion workers.
list i
Definition: ana.py:128
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to datma provider service.
StatusCode PersistencySvc::setDefaultCnvService ( long  type)
override

Set default service type.

Set default conversion service.

Definition at line 301 of file PersistencySvc.cpp.

301  {
303  return StatusCode::SUCCESS;
304 }
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
string type
Definition: gaudirun.py:151
SmartIF< IConversionSvc > m_cnvDefault
Default output service.
void PersistencySvc::svcNamesHandler ( Property theProp)
protected

Handlers for Service Names Property.

Definition at line 555 of file PersistencySvc.cpp.

555  {
556  DEBMSG << p << endmsg;
557 }
#define DEBMSG
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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 123 of file PersistencySvc.cpp.

123  {
124  return makeCall(UPDATE_OBJ, pAddr, pObj);
125 }
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
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 128 of file PersistencySvc.cpp.

128  {
129  return makeCall(UPDATE_OBJ_REFS, pAddr, pObj);
130 }
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
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 143 of file PersistencySvc.cpp.

143  {
144  return makeCall(UPDATE_REP, pAddr, pObj);
145 }
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.
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 148 of file PersistencySvc.cpp.

148  {
149  return makeCall(UPDATE_REP_REFS, pAddr, pObj);
150 }
StatusCode makeCall(int typ, IOpaqueAddress *&pAddress, DataObject *&pObject)
Implementation helper.

Member Data Documentation

SmartIF<IAddressCreator> PersistencySvc::m_addrCreator
mutableprotected

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

Definition at line 282 of file PersistencySvc.h.

SmartIF<IConversionSvc> PersistencySvc::m_cnvDefault
mutableprotected

Default output service.

Definition at line 273 of file PersistencySvc.h.

long PersistencySvc::m_cnvDefType = TEST_StorageType
protected

Default service type.

Definition at line 267 of file PersistencySvc.h.

Services PersistencySvc::m_cnvServices
protected

List of convermsion workers.

Definition at line 271 of file PersistencySvc.h.

SmartIF<IDataProviderSvc> PersistencySvc::m_dataSvc
mutableprotected

Pointer to datma provider service.

Definition at line 269 of file PersistencySvc.h.

bool PersistencySvc::m_enable = true
protected

Flag to indicate that the service is enabled.

Definition at line 279 of file PersistencySvc.h.

StringArrayProperty PersistencySvc::m_svcNames
protected

Names of services to be requested from the service locator and added by default.

Definition at line 277 of file PersistencySvc.h.


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