Gaudi Framework, version v20r2

Generated: 18 Jul 2008

ConversionSvc Class Reference

#include <GaudiKernel/ConversionSvc.h>

Inheritance diagram for ConversionSvc:

Inheritance graph
[legend]
Collaboration diagram for ConversionSvc:

Collaboration graph
[legend]
List of all members.

Detailed Description

Base class for all conversion services.

It manages a set of Converters that are specialized for conversions of specific objects.

This supports self learning converters: User hooks include the following (overridable) entries:

configureConverter and activateConverter are user hooks, where the convetrer can be manipulated by the hosting service and knowledge can be supplied, which a "generic" converter cannot aquire itself.

These hooks allow any sub-classed conversion service to override the calls and create converters, which aquire the knowledge about their persistency type and the object type they convert during the initialization.

Only AFTER these three steps the converter must satisfy the storage type of the hosting service and the class type of the required object type.

Author:
Markus Frank
Version:
1.0

Definition at line 46 of file ConversionSvc.h.

Public Types

typedef std::vector< WorkerEntryWorkers

Public Member Functions

virtual StatusCode initialize ()
 Initialize the service.
virtual StatusCode finalize ()
 stop the service.
virtual long repSvcType () const
 Retrieve the class type of the data store the converter uses.
const CLIDobjType () const
 Implementation of IConverter: dummy call.
virtual StatusCode setDataProvider (IDataProviderSvc *pService)
 Implementation of IConverter: Set Data provider service.
virtual IDataProviderSvcdataProvider () const
 Implementation of IConverter: Get Data provider service.
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Implementation of IConverter: Set conversion service the converter is connected to.
virtual IConversionSvcconversionSvc () const
 Implementation of IConverter: Get conversion service the converter is connected to.
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility.
virtual IAddressCreatoraddressCreator () const
 Retrieve address creator facility.
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 addConverter (const CLID &clid)
 Add converter object to conversion service.
virtual StatusCode addConverter (IConverter *pConverter)
 Add converter object to conversion service.
virtual StatusCode removeConverter (const CLID &clid)
 Remove converter object from conversion service (if present).
virtual IConverterconverter (const CLID &wanted)
 Retrieve converter from list.
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 &output)
 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 *par, const unsigned long *ip, 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.
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service.
 ConversionSvc (const std::string &name, ISvcLocator *svc, long type)
 Standard Constructor.
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
 Query interface.

Protected Member Functions

virtual ~ConversionSvc ()
 Standard Destructor.
virtual IConvertercreateConverter (long typ, const CLID &clid, const ICnvFactory *fac)
 Create new Converter using factory.
virtual StatusCode configureConverter (long typ, const CLID &clid, IConverter *cnv)
 Configure the new converter before initialize is called.
virtual StatusCode initializeConverter (long typ, const CLID &clid, IConverter *cnv)
 Initialize the new converter.
virtual StatusCode activateConverter (long typ, const CLID &clid, IConverter *cnv)
 Activate the new converter after initialization.
virtual void loadConverter (DataObject *pObject)
 Load converter or dictionary needed by the converter.
virtual IAddressCreatoraddressCreator ()
 Retrieve address creation interface.
StatusCode makeCall (int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)

Protected Attributes

IDataProviderSvcm_dataSvc
 Pointer to data provider service.
IAddressCreatorm_addressCreator
 Pointer to the address creation service interface.
long m_type
 Conversion service type.
Workersm_workers
 List of conversion workers.

Classes

class  CnvTest
class  WorkerEntry


Member Typedef Documentation

typedef std::vector<WorkerEntry> ConversionSvc::Workers

Definition at line 76 of file ConversionSvc.h.


Constructor & Destructor Documentation

ConversionSvc::ConversionSvc ( const std::string name,
ISvcLocator svc,
long  type 
)

Standard Constructor.

Definition at line 424 of file ConversionSvc.cpp.

References StatusCode::ignore(), m_dataSvc, m_type, m_workers, and setAddressCreator().

00425  : Service(name, svc)
00426 {
00427   m_type            = type;
00428   m_dataSvc         = 0;
00429   m_workers = new Workers();
00430   setAddressCreator(this).ignore();
00431 }

ConversionSvc::~ConversionSvc (  )  [protected, virtual]

Standard Destructor.

Definition at line 434 of file ConversionSvc.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), and m_workers.

00434                                 {
00435   // Release all workers.
00436   for ( Workers::iterator i = m_workers->begin(); i != m_workers->end(); i++ )    {
00437     (*i).converter()->release();
00438   }
00439   m_workers->erase(m_workers->begin(), m_workers->end() );
00440   delete m_workers;
00441 }


Member Function Documentation

StatusCode ConversionSvc::initialize (  )  [virtual]

Initialize the service.

Reimplemented from Service.

Reimplemented in PoolDbCnvSvc, HbookCnv::PersSvc, and RootHistCnv::PersSvc.

Definition at line 282 of file ConversionSvc.cpp.

References Service::initialize().

Referenced by RootHistCnv::PersSvc::initialize(), HbookCnv::PersSvc::initialize(), and PoolDbCnvSvc::initialize().

00282                                          {
00283   StatusCode status = Service::initialize();
00284   return status;
00285 }

StatusCode ConversionSvc::finalize (  )  [virtual]

stop the service.

Reimplemented from Service.

Reimplemented in PoolDbCnvSvc, HbookCnv::PersSvc, and RootHistCnv::PersSvc.

Definition at line 288 of file ConversionSvc.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), endreq(), std::vector< _Tp, _Alloc >::erase(), MSG::ERROR, Service::finalize(), m_dataSvc, m_workers, Service::msgSvc(), Service::name(), and IInterface::release().

Referenced by RootHistCnv::PersSvc::finalize(), HbookCnv::PersSvc::finalize(), and PoolDbCnvSvc::finalize().

00288                                         {
00289   // Release all workers.
00290   MsgStream log(msgSvc(), name());
00291   for ( Workers::iterator i = m_workers->begin(); i != m_workers->end(); i++ )    {
00292     if ( (*i).converter()->finalize().isFailure() ) {
00293       log << MSG::ERROR << "finalizing worker" << endreq;
00294     }
00295     (*i).converter()->release();
00296   }
00297   m_workers->erase(m_workers->begin(), m_workers->end() );
00298   if ( m_dataSvc ) m_dataSvc->release();
00299   m_dataSvc = 0;
00300   return Service::finalize();
00301 }

long ConversionSvc::repSvcType (  )  const [virtual]

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

Implements IConverter.

Definition at line 356 of file ConversionSvc.cpp.

References m_type.

Referenced by addConverter(), and RootHistCnv::PersSvc::createRep().

00356                                      {
00357   return m_type;
00358 }

const CLID & ConversionSvc::objType (  )  const [virtual]

Implementation of IConverter: dummy call.

Implements IConverter.

Definition at line 351 of file ConversionSvc.cpp.

References CLID_NULL.

00351                                             {
00352   return CLID_NULL;
00353 }

StatusCode ConversionSvc::setDataProvider ( IDataProviderSvc pService  )  [virtual]

Implementation of IConverter: Set Data provider service.

Returns:
Status code indicating success or failure
Parameters:
pService Pointer to data provider service

Implements IConverter.

Reimplemented in PoolDbCnvSvc.

Definition at line 167 of file ConversionSvc.cpp.

References IInterface::addRef(), std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), endreq(), MSG::ERROR, m_dataSvc, m_workers, Service::msgSvc(), Service::name(), IInterface::release(), Service::start(), Service::stop(), and StatusCode::SUCCESS.

Referenced by PoolDbCnvSvc::setDataProvider().

00167                                                                        {
00168   if ( !pDataSvc ) return StatusCode::SUCCESS; //Atlas does not use DataSvc
00169   if ( m_dataSvc ) m_dataSvc->release();
00170   m_dataSvc = pDataSvc;
00171   m_dataSvc->addRef();
00172   Workers::iterator stop  = m_workers->end();
00173   Workers::iterator start = m_workers->begin();
00174   for(Workers::iterator i=start; i != stop; i++ )    {
00175     IConverter* cnv = (*i).converter();
00176     if ( 0 != cnv )   {
00177       if (cnv->setDataProvider(m_dataSvc).isFailure()) {
00178         MsgStream log(msgSvc(), name());
00179         log << MSG::ERROR << "setting Data Provider" << endreq;
00180       }
00181     }
00182   }
00183   return StatusCode::SUCCESS;
00184 }

IDataProviderSvc * ConversionSvc::dataProvider (  )  const [virtual]

Implementation of IConverter: Get Data provider service.

Returns:
Pointer to data provider service

Implements IConverter.

Definition at line 187 of file ConversionSvc.cpp.

References m_dataSvc.

Referenced by RootHistCnv::PersSvc::createRep().

00187                                                        {
00188   return m_dataSvc;
00189 }

StatusCode ConversionSvc::setConversionSvc ( IConversionSvc svc  )  [virtual]

Implementation of IConverter: Set conversion service the converter is connected to.

Implements IConverter.

Definition at line 214 of file ConversionSvc.cpp.

References StatusCode::FAILURE.

00214                                                                       {
00215   return StatusCode::FAILURE;
00216 }

IConversionSvc * ConversionSvc::conversionSvc (  )  const [virtual]

Implementation of IConverter: Get conversion service the converter is connected to.

Implements IConverter.

Definition at line 219 of file ConversionSvc.cpp.

00219                                                         {
00220   return (IConversionSvc*)this;
00221 }

StatusCode ConversionSvc::setAddressCreator ( IAddressCreator creator  )  [virtual]

Set address creator facility.

Implements IConverter.

Definition at line 192 of file ConversionSvc.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), endreq(), MSG::ERROR, m_addressCreator, m_workers, Service::msgSvc(), Service::name(), Service::start(), Service::stop(), and StatusCode::SUCCESS.

Referenced by ConversionSvc().

00192                                                                       {
00193   m_addressCreator = creator;
00194   Workers::iterator stop  = m_workers->end();
00195   Workers::iterator start = m_workers->begin();
00196   for(Workers::iterator i=start; i != stop; i++ )    {
00197     IConverter* cnv = (*i).converter();
00198     if ( 0 != cnv )   {
00199       if (cnv->setAddressCreator(m_addressCreator).isFailure()) {
00200         MsgStream log(msgSvc(), name());
00201         log << MSG::ERROR << "setting Address Creator"  << endreq;
00202       }
00203     }
00204   }
00205   return StatusCode::SUCCESS;
00206 }

IAddressCreator * ConversionSvc::addressCreator (  )  const [virtual]

Retrieve address creator facility.

Implements IConverter.

Definition at line 209 of file ConversionSvc.cpp.

References m_addressCreator.

00209                                                         {
00210   return m_addressCreator;
00211 }

StatusCode ConversionSvc::createObj ( IOpaqueAddress pAddress,
DataObject *&  refpObject 
) [virtual]

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

Implements IConverter.

Definition at line 108 of file ConversionSvc.cpp.

References CREATE_OBJ, and makeCall().

00108                                                                                     {
00109   return makeCall(CREATE_OBJ, false, true, false, pAddress, refpObj);
00110 }

StatusCode ConversionSvc::fillObjRefs ( IOpaqueAddress pAddress,
DataObject pObject 
) [virtual]

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

Implements IConverter.

Definition at line 113 of file ConversionSvc.cpp.

References FILL_OBJ_REFS, and makeCall().

00113                                                                                    {
00114   return makeCall(FILL_OBJ_REFS, false, true, true, pAddress, pObj);
00115 }

StatusCode ConversionSvc::updateObj ( IOpaqueAddress pAddress,
DataObject refpObject 
) [virtual]

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

Implements IConverter.

Definition at line 118 of file ConversionSvc.cpp.

References makeCall(), and UPDATE_OBJ.

00118                                                                                 {
00119   return makeCall(UPDATE_OBJ, false, true, false, pAddress, pObj);
00120 }

StatusCode ConversionSvc::updateObjRefs ( IOpaqueAddress pAddress,
DataObject pObject 
) [virtual]

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

Implements IConverter.

Definition at line 123 of file ConversionSvc.cpp.

References makeCall(), and UPDATE_OBJ_REFS.

00123                                                                                    {
00124   return makeCall(UPDATE_OBJ_REFS, false, true, true, pAddress, pObj);
00125 }

StatusCode ConversionSvc::createRep ( DataObject pObject,
IOpaqueAddress *&  refpAddress 
) [virtual]

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

Implements IConverter.

Reimplemented in HbookCnv::PersSvc, and RootHistCnv::PersSvc.

Definition at line 128 of file ConversionSvc.cpp.

References CREATE_REP, and makeCall().

Referenced by RootHistCnv::PersSvc::createRep(), and HbookCnv::PersSvc::createRep().

00128                                                                                    {
00129   return makeCall(CREATE_REP, true, false, false, refpAddress, pObj);
00130 }

StatusCode ConversionSvc::fillRepRefs ( IOpaqueAddress pAddress,
DataObject pObject 
) [virtual]

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

Implements IConverter.

Reimplemented in HbookCnv::PersSvc.

Definition at line 133 of file ConversionSvc.cpp.

References FILL_REP_REFS, and makeCall().

Referenced by HbookCnv::PersSvc::fillRepRefs().

00133                                                                                  {
00134   return makeCall(FILL_REP_REFS, true, false, false, pAddress, pObj);
00135 }

StatusCode ConversionSvc::updateRep ( IOpaqueAddress pAddress,
DataObject pObject 
) [virtual]

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

Implements IConverter.

Definition at line 138 of file ConversionSvc.cpp.

References makeCall(), and UPDATE_REP.

00138                                                                                {
00139   return makeCall(UPDATE_REP, true, false, false, pAddress, pObj);
00140 }

StatusCode ConversionSvc::updateRepRefs ( IOpaqueAddress pAddress,
DataObject pObject 
) [virtual]

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

Implements IConverter.

Definition at line 143 of file ConversionSvc.cpp.

References makeCall(), and UPDATE_REP_REFS.

00143                                                                                      {
00144   return makeCall(UPDATE_REP_REFS, true, false, false, pAddress, pObj);
00145 }

StatusCode ConversionSvc::addConverter ( const CLID clid  )  [virtual]

Add converter object to conversion service.

Implements IConversionSvc.

Definition at line 224 of file ConversionSvc.cpp.

References activateConverter(), configureConverter(), createConverter(), initializeConverter(), StatusCode::isSuccess(), IConversionSvc::NO_CONVERTER, IConverter::objType(), IInterface::release(), IConverter::repSvcType(), and repSvcType().

Referenced by converter().

00224                                                         {
00225   // First look for the more specific converter
00226   long typ = repSvcType();
00227   IConverter* pConverter = createConverter(typ, clid, 0);
00228   if ( 0 != pConverter )    {
00229     StatusCode status = configureConverter( typ, clid, pConverter );
00230     if ( status.isSuccess() )   {
00231       status = initializeConverter( typ, clid, pConverter );
00232       if ( status.isSuccess() )   {
00233         status = activateConverter( typ, clid, pConverter );
00234         if ( status.isSuccess() )   {
00235           long conv_typ  = pConverter->repSvcType();
00236           const CLID&   conv_clid = pConverter->objType();
00237           typ      = (typ<0xFF) ? typ : typ&0xFFFFFF00;
00238           conv_typ = (conv_typ<0xFF) ? conv_typ : conv_typ&0xFFFFFF00;
00239           if ( conv_typ == typ && conv_clid == clid )   {
00240             return addConverter(pConverter);
00241           }
00242         }
00243       }
00244     }
00245     pConverter->release();
00246   }
00247   return NO_CONVERTER;
00248 }

StatusCode ConversionSvc::addConverter ( IConverter pConverter  )  [virtual]

Add converter object to conversion service.

Implements IConversionSvc.

Definition at line 251 of file ConversionSvc.cpp.

References IInterface::addRef(), StatusCode::ignore(), m_workers, IConversionSvc::NO_CONVERTER, IConverter::objType(), std::vector< _Tp, _Alloc >::push_back(), removeConverter(), and StatusCode::SUCCESS.

00251                                                                 {
00252   if ( 0 != pConverter )    {
00253     const CLID& clid = pConverter->objType();
00254     removeConverter(clid).ignore();
00255     m_workers->push_back(WorkerEntry(clid, pConverter));
00256     pConverter->addRef();
00257     return StatusCode::SUCCESS;
00258   }
00259   return NO_CONVERTER;
00260 }

StatusCode ConversionSvc::removeConverter ( const CLID clid  )  [virtual]

Remove converter object from conversion service (if present).

Implements IConversionSvc.

Definition at line 263 of file ConversionSvc.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), m_workers, IConversionSvc::NO_CONVERTER, std::remove_if(), Service::start(), Service::stop(), and StatusCode::SUCCESS.

Referenced by addConverter().

00263                                                            {
00264   CnvTest test(clid);
00265   Workers::iterator stop  = m_workers->end();
00266   Workers::iterator start = m_workers->begin();
00267   for(Workers::iterator i=start; i != stop; i++ )    {
00268     if ( test( *i ) )   {
00269       (*i).converter()->finalize().ignore();
00270       (*i).converter()->release();
00271     }
00272   }
00273   Workers::iterator j = std::remove_if(start, stop, test);
00274   if ( j != stop )  {
00275     m_workers->erase(j, stop);
00276     return StatusCode::SUCCESS;
00277   }
00278   return NO_CONVERTER;  
00279 }

IConverter * ConversionSvc::converter ( const CLID wanted  )  [virtual]

Retrieve converter from list.

Implements IConversionSvc.

Definition at line 148 of file ConversionSvc.cpp.

References addConverter(), std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), std::find_if(), StatusCode::isSuccess(), and m_workers.

Referenced by makeCall().

00148                                                          {
00149   IConverter* cnv = 0;
00150   Workers::iterator i = std::find_if(m_workers->begin(),m_workers->end(),CnvTest(clid));
00151   if ( i != m_workers->end() )      {
00152     cnv = (*i).converter();
00153   }
00154   if ( 0 == cnv )     {
00155     StatusCode status = addConverter(clid);
00156     if ( status.isSuccess() )   {
00157       i = std::find_if(m_workers->begin(),m_workers->end(),CnvTest(clid));
00158       if ( i != m_workers->end() )      {
00159         cnv = (*i).converter();
00160       }
00161     }
00162   }
00163   return cnv;
00164 }

StatusCode ConversionSvc::connectOutput ( const std::string outputFile,
const std::string openMode 
) [virtual]

Connect the output file to the service with open mode.

Implements IConversionSvc.

Reimplemented in PoolDbCnvSvc.

Definition at line 380 of file ConversionSvc.cpp.

00381                                                                          {
00382   return connectOutput(outputFile);
00383 }

StatusCode ConversionSvc::connectOutput ( const std::string output  )  [virtual]

Connect the output file to the service.

Implements IConversionSvc.

Reimplemented in PoolDbCnvSvc.

Definition at line 386 of file ConversionSvc.cpp.

References StatusCode::SUCCESS.

00386                                                                          {
00387   return StatusCode::SUCCESS;
00388 }

StatusCode ConversionSvc::commitOutput ( const std::string output,
bool  do_commit 
) [virtual]

Commit pending output.

Implements IConversionSvc.

Reimplemented in PoolDbCnvSvc.

Definition at line 391 of file ConversionSvc.cpp.

References StatusCode::SUCCESS.

00391                                                                {
00392   return StatusCode::SUCCESS;
00393 }

StatusCode ConversionSvc::createAddress ( long  svc_type,
const CLID clid,
const std::string par,
const unsigned long *  ip,
IOpaqueAddress *&  refpAddress 
) [virtual]

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

Implements IAddressCreator.

Reimplemented in PoolDbCnvSvc.

Definition at line 396 of file ConversionSvc.cpp.

References StatusCode::FAILURE.

00400                                                                          {
00401   refpAddress = 0;
00402   return StatusCode::FAILURE;
00403 }

StatusCode ConversionSvc::convertAddress ( const IOpaqueAddress pAddress,
std::string refAddress 
) [virtual]

Convert an address to string form.

Implements IAddressCreator.

Definition at line 406 of file ConversionSvc.cpp.

References StatusCode::FAILURE.

00408 {
00409   refAddress = "";
00410   return StatusCode::FAILURE;
00411 }

StatusCode ConversionSvc::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 414 of file ConversionSvc.cpp.

References StatusCode::FAILURE.

00418 {
00419   refpAddress = 0;
00420   return StatusCode::FAILURE;
00421 }

StatusCode ConversionSvc::updateServiceState ( IOpaqueAddress pAddress  )  [virtual]

Update state of the service.

Reimplemented in PoolDbCnvSvc.

Definition at line 103 of file ConversionSvc.cpp.

References StatusCode::SUCCESS.

Referenced by makeCall().

00103                                                                             {
00104   return StatusCode::SUCCESS;
00105 }

StatusCode ConversionSvc::queryInterface ( const InterfaceID riid,
void **  ppvInterface 
) [virtual]

Query interface.

Reimplemented from Service.

Reimplemented in PoolDbCnvSvc.

Definition at line 361 of file ConversionSvc.cpp.

References Service::addRef(), IID_IAddressCreator, IID_IConversionSvc, IID_IConverter, Service::queryInterface(), StatusCode::SUCCESS, and InterfaceID::versionMatch().

Referenced by PoolDbCnvSvc::queryInterface().

00361                                                                                       {
00362   if ( IID_IConversionSvc.versionMatch(riid) )  {
00363     *ppvInterface = (IConversionSvc*)this;
00364   }
00365   else if ( IID_IConverter.versionMatch(riid) )  {
00366     *ppvInterface = (IConverter*)this;
00367   }
00368   else if ( IID_IAddressCreator.versionMatch(riid) )  {
00369     *ppvInterface = (IAddressCreator*)this;
00370   }
00371   else  {
00372     // Interface is not directly availible: try out a base class
00373     return Service::queryInterface(riid, ppvInterface);
00374   }
00375   addRef();
00376   return StatusCode::SUCCESS;
00377 }

IConverter * ConversionSvc::createConverter ( long  typ,
const CLID clid,
const ICnvFactory *  fac 
) [protected, virtual]

Create new Converter using factory.

Reimplemented in PoolDbCnvSvc.

Definition at line 305 of file ConversionSvc.cpp.

References Service::serviceLocator().

Referenced by addConverter().

00307                                                                          {
00308   IConverter* pConverter;
00309   pConverter = PluginService::CreateWithId<IConverter*>(ConverterID(typ,clid),serviceLocator());
00310   if ( 0 == pConverter )  {
00311     typ = (typ<0xFF) ? typ : typ&0xFFFFFF00;
00312     pConverter = PluginService::CreateWithId<IConverter*>(ConverterID(typ,clid),serviceLocator());
00313   }
00314   return pConverter;
00315 }

StatusCode ConversionSvc::configureConverter ( long  typ,
const CLID clid,
IConverter cnv 
) [protected, virtual]

Configure the new converter before initialize is called.

Definition at line 318 of file ConversionSvc.cpp.

References StatusCode::ignore(), m_addressCreator, m_dataSvc, IConversionSvc::NO_CONVERTER, IConverter::setAddressCreator(), IConverter::setConversionSvc(), IConverter::setDataProvider(), and StatusCode::SUCCESS.

Referenced by addConverter().

00320                                                                          {
00321   if ( 0 != pConverter )    {
00322     pConverter->setConversionSvc(this).ignore();
00323     pConverter->setAddressCreator(m_addressCreator).ignore();
00324     pConverter->setDataProvider(m_dataSvc).ignore();
00325     return StatusCode::SUCCESS;
00326   }
00327   return NO_CONVERTER;
00328 }

StatusCode ConversionSvc::initializeConverter ( long  typ,
const CLID clid,
IConverter cnv 
) [protected, virtual]

Initialize the new converter.

Definition at line 331 of file ConversionSvc.cpp.

References IConverter::initialize(), and IConversionSvc::NO_CONVERTER.

Referenced by addConverter().

00333                                                                          {
00334   if ( pConverter )    {
00335     return pConverter->initialize();
00336   }
00337   return NO_CONVERTER;
00338 }

StatusCode ConversionSvc::activateConverter ( long  typ,
const CLID clid,
IConverter cnv 
) [protected, virtual]

Activate the new converter after initialization.

Definition at line 341 of file ConversionSvc.cpp.

References IConversionSvc::NO_CONVERTER, and StatusCode::SUCCESS.

Referenced by addConverter().

00343                                                                        {
00344   if ( 0 != pConverter )    {
00345     return StatusCode::SUCCESS;
00346   }
00347   return NO_CONVERTER;
00348 }

void ConversionSvc::loadConverter ( DataObject pObject  )  [protected, virtual]

Load converter or dictionary needed by the converter.

Reimplemented in PoolDbCnvSvc.

Definition at line 99 of file ConversionSvc.cpp.

Referenced by makeCall().

00099                                              {
00100   
00101 }

virtual IAddressCreator* ConversionSvc::addressCreator (  )  [inline, protected, virtual]

Retrieve address creation interface.

Definition at line 220 of file ConversionSvc.h.

References m_addressCreator.

00220                                               {
00221     return m_addressCreator;
00222   }

StatusCode ConversionSvc::makeCall ( int  typ,
bool  ignore_add,
bool  ignore_obj,
bool  update,
IOpaqueAddress *&  pAddress,
DataObject *&  pObject 
) [protected]

Definition at line 27 of file ConversionSvc.cpp.

References IOpaqueAddress::clID(), DataObject::clID(), CLID_NULL, converter(), CREATE_OBJ, CREATE_REP, IConverter::createObj(), IConverter::createRep(), endreq(), StatusCode::FAILURE, FILL_OBJ_REFS, FILL_REP_REFS, IConverter::fillObjRefs(), IConverter::fillRepRefs(), StatusCode::ignore(), MSG::INFO, IConverter::INVALID_ADDRESS, IConverter::INVALID_OBJECT, StatusCode::isSuccess(), loadConverter(), Service::msgSvc(), Service::name(), IConversionSvc::NO_CONVERTER, System::typeinfoName(), UPDATE_OBJ, UPDATE_OBJ_REFS, UPDATE_REP, UPDATE_REP_REFS, IConverter::updateObj(), IConverter::updateObjRefs(), IConverter::updateRep(), IConverter::updateRepRefs(), and updateServiceState().

Referenced by createObj(), createRep(), fillObjRefs(), fillRepRefs(), updateObj(), updateObjRefs(), updateRep(), and updateRepRefs().

00032                                                               {
00033   if ( 0 != pAddress || ignore_add )    {
00034     if ( 0 != pObject  || ignore_obj )    {
00035       const CLID&  obj_class =
00036         (0 != pObject && !ignore_obj) ? pObject->clID() 
00037         : (0 != pAddress && !ignore_add)
00038         ? pAddress->clID()                       
00039         : CLID_NULL;
00040       IConverter*  cnv  = converter(obj_class);
00041       if ( !cnv && pObject ) {
00042         //Give it a try to autoload the class (dictionary) for which the converter is needed
00043         loadConverter( pObject);
00044         cnv  = converter(obj_class);
00045       }
00046       
00047       StatusCode status(StatusCode::FAILURE,true);
00048       if ( 0 != cnv )   {
00049         switch(typ)   {
00050         case CREATE_OBJ:
00051           pObject = 0;
00052           status = cnv->createObj(pAddress, pObject);
00053           break;
00054         case FILL_OBJ_REFS:
00055           status = cnv->fillObjRefs(pAddress, pObject);
00056           break;
00057         case UPDATE_OBJ:
00058           status = cnv->updateObj(pAddress, pObject);
00059           break;
00060         case UPDATE_OBJ_REFS:
00061           status = cnv->updateObjRefs(pAddress, pObject);
00062           break;
00063         case CREATE_REP:
00064           pAddress = 0;
00065           status = cnv->createRep(pObject, pAddress);
00066           break;
00067         case FILL_REP_REFS:
00068           status = cnv->fillRepRefs(pAddress, pObject);
00069           break;
00070         case UPDATE_REP:
00071           status = cnv->updateRep(pAddress, pObject);
00072           break;
00073         case UPDATE_REP_REFS:
00074           status = cnv->updateRepRefs(pAddress, pObject);
00075           break;
00076         default:
00077           status = StatusCode::FAILURE;
00078           break;
00079         }
00080         if ( status.isSuccess() && update )   {
00081           status = updateServiceState(pAddress);
00082         }
00083         return status;
00084       }
00085       status.ignore();
00086       MsgStream log(msgSvc(), name());
00087       log << MSG::INFO << "No converter for object ";
00088       if ( pObject != 0 )   {
00089         log << System::typeinfoName(typeid(*pObject));
00090       }
00091       log << "  CLID= " << obj_class << endreq;
00092       return NO_CONVERTER;
00093     }
00094     return INVALID_OBJECT;
00095   }
00096   return INVALID_ADDRESS;
00097 }


Member Data Documentation

IDataProviderSvc* ConversionSvc::m_dataSvc [protected]

Pointer to data provider service.

Definition at line 233 of file ConversionSvc.h.

Referenced by configureConverter(), ConversionSvc(), dataProvider(), finalize(), and setDataProvider().

IAddressCreator* ConversionSvc::m_addressCreator [protected]

Pointer to the address creation service interface.

Definition at line 235 of file ConversionSvc.h.

Referenced by addressCreator(), configureConverter(), and setAddressCreator().

long ConversionSvc::m_type [protected]

Conversion service type.

Definition at line 237 of file ConversionSvc.h.

Referenced by ConversionSvc(), PoolDbCnvSvc::initialize(), and repSvcType().

Workers* ConversionSvc::m_workers [protected]

List of conversion workers.

Definition at line 239 of file ConversionSvc.h.

Referenced by addConverter(), ConversionSvc(), converter(), finalize(), removeConverter(), setAddressCreator(), setDataProvider(), and ~ConversionSvc().


The documentation for this class was generated from the following files:
Generated at Fri Jul 18 12:06:56 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004