| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# PersistencySvc Class Reference

`#include <PersistencySvc.h>`

Inheritance diagram for PersistencySvc:

[legend]
Collaboration diagram for PersistencySvc:

[legend]

List of all members.

## Detailed Description

PersistencySvc class implementation definition.

System: The LHCb Offline System

Package: PersistencySvc

Dependencies:

- STL: <vector>, <algorithm>, <functional>
- Generic service definiton: "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 53 of file PersistencySvc.h.

## : Object implementation
| PersistencySvc (const std::string &name, ISvcLocator *svc)
| Standard Constructor.
virtual | ~PersistencySvc ()
| Standard Destructor.
IConversionSvc * | service (const std::string &nam)
| Retrieve conversion service by name.
IConversionSvc * | service (long service_type)
| Retrieve conversion service from list.
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.
## Public Member Functions
IPersistencySvc Interface implementation
long | repSvcType () const
| Return default service type.
const CLID & | objType () const
| Retrieve the class type of objects the converter produces. (DUMMY).
virtual StatusCode | createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
| Implementation of IConverter: Create the transient representation of an object.
virtual StatusCode | fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
| Implementation of IConverter: Resolve the references of the created transient object.
virtual StatusCode | updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
| Implementation of IConverter: Update the transient object from the other representation.
virtual StatusCode | updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
| Implementation of IConverter: Update the references of an updated transient object.
virtual StatusCode | createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
| Implementation of IConverter: Convert the transient object to the requested representation.
virtual StatusCode | fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
| Implementation of IConverter: Resolve the references of the converted object.
virtual StatusCode | updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
| Implementation of IConverter: Update the converted representation of a transient object.
virtual StatusCode | updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
| Implementation of IConverter: Update the references of an already converted object.
virtual StatusCode | setDataProvider (IDataProviderSvc *pStore)
| Define transient datastore.
virtual IDataProviderSvc * | dataProvider () const
| Access reference to transient datastore.
virtual StatusCode | setConversionSvc (IConversionSvc *svc)
| Set conversion service the converter is connected to.
virtual IConversionSvc * | conversionSvc () const
| Get conversion service the converter is connected to.
virtual StatusCode | setAddressCreator (IAddressCreator *creator)
| Set address creator facility.
virtual IAddressCreator * | addressCreator () const
| Retrieve address creator facility.
virtual StatusCode | addConverter (IConverter *pConverter)
| Add converter object to conversion service.
virtual StatusCode | addConverter (const CLID &clid)
| Add converter object to conversion service.
virtual IConverter * | converter (const CLID &clid)
| Retrieve converter from list.
virtual StatusCode | removeConverter (const CLID &clid)
| Remove converter object from conversion service (if present).
virtual StatusCode | connectOutput (const std::string &outputFile, const std::string &openMode)
| Connect the output file to the service with open mode.
virtual StatusCode | connectOutput (const std::string &outputFile)
| Connect the output file to the service.
virtual StatusCode | commitOutput (const std::string &output, bool do_commit)
| Commit pending output.
virtual StatusCode | createAddress (long svc_type, const CLID &clid, const std::string *pars, const unsigned long *ipars, IOpaqueAddress *&refpAddress)
| Create a Generic address using explicit arguments to identify a single object.
virtual StatusCode | convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress)
| Convert an address to string form.
virtual StatusCode | createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress)
| Convert an address in string form to object form.
: IPersistencySvc implementation
virtual StatusCode | addCnvService (IConversionSvc *service)
| Add a new Service.
virtual StatusCode | removeCnvService (long type)
| Remove a Service.
virtual StatusCode | setDefaultCnvService (long type)
| Set default service type.
virtual StatusCode | getService (long service_type, IConversionSvc *&refpSvc)
| Retrieve conversion service identified by technology.
virtual StatusCode | getService (const std::string &service_type, IConversionSvc *&refpSvc)
| Retrieve conversion service identified by technology.
: IService implementation
virtual StatusCode | initialize ()
| Initialize the service.
virtual StatusCode | finalize ()
| stop the service.
: IInterface implementation
StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown)
| Query interface.
## Protected Types
typedef std::map< long, ServiceEntry > | Services
## Protected Member Functions
void | svcNamesHandler (Property &theProp)
| Handlers for Service Names Property.
## Protected Attributes
long | m_cnvDefType
| Default service type.
IDataProviderSvc * | m_dataSvc
| Pointer to datma provider service.
Services | m_cnvServices
| List of convermsion workers.
IConversionSvc * | m_cnvDefault
| Default output service.
StringArrayProperty | m_svcNames
| Names of services to be requested from the service locator and added by default.
bool | m_enable
| Flag to indicate that the service is enabled.
## Friends
class | SvcFactory< PersistencySvc >
class | Factory< PersistencySvc, IService *(std::string, ISvcLocator *)>
## Classes
class | ServiceEntry

## Member Typedef Documentation

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

Definition at line 97 of file PersistencySvc.h.

## Constructor & Destructor Documentation

PersistencySvc::PersistencySvc | ( | const std::string & | name,
|  | ISvcLocator * | svc |
| ) |  |  |

Standard Constructor.

Definition at line 647 of file PersistencySvc.cpp.

    00648 :  Service(name, svc),
    00649    m_cnvDefType(TEST_StorageType),
    00650    m_dataSvc(0),
    00651    m_cnvDefault(0),
    00652    m_enable(true)
    00653 {
    00654   declareProperty("CnvServices", m_svcNames);
    00655   m_svcNames.declareUpdateHandler( &PersistencySvc::svcNamesHandler, this );
    00656 }

PersistencySvc::~PersistencySvc | ( |  | ) | `[virtual]`

Standard Destructor.

Definition at line 659 of file PersistencySvc.cpp.

    00659                                   {
    00660 }

## Member Function Documentation

long PersistencySvc::repSvcType | ( |  | ) | const`[virtual]`

Return default service type.

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

Implements IConverter.

Definition at line 337 of file PersistencySvc.cpp.

    00337                                       {
    00338   long typ = (m_cnvDefault) ? m_cnvDefault->repSvcType() : 0;
    00339   return typ;
    00340 }

const CLID & PersistencySvc::objType | ( |  | ) | const`[virtual]`

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

Retrieve the class type of objects the converter produces.

Implements IConverter.

Definition at line 584 of file PersistencySvc.cpp.

    00584                                              {
    00585   return CLID_NULL;
    00586 }

StatusCode PersistencySvc::createObj | ( | IOpaqueAddress * | pAddress,
|  | DataObject *& | refpObject |
| ) |  |  | `[virtual]`

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

Create the transient representation of an object.

Implements IConverter.

Definition at line 115 of file PersistencySvc.cpp.

    00115                                                                                   {
    00116   return makeCall(CREATE_OBJ, pAddr, refpObj);
    00117 }

StatusCode PersistencySvc::fillObjRefs | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | pObject |
| ) |  |  | `[virtual]`

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

Resolve the references of the created transient object.

Implements IConverter.

Definition at line 120 of file PersistencySvc.cpp.

    00120                                                                                  {
    00121   return makeCall(FILL_OBJ_REFS, pAddr, pObj);
    00122 }

StatusCode PersistencySvc::updateObj | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | refpObject |
| ) |  |  | `[virtual]`

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

Update the transient object from the other representation.

Implements IConverter.

Definition at line 125 of file PersistencySvc.cpp.

    00125                                                                               {
    00126   return makeCall(UPDATE_OBJ, pAddr, pObj);
    00127 }

StatusCode PersistencySvc::updateObjRefs | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | pObject |
| ) |  |  | `[virtual]`

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

Update the references of an updated transient object.

Implements IConverter.

Definition at line 130 of file PersistencySvc.cpp.

    00130                                                                                  {
    00131   return makeCall(UPDATE_OBJ_REFS, pAddr, pObj);
    00132 }

StatusCode PersistencySvc::createRep | ( | DataObject * | pObject,
|  | IOpaqueAddress *& | refpAddress |
| ) |  |  | `[virtual]`

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

Convert the transient object to the requested representation.

Implements IConverter.

Reimplemented in HistogramPersistencySvc.

Definition at line 135 of file PersistencySvc.cpp.

    00135                                                                                  {
    00136   return makeCall(CREATE_REP, refpAddr, pObj);
    00137 }

StatusCode PersistencySvc::fillRepRefs | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | pObject |
| ) |  |  | `[virtual]`

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

Resolve the references of the converted object.

Implements IConverter.

Definition at line 140 of file PersistencySvc.cpp.

    00140                                                                                {
    00141   return makeCall(FILL_REP_REFS, pAddr, pObj);
    00142 }

StatusCode PersistencySvc::updateRep | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | pObject |
| ) |  |  | `[virtual]`

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

Update the converted representation of a transient object.

Implements IConverter.

Definition at line 145 of file PersistencySvc.cpp.

    00145                                                                              {
    00146   return makeCall(UPDATE_REP, pAddr, pObj);
    00147 }

StatusCode PersistencySvc::updateRepRefs | ( | IOpaqueAddress * | pAddress,
|  | DataObject * | pObject |
| ) |  |  | `[virtual]`

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

Update the references of an already converted object.

Implements IConverter.

Definition at line 150 of file PersistencySvc.cpp.

    00150                                                                                    {
    00151   return makeCall(UPDATE_REP_REFS, pAddr, pObj);
    00152 }

StatusCode PersistencySvc::setDataProvider | ( | IDataProviderSvc * | pStore | ) | `[virtual]`

Define transient datastore.

Define transient data store.

Implements IConverter.

Definition at line 172 of file PersistencySvc.cpp.

    00172                                                                         {
    00173   m_dataSvc = pDataSvc;
    00174   for ( Services::iterator i = m_cnvServices.begin(); i != m_cnvServices.end(); i++ )   {
    00175     (*i).second.conversionSvc()->setDataProvider(m_dataSvc).ignore();
    00176   }
    00177   return StatusCode(StatusCode::SUCCESS,true);
    00178 }

IDataProviderSvc * PersistencySvc::dataProvider | ( |  | ) | const`[virtual]`

Access reference to transient datastore.

Access the dataprovider service.

Implements IConverter.

Definition at line 181 of file PersistencySvc.cpp.

    00181                                                        {
    00182   return m_dataSvc;
    00183 }

StatusCode PersistencySvc::setConversionSvc | ( | IConversionSvc * | svc | ) | `[virtual]`

Set conversion service the converter is connected to.

Implements IConverter.

Definition at line 186 of file PersistencySvc.cpp.

    00186                                                                  {
    00187   m_cnvDefault = svc;
    00188   return StatusCode(StatusCode::SUCCESS,true);
    00189 }

IConversionSvc * PersistencySvc::conversionSvc | ( |  | ) | const`[virtual]`

Get conversion service the converter is connected to.

Implements IConverter.

Definition at line 192 of file PersistencySvc.cpp.

    00192                                                          {
    00193   return m_cnvDefault;
    00194 }

StatusCode PersistencySvc::setAddressCreator | ( | IAddressCreator * | creator | ) | `[virtual]`

Set address creator facility.

Implements IConverter.

Definition at line 491 of file PersistencySvc.cpp.

    00491                                                                 {
    00492   // The persistency service is a address creation dispatcher istelf.
    00493   // The persistency service can NEVER create addresses itself.
    00494   // The entry point must only be provided in order to fulfill the needs of the
    00495   // implementing interfaces.
    00496   return StatusCode::FAILURE;
    00497 }

IAddressCreator * PersistencySvc::addressCreator | ( |  | ) | const`[virtual]`

Retrieve address creator facility.

Implements IConverter.

Definition at line 500 of file PersistencySvc.cpp.

    00500                                                           {
    00501   return (IAddressCreator*)this;
    00502 }

StatusCode PersistencySvc::addConverter | ( | IConverter * | pConverter | ) | `[virtual]`

Add converter object to conversion service.

Implements IConversionSvc.

Definition at line 202 of file PersistencySvc.cpp.

    00202                                                                  {
    00203   if ( 0 != pConverter )    {
    00204     long typ  = pConverter->repSvcType();
    00205     IConversionSvc* svc = service(typ);
    00206     if ( 0 != svc )   {
    00207       return svc->addConverter(pConverter);
    00208     }
    00209     return BAD_STORAGE_TYPE;
    00210   }
    00211   return NO_CONVERTER;
    00212 }

StatusCode PersistencySvc::addConverter | ( | const CLID & | clid | ) | `[virtual]`

Add converter object to conversion service.

Implements IConversionSvc.

Definition at line 197 of file PersistencySvc.cpp.

    00197                                                                {
    00198   return StatusCode::FAILURE;
    00199 }

IConverter * PersistencySvc::converter | ( | const CLID & | clid | ) | `[virtual]`

Retrieve converter from list.

Implements IConversionSvc.

Definition at line 228 of file PersistencySvc.cpp.

    00228                                                           {
    00229   return 0;
    00230 }

StatusCode PersistencySvc::removeConverter | ( | const CLID & | clid | ) | `[virtual]`

Remove converter object from conversion service (if present).

Implements IConversionSvc.

Definition at line 215 of file PersistencySvc.cpp.

    00215                                                             {
    00216   // Remove converter type from all services
    00217   StatusCode status = NO_CONVERTER, iret = StatusCode::SUCCESS;
    00218   for ( Services::iterator i = m_cnvServices.begin(); i != m_cnvServices.end(); i++ )    {
    00219     iret = (*i).second.conversionSvc()->removeConverter(clid);
    00220     if ( iret.isSuccess() )    {
    00221       status = iret;
    00222     }
    00223   }
    00224   return status;
    00225 }

StatusCode PersistencySvc::connectOutput | ( | const std::string & | outputFile,
|  | const std::string & | openMode |
| ) |  |  | `[virtual]`

Connect the output file to the service with open mode.

Implements IConversionSvc.

Definition at line 349 of file PersistencySvc.cpp.

    00350                                                                           {
    00351   return connectOutput(outputFile);
    00352 }

StatusCode PersistencySvc::connectOutput | ( | const std::string & | outputFile | ) | `[virtual]`

Connect the output file to the service.

Implements IConversionSvc.

Definition at line 355 of file PersistencySvc.cpp.

    00355                                                          {
    00356   return StatusCode::SUCCESS;
    00357 }

StatusCode PersistencySvc::commitOutput | ( | const std::string & | output,
|  | bool | do_commit |
| ) |  |  | `[virtual]`

Commit pending output.

Implements IConversionSvc.

Definition at line 360 of file PersistencySvc.cpp.

    00360                                                                 {
    00361   return StatusCode::SUCCESS;
    00362 }

StatusCode PersistencySvc::createAddress | ( | long | svc_type,
|  | const CLID & | clid,
|  | const std::string * | pars,
|  | const unsigned long * | ipars,
|  | IOpaqueAddress *& | refpAddress |
| ) |  |  | `[virtual]`

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

Implements IAddressCreator.

Definition at line 365 of file PersistencySvc.cpp.

    00369                                                                           {
    00370   IAddressCreator* svc = addressCreator(svc_type);
    00371   StatusCode   status  = BAD_STORAGE_TYPE;        // Preset error
    00372   refpAddress = 0;
    00373   if ( 0 != svc )   {
    00374     status = svc->createAddress(svc_type, clid, pars, ipars, refpAddress);
    00375   }
    00376   return status;
    00377 }

StatusCode PersistencySvc::convertAddress | ( | const IOpaqueAddress * | pAddress,
|  | std::string & | refAddress |
| ) |  |  | `[virtual]`

Convert an address to string form.

Implements IAddressCreator.

Definition at line 380 of file PersistencySvc.cpp.

    00382 {
    00383   // Assumuption is that the Persistency service prepends a header
    00384   // and requests the conversion service refered to by the service
    00385   // type to encode the rest
    00386   long svc_type = 0;
    00387   CLID clid = 0;
    00388   if ( 0 != pAddress ) {
    00389     svc_type = pAddress->svcType();
    00390     clid     = pAddress->clID();
    00391   }
    00392   IAddressCreator* svc = addressCreator(svc_type);
    00393   StatusCode   status  = BAD_STORAGE_TYPE;        // Preset error
    00394   refAddress = "";
    00395
    00396   if ( 0 != svc )   {
    00397     // Found service, set header
    00398     encodeAddrHdr(svc_type, clid, refAddress);
    00399     std::string address;
    00400     // Get rest of address from conversion service
    00401     status = svc->convertAddress(pAddress, address);
    00402     refAddress += address;
    00403   }
    00404   return status;
    00405 }

StatusCode PersistencySvc::createAddress | ( | long | svc_type,
|  | const CLID & | clid,
|  | const std::string & | refAddress,
|  | IOpaqueAddress *& | refpAddress |
| ) |  |  | `[virtual]`

Convert an address in string form to object form.

Implements IAddressCreator.

Definition at line 408 of file PersistencySvc.cpp.

    00412 {
    00413   // Assumuption is that the Persistency service decodes that header
    00414   // and requests the conversion service refered to by the service
    00415   // type to decode the rest
    00416   long new_svc_type = 0;
    00417   CLID new_clid = 0;
    00418   std::string address_trailer;
    00419   decodeAddrHdr(refAddress, new_svc_type, new_clid, address_trailer);
    00420   IAddressCreator* svc = addressCreator(new_svc_type);
    00421   StatusCode   status  = BAD_STORAGE_TYPE;        // Preset error
    00422   if ( 0 != svc )   {
    00423     status = svc->createAddress( new_svc_type, new_clid, address_trailer, refpAddress);
    00424   }
    00425   return status;
    00426 }

StatusCode PersistencySvc::addCnvService | ( | IConversionSvc * | service | ) | `[virtual]`

Add a new Service.

Add data service.

Implements IPersistencySvc.

Definition at line 275 of file PersistencySvc.cpp.

    00275                                                                  {
    00276   if ( 0 != servc )   {
    00277     long type = servc->repSvcType();
    00278     long def_typ = (m_cnvDefault) ? m_cnvDefault->repSvcType() : 0;
    00279     Services::iterator it = m_cnvServices.find( type );
    00280     IConversionSvc* cnv_svc = 0;
    00281     if ( it != m_cnvServices.end() )    {
    00282       cnv_svc = (*it).second.conversionSvc();
    00283     }
    00284     if ( type == def_typ )     {
    00285       m_cnvDefault = servc;
    00286     }
    00287     if ( cnv_svc != servc )   {
    00288       MsgStream log( msgSvc(), name() );
    00289       IAddressCreator* icr = 0;
    00290       StatusCode status  = servc->queryInterface(IID_IAddressCreator, pp_cast<void>(&icr));
    00291       if ( status.isSuccess() )   {
    00292         IService* isvc = 0;
    00293         status = servc->queryInterface(IID_IService, pp_cast<void>(&isvc));
    00294         if ( status.isSuccess() )    {
    00295           if ( 0 != cnv_svc )   {
    00296             removeCnvService (type).ignore();
    00297           }
    00298           std::pair<Services::iterator, bool> p =
    00299             m_cnvServices.insert( Services::value_type( type, ServiceEntry(type, isvc, servc, icr)));
    00300           if( p.second )    {
    00301             log << MSG::INFO << "Added successfully Conversion service:" << isvc->name() << endreq;
    00302             servc->addRef();
    00303             servc->setAddressCreator(this).ignore();
    00304             servc->setDataProvider(m_dataSvc).ignore();
    00305             return StatusCode::SUCCESS;
    00306           }
    00307           log << MSG::INFO << "Cannot add Conversion service of type " << isvc->name() << endreq;
    00308           isvc->release();
    00309           icr->release();
    00310           return StatusCode::FAILURE;
    00311         }
    00312         icr->release();
    00313       }
    00314       log << MSG::INFO << "Cannot add Conversion service of type " << type << endreq;
    00315       return StatusCode::FAILURE;
    00316     }
    00317     else    {
    00318       return StatusCode::SUCCESS;
    00319     }
    00320   }
    00321   return BAD_STORAGE_TYPE;
    00322 }

StatusCode PersistencySvc::removeCnvService | ( | long | type | ) | `[virtual]`

Remove a Service.

Remove conversion service.

Implements IPersistencySvc.

Definition at line 325 of file PersistencySvc.cpp.

    00325                                                            {
    00326   Services::iterator it = m_cnvServices.find( svctype );
    00327   if( it != m_cnvServices.end() ) {
    00328     (*it).second.service()->release();
    00329     (*it).second.addrCreator()->release();
    00330     m_cnvServices.erase(it);
    00331     return StatusCode::SUCCESS;
    00332   }
    00333   return BAD_STORAGE_TYPE;
    00334 }

StatusCode PersistencySvc::setDefaultCnvService | ( | long | type | ) | `[virtual]`

Set default service type.

Set default conversion service.

Implements IPersistencySvc.

Definition at line 343 of file PersistencySvc.cpp.

    00343                                                              {
    00344   m_cnvDefault = service(type);
    00345   return StatusCode::SUCCESS;
    00346 }

StatusCode PersistencySvc::getService | ( | long | service_type,
|  | IConversionSvc *& | refpSvc |
| ) |  |  | `[virtual]`

Retrieve conversion service identified by technology.

Implements IPersistencySvc.

Definition at line 505 of file PersistencySvc.cpp.

    00505                                                                                      {
    00506   refpSvc = service(service_type);
    00507   return (0==refpSvc) ? StatusCode::FAILURE : StatusCode::SUCCESS;
    00508 }

StatusCode PersistencySvc::getService | ( | const std::string & | service_type,
|  | IConversionSvc *& | refpSvc |
| ) |  |  | `[virtual]`

Retrieve conversion service identified by technology.

Implements IPersistencySvc.

Definition at line 511 of file PersistencySvc.cpp.

    00511                                                                                                  {
    00512   const char* imp = service_type.c_str();
    00513   long len = service_type.length();
    00514   if ( ::strncasecmp(imp,"SICB", len) == 0 )
    00515     return getService(SICB_StorageType, refpSvc);
    00516   else if ( ::strncasecmp(imp,"ZEBRA", len) == 0 )
    00517     return getService(SICB_StorageType, refpSvc);
    00518   else if ( ::strncasecmp(imp,"MS Access", len) == 0 )
    00519     return getService(ACCESS_StorageType, refpSvc);
    00520   else if ( ::strncasecmp(imp,"Microsoft Access", strlen("Microsoft Access")) == 0 )
    00521     return getService(ACCESS_StorageType, refpSvc);
    00522   else if ( ::strncasecmp(imp,"SQL Server", len) == 0 )
    00523     return getService(SQLSERVER_StorageType, refpSvc);
    00524   else if ( ::strncasecmp(imp,"Microsoft ODBC for Oracle", len) == 0 )
    00525     return getService(ORACLE_StorageType, refpSvc);
    00526   else if ( ::strncasecmp(imp,"Oracle ODBC", strlen("Oracle ODBC")) == 0 )
    00527     return getService(ORACLE_StorageType, refpSvc);
    00528   else if ( ::strncasecmp(imp,"Oracle OCI", strlen("Oracle OCI")) == 0 )
    00529     return getService(ORACLE_StorageType, refpSvc);
    00530   else if ( ::strncasecmp(imp,"MySQL", len) == 0 )
    00531     return getService(MYSQL_StorageType, refpSvc);
    00532   else if ( ::strncasecmp(imp,"ROOT", len) == 0 )
    00533     return getService(ROOT_StorageType, refpSvc);
    00534   else if ( ::strncasecmp(imp,"OBJY", len) == 0 )
    00535     return getService(OBJY_StorageType, refpSvc);
    00536   else if ( ::strncasecmp(imp,"OBJYECTI", 7) == 0 )
    00537     return getService(OBJY_StorageType, refpSvc);
    00538   else if ( ::strncasecmp(imp,"POOL_ROOTKEY", 12) == 0 )
    00539     return getService(POOL_ROOTKEY_StorageType, refpSvc);
    00540   else if ( ::strncasecmp(imp,"POOL_ROOTTREE", 12) == 0 )
    00541     return getService(POOL_ROOTTREE_StorageType, refpSvc);
    00542   else if ( ::strncasecmp(imp,"POOL_ROOT", 9) == 0 )
    00543     return getService(POOL_ROOT_StorageType, refpSvc);
    00544   else if ( ::strncasecmp(imp,"POOL_MySQL", 8) == 0 )
    00545     return getService(POOL_MYSQL_StorageType, refpSvc);
    00546   else if ( ::strncasecmp(imp,"POOL_ORACLE", 8) == 0 )
    00547     return getService(POOL_ORACLE_StorageType, refpSvc);
    00548   else if ( ::strncasecmp(imp,"POOL_ACCESS", 8) == 0 )
    00549     return getService(POOL_ACCESS_StorageType, refpSvc);
    00550   else if ( ::strncasecmp(imp,"POOL", 4) == 0 )
    00551     return getService(POOL_StorageType, refpSvc);
    00552
    00553   for(Services::const_iterator i=m_cnvServices.begin(); i != m_cnvServices.end();++i)  {
    00554     SmartIF<IService> svc((*i).second.conversionSvc());
    00555     if ( svc )  {
    00556       // Check wether this is already an active service: first check by service name
    00557       if ( svc->name() == service_type )  {
    00558         refpSvc = (*i).second.conversionSvc();
    00559         return StatusCode::SUCCESS;
    00560       }
    00561       // Check wether this is already an active service: now check by service type
    00562       if ( System::typeinfoName(typeid(*(svc.get()))) == service_type )  {
    00563         refpSvc = (*i).second.conversionSvc();
    00564         return StatusCode::SUCCESS;
    00565       }
    00566     }
    00567   }
    00568   const std::vector<std::string>& names = m_svcNames;
    00569   // if not, check if the service is in the list and may be requested
    00570   for(std::vector<std::string>::const_iterator i=names.begin(); i != names.end(); i++) {
    00571     ListItem itm(*i);
    00572     if ( itm.name() == service_type || itm.type() == service_type )  {
    00573       IConversionSvc* svc = service(*i);
    00574       if ( svc )  {
    00575         refpSvc = svc;
    00576         return StatusCode::SUCCESS;
    00577       }
    00578     }
    00579   }
    00580   return StatusCode::FAILURE;
    00581 }

StatusCode PersistencySvc::initialize | ( |  | ) | `[virtual]`

Initialize the service.

Reimplemented from Service.

Reimplemented in DetPersistencySvc, EvtPersistencySvc, and HistogramPersistencySvc.

Definition at line 589 of file PersistencySvc.cpp.

    00589                                           {
    00590   // Initialize basic service
    00591   StatusCode status = Service::initialize();
    00592   if ( !status.isSuccess() )   {
    00593     MsgStream log( msgSvc(), name() ); // Service MUST be initialized BEFORE!
    00594     log << MSG::ERROR << "Error initializing Service base class." << endreq;
    00595   }
    00596   return status;
    00597 }

StatusCode PersistencySvc::finalize | ( | void |  | ) | `[virtual]`

stop the service.

Reimplemented from Service.

Reimplemented in DetPersistencySvc, EvtPersistencySvc, and HistogramPersistencySvc.

Definition at line 600 of file PersistencySvc.cpp.

    00600                                          {
    00601   // Release all workers
    00602   for ( Services::iterator i = m_cnvServices.begin(); i != m_cnvServices.end(); i++ )    {
    00603     (*i).second.service()->release();
    00604     (*i).second.conversionSvc()->release();
    00605     (*i).second.addrCreator()->release();
    00606   }
    00607   m_cnvServices.erase(m_cnvServices.begin(), m_cnvServices.end());
    00608   return StatusCode::SUCCESS;
    00609 }

StatusCode PersistencySvc::queryInterface | ( | const InterfaceID & | riid,
|  | void ** | ppvUnknown |
| ) |  |  | `[virtual]`

Query interface.

Reimplemented from Service.

Definition at line 612 of file PersistencySvc.cpp.

    00612                                                                                        {
    00613   if ( IID_IConverter == riid )  {
    00614     *ppvInterface = (IConverter*)this;
    00615   }
    00616   else if ( IID_IConversionSvc == riid )  {
    00617     *ppvInterface = (IConversionSvc*)this;
    00618   }
    00619   else if ( IID_IPersistencySvc == riid )  {
    00620     *ppvInterface = (IPersistencySvc*)this;
    00621   }
    00622   else if ( IID_IAddressCreator == riid )  {
    00623     *ppvInterface = (IAddressCreator*)this;
    00624   }
    00625   else  {
    00626     // Interface is not directly availible: try out a base class
    00627     return Service::queryInterface(riid, ppvInterface);
    00628   }
    00629   addRef();
    00630   return StatusCode::SUCCESS;
    00631 }

IConversionSvc * PersistencySvc::service | ( | const std::string & | nam | ) | `[protected]`

Retrieve conversion service by name.

Definition at line 233 of file PersistencySvc.cpp.

    00233                                                                 {
    00234   IConversionSvc* svc = 0;
    00235   for ( Services::iterator it = m_cnvServices.begin(); it != m_cnvServices.end(); it++ )    {
    00236     if ( (*it).second.service()->name() == nam )   {
    00237       return (*it).second.conversionSvc();
    00238     }
    00239   }
    00240   StatusCode status = Service::service(nam, svc, true);
    00241   if ( status.isSuccess() )   {
    00242     if ( addCnvService(svc).isSuccess() )   {
    00243       svc->release();       // Do not double-reference count
    00244       return svc;
    00245     }
    00246   }
    00247   MsgStream log( msgSvc(), name() );
    00248   log << MSG::INFO << "Cannot access Conversion service:" << nam << endreq;
    00249   return 0;
    00250 }

IConversionSvc * PersistencySvc::service | ( | long | service_type | ) | `[protected]`

Retrieve conversion service from list.

Definition at line 253 of file PersistencySvc.cpp.

    00253                                                      {
    00254   typedef std::vector<std::string> SvcNames;
    00255   // Check wether this is already an active service
    00256   Services::iterator it = m_cnvServices.find( type );
    00257   if( it != m_cnvServices.end() ) {
    00258     return (*it).second.conversionSvc();
    00259   }
    00260   // if not, check if the service is in the list and may be requested
    00261   const SvcNames& theNames = m_svcNames.value();
    00262   for ( SvcNames::const_iterator i = theNames.begin(); i != theNames.end(); i++ )   {
    00263     IConversionSvc* svc = service(*i);
    00264     if ( svc != 0 )  {
    00265       long typ = svc->repSvcType();
    00266       if ( typ == type )    {
    00267         return svc;
    00268       }
    00269     }
    00270   }
    00271   return 0;
    00272 }

IAddressCreator * PersistencySvc::addressCreator | ( | long | service_type | ) | `[protected]`

Retrieve address creator from list.

Retrieve address creator service from list.

Definition at line 155 of file PersistencySvc.cpp.

    00155                                                              {
    00156   long typ = type;
    00157   Services::iterator it = m_cnvServices.find( typ );
    00158   if( it == m_cnvServices.end() ) {
    00159     IConversionSvc* s = service(type);
    00160     if ( s )   {
    00161       it = m_cnvServices.find( typ );
    00162       if ( it != m_cnvServices.end() ) {
    00163         return (*it).second.addrCreator();
    00164       }
    00165     }
    00166     return 0;
    00167   }
    00168   return (*it).second.addrCreator();
    00169 }

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

Retrieve string from storage type and clid.

Definition at line 429 of file PersistencySvc.cpp.

    00432 {
    00433   // For address header, use xml-style format of
    00434   // <addrhdr service_type="xxx" clid="yyy" />
    00435   std::stringstream stream;
    00436   int svctyp = service_type; // must put int into stream, not char
    00437   stream << "<address_header service_type=\"" << svctyp << "\" clid=\"" << clid << "\" /> ";
    00438   address = stream.str();
    00439 }

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 442 of file PersistencySvc.cpp.

    00446 {
    00447   // For address header, use xml-style format of
    00448   // <addrhdr service_type="xxx" clid="yyy" />
    00449   service_type = 0;
    00450   clid = 0;
    00451   address_trailer = "";
    00452
    00453   // Check for addrhdr tag
    00454   size_t pos = address.find("<address_header");
    00455   if (std::string::npos != pos) {
    00456     // Get service_type
    00457     pos = address.find("service_type=\"");
    00458     if (std::string::npos != pos) {
    00459       pos += 14;
    00460       size_t end = address.find('\"', pos);
    00461         if (std::string::npos != end) {
    00462           std::string str;
    00463           str.insert(0, address, pos, end-pos);
    00464           int temp;
    00465           sscanf(str.c_str(),"%d",&temp);
    00466           service_type = temp;
    00467           // Get clid
    00468           pos = address.find("clid=\"");
    00469         if (std::string::npos != pos) {
    00470           pos += 6;
    00471           size_t end = address.find('\"', pos);
    00472           if (std::string::npos != end) {
    00473             std::string str1;
    00474             str1.insert(0, address, pos, end-pos);
    00475             sscanf(str1.c_str(),"%d",&temp);
    00476             clid = temp;
    00477             // Get trailer_address
    00478             pos = address.find(">");
    00479             if (std::string::npos != pos) {
    00480               pos += 1;
    00481               address_trailer.insert(0, address, pos, address.size() - pos);
    00482             }
    00483           }
    00484         }
    00485       }
    00486     }
    00487   }
    00488 }

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

Implementation helper.

Definition at line 51 of file PersistencySvc.cpp.

    00053                                                                {
    00054   if ( m_enable )    {
    00055     IConversionSvc* svc    = 0;
    00056     switch(typ)   {
    00057     case CREATE_REP:
    00058     case FILL_REP_REFS:
    00059     case UPDATE_REP:
    00060     case UPDATE_REP_REFS:
    00061       svc = m_cnvDefault;
    00062       break;
    00063     default:
    00064       if ( 0 != pAddress )    {
    00065         long svc_type = pAddress->svcType();
    00066         svc = service(svc_type);
    00067         if ( 0 == svc )   {
    00068           return BAD_STORAGE_TYPE;
    00069         }
    00070       }
    00071       else  {
    00072         return INVALID_ADDRESS;
    00073       }
    00074       break;
    00075     }
    00076
    00077     StatusCode status(StatusCode::FAILURE,true);
    00078     switch( typ )     {
    00079     case CREATE_OBJ:
    00080       pObject = 0;
    00081       status = svc->createObj(pAddress, pObject);
    00082       break;
    00083     case FILL_OBJ_REFS:
    00084       status = svc->fillObjRefs(pAddress, pObject);
    00085       break;
    00086     case UPDATE_OBJ:
    00087       status = svc->updateObj(pAddress, pObject);
    00088       break;
    00089     case UPDATE_OBJ_REFS:
    00090       status = svc->updateObjRefs(pAddress, pObject);
    00091       break;
    00092     case CREATE_REP:
    00093       status = svc->createRep(pObject, pAddress);
    00094       break;
    00095     case FILL_REP_REFS:
    00096       status = svc->fillRepRefs(pAddress, pObject);
    00097       break;
    00098     case UPDATE_REP:
    00099       status = svc->updateRep(pAddress, pObject);
    00100       break;
    00101     case UPDATE_REP_REFS:
    00102       status = svc->updateRepRefs(pAddress, pObject);
    00103       break;
    00104     default:
    00105       status = StatusCode::FAILURE;
    00106       break;
    00107     }
    00108     status.ignore();
    00109     return status;
    00110   }
    00111   return StatusCode::SUCCESS;
    00112 }

bool PersistencySvc::enable | ( | bool | value | ) | `[protected]`

Set enabled flag.

Definition at line 639 of file PersistencySvc.cpp.

    00640 {
    00641   bool old = m_enable;
    00642   m_enable = value;
    00643   return old;
    00644 }

void PersistencySvc::svcNamesHandler | ( | Property & | theProp | ) | `[protected]`

Handlers for Service Names Property.

Definition at line 633 of file PersistencySvc.cpp.

    00633                                                       {
    00634   MsgStream log( msgSvc(), name() );
    00635   log << MSG::INFO << p << endreq ;
    00636 }

## Friends And Related Function Documentation

friend class SvcFactory< PersistencySvc >`[friend]`

Definition at line 58 of file PersistencySvc.h.

friend class Factory< PersistencySvc, IService *(std::string, ISvcLocator *)>`[friend]`

Definition at line 59 of file PersistencySvc.h.

## Member Data Documentation

long PersistencySvc::m_cnvDefType`[protected]`

Default service type.

Definition at line 276 of file PersistencySvc.h.

IDataProviderSvc* PersistencySvc::m_dataSvc`[protected]`

Pointer to datma provider service.

Definition at line 278 of file PersistencySvc.h.

Services PersistencySvc::m_cnvServices`[protected]`

List of convermsion workers.

Definition at line 280 of file PersistencySvc.h.

IConversionSvc* PersistencySvc::m_cnvDefault`[protected]`

Default output service.

Definition at line 282 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 286 of file PersistencySvc.h.

bool PersistencySvc::m_enable`[protected]`

Flag to indicate that the service is enabled.

Definition at line 288 of file PersistencySvc.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiSvc/src/PersistencySvc/PersistencySvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiSvc/src/PersistencySvc/PersistencySvc.cpp