| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# PersistencySvc Class Reference

PersistencySvc class implementation definition. More...

`#include <PersistencySvc.h>`

Inheritance diagram for PersistencySvc:

[legend]
Collaboration diagram for PersistencySvc:

[legend]

List of all members.

## : Object implementation
| PersistencySvc (const std::string &name, ISvcLocator *svc)
| Standard Constructor.
virtual | ~PersistencySvc ()
| Standard Destructor.
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.
## 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 SmartIF < IDataProviderSvc > & | dataProvider () const
| Access reference to transient datastore.
virtual StatusCode | setConversionSvc (IConversionSvc *svc)
| Set conversion service the converter is connected to.
virtual SmartIF< IConversionSvc > & | conversionSvc () const
| Get conversion service the converter is connected to.
virtual StatusCode | setAddressCreator (IAddressCreator *creator)
| Set address creator facility.
virtual SmartIF < 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.
## 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.
SmartIF< IDataProviderSvc > | m_dataSvc
| Pointer to datma provider service.
Services | m_cnvServices
| List of convermsion workers.
SmartIF< 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.
SmartIF< IAddressCreator > | m_addrCreator
| Pointer to the IAddressCreator interface of this, for addressCreator().
## Friends
class | SvcFactory< PersistencySvc >
class | Factory< PersistencySvc, IService *(std::string, ISvcLocator *)>
## Classes
class | ServiceEntry

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

## Member Typedef Documentation

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

Definition at line 106 of file PersistencySvc.h.

## Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 628 of file PersistencySvc.cpp.

    00629 :  base_class(name, svc),
    00630    m_cnvDefType(TEST_StorageType),
    00631    m_enable(true)
    00632 {
    00633   declareProperty("CnvServices", m_svcNames);
    00634   m_svcNames.declareUpdateHandler( &PersistencySvc::svcNamesHandler, this );
    00635 }

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

Standard Destructor.

Definition at line 638 of file PersistencySvc.cpp.

    00638                                   {
    00639 }

## Member Function Documentation

long PersistencySvc::repSvcType | ( |  | ) | const

Return default service type.

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

Definition at line 342 of file PersistencySvc.cpp.

    00342                                       {
    00343   long typ = (m_cnvDefault) ? m_cnvDefault->repSvcType() : 0;
    00344   return typ;
    00345 }

const CLID & PersistencySvc::objType | ( |  | ) | const

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

Retrieve the class type of objects the converter produces.

Definition at line 589 of file PersistencySvc.cpp.

    00589                                              {
    00590   return CLID_NULL;
    00591 }

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.

Definition at line 116 of file PersistencySvc.cpp.

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

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.

Definition at line 121 of file PersistencySvc.cpp.

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

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.

Definition at line 126 of file PersistencySvc.cpp.

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

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.

Definition at line 131 of file PersistencySvc.cpp.

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

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.

Reimplemented in HistogramPersistencySvc.

Definition at line 136 of file PersistencySvc.cpp.

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

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.

Definition at line 141 of file PersistencySvc.cpp.

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

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.

Definition at line 146 of file PersistencySvc.cpp.

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

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.

Definition at line 151 of file PersistencySvc.cpp.

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

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

Define transient datastore.

Define transient data store.

Definition at line 174 of file PersistencySvc.cpp.

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

SmartIF< IDataProviderSvc > & PersistencySvc::dataProvider | ( |  | ) | const`[virtual]`

Access reference to transient datastore.

Access the dataprovider service.

Definition at line 183 of file PersistencySvc.cpp.

    00183                                                                 {
    00184   return m_dataSvc;
    00185 }

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

Set conversion service the converter is connected to.

Definition at line 188 of file PersistencySvc.cpp.

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

SmartIF< IConversionSvc > & PersistencySvc::conversionSvc | ( |  | ) | const`[virtual]`

Get conversion service the converter is connected to.

Definition at line 194 of file PersistencySvc.cpp.

    00194                                                                   {
    00195   return m_cnvDefault;
    00196 }

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

Set address creator facility.

Definition at line 496 of file PersistencySvc.cpp.

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

SmartIF< IAddressCreator > & PersistencySvc::addressCreator | ( |  | ) | const`[virtual]`

Retrieve address creator facility.

Definition at line 505 of file PersistencySvc.cpp.

    00505                                                                    {
    00506   return m_addrCreator;
    00507 }

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

Add converter object to conversion service.

Definition at line 204 of file PersistencySvc.cpp.

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

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

Add converter object to conversion service.

Definition at line 199 of file PersistencySvc.cpp.

    00199                                                                {
    00200   return StatusCode::FAILURE;
    00201 }

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

Retrieve converter from list.

Definition at line 230 of file PersistencySvc.cpp.

    00230                                                           {
    00231   return 0;
    00232 }

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

Remove converter object from conversion service (if present).

Definition at line 217 of file PersistencySvc.cpp.

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

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

Connect the output file to the service with open mode.

Definition at line 354 of file PersistencySvc.cpp.

    00355                                                                           {
    00356   return connectOutput(outputFile);
    00357 }

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

Connect the output file to the service.

Definition at line 360 of file PersistencySvc.cpp.

    00360                                                          {
    00361   return StatusCode::SUCCESS;
    00362 }

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

Commit pending output.

Definition at line 365 of file PersistencySvc.cpp.

    00365                                                                 {
    00366   return StatusCode::SUCCESS;
    00367 }

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.

Definition at line 370 of file PersistencySvc.cpp.

    00374                                                                           {
    00375   IAddressCreator* svc = addressCreator(svc_type);
    00376   StatusCode   status  = BAD_STORAGE_TYPE;        // Preset error
    00377   refpAddress = 0;
    00378   if ( 0 != svc )   {
    00379     status = svc->createAddress(svc_type, clid, pars, ipars, refpAddress);
    00380   }
    00381   return status;
    00382 }

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

Convert an address to string form.

Definition at line 385 of file PersistencySvc.cpp.

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

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.

Definition at line 413 of file PersistencySvc.cpp.

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

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

Add a new Service.

Add data service.

Definition at line 280 of file PersistencySvc.cpp.

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

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

Remove a Service.

Remove conversion service.

Definition at line 330 of file PersistencySvc.cpp.

    00330                                                            {
    00331   Services::iterator it = m_cnvServices.find( svctype );
    00332   if( it != m_cnvServices.end() ) {
    00333     (*it).second.service()->release();
    00334     (*it).second.addrCreator()->release();
    00335     m_cnvServices.erase(it);
    00336     return StatusCode::SUCCESS;
    00337   }
    00338   return BAD_STORAGE_TYPE;
    00339 }

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

Set default service type.

Set default conversion service.

Definition at line 348 of file PersistencySvc.cpp.

    00348                                                              {
    00349   m_cnvDefault = service(type);
    00350   return StatusCode::SUCCESS;
    00351 }

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

Retrieve conversion service identified by technology.

Definition at line 510 of file PersistencySvc.cpp.

    00510                                                                                      {
    00511   refpSvc = service(service_type);
    00512   return (0==refpSvc) ? StatusCode::FAILURE : StatusCode::SUCCESS;
    00513 }

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

Retrieve conversion service identified by technology.

Definition at line 516 of file PersistencySvc.cpp.

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

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

Initialize the service.

Reimplemented from Service.

Reimplemented in DetPersistencySvc, EvtPersistencySvc, and HistogramPersistencySvc.

Definition at line 594 of file PersistencySvc.cpp.

    00594                                           {
    00595   m_addrCreator = this; // initialize internal pointer to IAddressCreator interface
    00596   // Initialize basic service
    00597   StatusCode status = Service::initialize();
    00598   if ( !status.isSuccess() )   {
    00599     MsgStream log( msgSvc(), name() ); // Service MUST be initialized BEFORE!
    00600     log << MSG::ERROR << "Error initializing Service base class." << endmsg;
    00601   }
    00602   return status;
    00603 }

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

stop the service.

Reimplemented from Service.

Reimplemented in DetPersistencySvc, EvtPersistencySvc, and HistogramPersistencySvc.

Definition at line 606 of file PersistencySvc.cpp.

    00606                                          {
    00607   // Release all workers
    00608   m_cnvServices.clear();
    00609   // Release references to this to avoid loops
    00610   m_addrCreator = 0;
    00611   return StatusCode::SUCCESS;
    00612 }

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

Retrieve conversion service by name.

Definition at line 235 of file PersistencySvc.cpp.

    00235                                                                          {
    00236   Gaudi::Utils::TypeNameString tn(nam);
    00237   IConversionSvc* svc = 0;
    00238   for ( Services::iterator it = m_cnvServices.begin(); it != m_cnvServices.end(); it++ )    {
    00239     if ( (*it).second.service()->name() == tn.name() )   {
    00240       return (*it).second.conversionSvc();
    00241     }
    00242   }
    00243   StatusCode status = Service::service(nam, svc, true);
    00244   if ( status.isSuccess() )   {
    00245     if ( addCnvService(svc).isSuccess() )   {
    00246       svc->release();       // Do not double-reference count
    00247       return service(nam); // now it is in the list
    00248     }
    00249   }
    00250   MsgStream log( msgSvc(), name() );
    00251   log << MSG::INFO << "Cannot access Conversion service:" << nam << endmsg;
    00252   static SmartIF<IConversionSvc> no_svc;
    00253   return no_svc;
    00254 }

SmartIF< IConversionSvc > & PersistencySvc::service | ( | long | service_type | ) | `[protected]`

Retrieve conversion service from list.

Definition at line 257 of file PersistencySvc.cpp.

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

SmartIF< IAddressCreator > & PersistencySvc::addressCreator | ( | long | service_type | ) | `[protected]`

Retrieve address creator from list.

Retrieve address creator service from list.

Definition at line 156 of file PersistencySvc.cpp.

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

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

Retrieve string from storage type and clid.

Definition at line 434 of file PersistencySvc.cpp.

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

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

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

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

Implementation helper.

Definition at line 52 of file PersistencySvc.cpp.

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

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

Set enabled flag.

Definition at line 620 of file PersistencySvc.cpp.

    00621 {
    00622   bool old = m_enable;
    00623   m_enable = value;
    00624   return old;
    00625 }

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

Handlers for Service Names Property.

Definition at line 614 of file PersistencySvc.cpp.

    00614                                                       {
    00615   MsgStream log( msgSvc(), name() );
    00616   log << MSG::INFO << p << endmsg ;
    00617 }

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

SmartIF<IDataProviderSvc> PersistencySvc::m_dataSvc`[mutable, protected]`

Pointer to datma provider service.

Definition at line 282 of file PersistencySvc.h.

Services PersistencySvc::m_cnvServices`[protected]`

List of convermsion workers.

Definition at line 284 of file PersistencySvc.h.

SmartIF<IConversionSvc> PersistencySvc::m_cnvDefault`[mutable, protected]`

Default output service.

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

bool PersistencySvc::m_enable`[protected]`

Flag to indicate that the service is enabled.

Definition at line 292 of file PersistencySvc.h.

SmartIF<IAddressCreator> PersistencySvc::m_addrCreator`[mutable, protected]`

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

Definition at line 295 of file PersistencySvc.h.

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

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