ConversionSvc Class Reference

Base class for all conversion services. More...

#include <GaudiKernel/ConversionSvc.h>

Inheritance diagram for ConversionSvc:
Collaboration diagram for ConversionSvc:

Classes

class  CnvTest
 
class  WorkerEntry
 

Public Member Functions

virtual StatusCode initialize ()
 Initialize the service. More...
 
virtual StatusCode finalize ()
 stop the service. More...
 
virtual long repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
const CLIDobjType () const
 Implementation of IConverter: dummy call. More...
 
virtual StatusCode setDataProvider (IDataProviderSvc *pService)
 Implementation of IConverter: Set Data provider service. More...
 
virtual SmartIF< IDataProviderSvc > & dataProvider () const
 Implementation of IConverter: Get Data provider service. More...
 
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Implementation of IConverter: Set conversion service the converter is connected to. More...
 
virtual SmartIF< IConversionSvc > & conversionSvc () const
 Implementation of IConverter: Get conversion service the converter is connected to. More...
 
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility. More...
 
virtual SmartIF< IAddressCreator > & addressCreator () const
 Retrieve address creator facility. More...
 
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
 Implementation of IConverter: Create the transient representation of an object. More...
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the created transient object. More...
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
 Implementation of IConverter: Update the transient object from the other representation. More...
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the references of an updated transient object. More...
 
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Implementation of IConverter: Convert the transient object to the requested representation. More...
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the converted object. More...
 
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the converted representation of a transient object. More...
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the references of an already converted object. More...
 
virtual StatusCode addConverter (const CLID &clid)
 Add converter object to conversion service. More...
 
virtual StatusCode addConverter (IConverter *pConverter)
 Add converter object to conversion service. More...
 
virtual StatusCode removeConverter (const CLID &clid)
 Remove converter object from conversion service (if present). More...
 
virtual IConverterconverter (const CLID &wanted)
 Retrieve converter from list. More...
 
virtual StatusCode connectOutput (const std::string &outputFile, const std::string &openMode)
 Connect the output file to the service with open mode. More...
 
virtual StatusCode connectOutput (const std::string &output)
 Connect the output file to the service. More...
 
virtual StatusCode commitOutput (const std::string &output, bool do_commit)
 Commit pending output. More...
 
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. More...
 
virtual StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress)
 Convert an address to string form. More...
 
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress)
 Convert an address in string form to object form. More...
 
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service. More...
 
 ConversionSvc (const std::string &name, ISvcLocator *svc, long type)
 Standard Constructor. More...
 
virtual StatusCode initialize ()
 Initialize the service. More...
 
virtual StatusCode finalize ()
 stop the service. More...
 
virtual long repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
const CLIDobjType () const
 Implementation of IConverter: dummy call. More...
 
virtual StatusCode setDataProvider (IDataProviderSvc *pService)
 Implementation of IConverter: Set Data provider service. More...
 
virtual SmartIF< IDataProviderSvc > & dataProvider () const
 Implementation of IConverter: Get Data provider service. More...
 
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Implementation of IConverter: Set conversion service the converter is connected to. More...
 
virtual SmartIF< IConversionSvc > & conversionSvc () const
 Implementation of IConverter: Get conversion service the converter is connected to. More...
 
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility. More...
 
virtual SmartIF< IAddressCreator > & addressCreator () const
 Retrieve address creator facility. More...
 
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
 Implementation of IConverter: Create the transient representation of an object. More...
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the created transient object. More...
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
 Implementation of IConverter: Update the transient object from the other representation. More...
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the references of an updated transient object. More...
 
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Implementation of IConverter: Convert the transient object to the requested representation. More...
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the converted object. More...
 
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the converted representation of a transient object. More...
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the references of an already converted object. More...
 
virtual StatusCode addConverter (const CLID &clid)
 Add converter object to conversion service. More...
 
virtual StatusCode addConverter (IConverter *pConverter)
 Add converter object to conversion service. More...
 
virtual StatusCode removeConverter (const CLID &clid)
 Remove converter object from conversion service (if present). More...
 
virtual IConverterconverter (const CLID &wanted)
 Retrieve converter from list. More...
 
virtual StatusCode connectOutput (const std::string &outputFile, const std::string &openMode)
 Connect the output file to the service with open mode. More...
 
virtual StatusCode connectOutput (const std::string &output)
 Connect the output file to the service. More...
 
virtual StatusCode commitOutput (const std::string &output, bool do_commit)
 Commit pending output. More...
 
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. More...
 
virtual StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress)
 Convert an address to string form. More...
 
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress)
 Convert an address in string form to object form. More...
 
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service. More...
 
 ConversionSvc (const std::string &name, ISvcLocator *svc, long type)
 Standard Constructor. More...
 
- Public Member Functions inherited from extends< BASE, Interfaces >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Member Functions

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

Protected Attributes

SmartIF< IDataProviderSvcm_dataSvc
 Pointer to data provider service. More...
 
SmartIF< IAddressCreatorm_addressCreator
 Pointer to the address creation service interface. More...
 
SmartIF< IConversionSvcm_cnvSvc
 Pointer to the IConversionSvc interface of this. More...
 
long m_type
 Conversion service type. More...
 
std::vector< WorkerEntrym_workers
 List of conversion workers. More...
 

Private Member Functions

 ConversionSvc (const ConversionSvc &)
 Fake copy constructor (never implemented). More...
 
ConversionSvcoperator= (const ConversionSvc &)
 Fake assignment operator (never implemented). More...
 
 ConversionSvc (const ConversionSvc &)
 Fake copy constructor (never implemented). More...
 
ConversionSvcoperator= (const ConversionSvc &)
 Fake assignment operator (never implemented). More...
 

Additional Inherited Members

- Public Types inherited from extends< BASE, Interfaces >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 

Detailed Description

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:

  • findCnvFactory: returns a suitable converter factory
  • createConverter: the actual convetrer creation
  • configureConverter: configure converter before initialize
  • initializeConverter: initializes the converter
  • activateConverter: any additional configuration to be done after initialize.

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.

Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 383 of file ConversionSvc.cpp.

384  : base_class(name, svc),
385  m_cnvSvc(static_cast<IConversionSvc*>(this))
386 {
387  m_type = type;
388  m_dataSvc = nullptr;
389  setAddressCreator(this).ignore();
390 }
extends base_class
Typedef to this class.
Definition: extends.h:14
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
virtual StatusCode setAddressCreator(IAddressCreator *creator)
Set address creator facility.
long m_type
Conversion service type.
void ignore() const
Definition: StatusCode.h:108
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
string type
Definition: gaudirun.py:151
ConversionSvc::~ConversionSvc ( )
protectedvirtual

Standard Destructor.

Definition at line 393 of file ConversionSvc.cpp.

393  {
394  // Release all workers.
395  for ( auto & i : m_workers ) i.converter()->release();
396 }
std::vector< WorkerEntry > m_workers
List of conversion workers.
list i
Definition: ana.py:128
ConversionSvc::ConversionSvc ( const ConversionSvc )
private

Fake copy constructor (never implemented).

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

Standard Constructor.

virtual ConversionSvc::~ConversionSvc ( )
protectedvirtual

Standard Destructor.

ConversionSvc::ConversionSvc ( const ConversionSvc )
private

Fake copy constructor (never implemented).

Member Function Documentation

StatusCode ConversionSvc::activateConverter ( long  typ,
const CLID clid,
IConverter cnv 
)
protectedvirtual

Activate the new converter after initialization.

Activate the freshly created converter.

Definition at line 321 of file ConversionSvc.cpp.

323  {
324  return pConverter ? StatusCode{StatusCode::SUCCESS}
325  : NO_CONVERTER;
326 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode ConversionSvc::activateConverter ( long  typ,
const CLID clid,
IConverter cnv 
)
protectedvirtual

Activate the new converter after initialization.

StatusCode ConversionSvc::addConverter ( const CLID clid)
virtual

Add converter object to conversion service.

Definition at line 212 of file ConversionSvc.cpp.

212  {
213  // First look for the more specific converter
214  long typ = repSvcType();
215  IConverter* pConverter = createConverter(typ, clid, nullptr);
216  if ( pConverter ) {
217  StatusCode status = configureConverter( typ, clid, pConverter );
218  if ( status.isSuccess() ) {
219  status = initializeConverter( typ, clid, pConverter );
220  if ( status.isSuccess() ) {
221  status = activateConverter( typ, clid, pConverter );
222  if ( status.isSuccess() ) {
223  long conv_typ = pConverter->repSvcType();
224  const CLID& conv_clid = pConverter->objType();
225  typ = (typ<0xFF) ? typ : typ&0xFFFFFF00;
226  conv_typ = (conv_typ<0xFF) ? conv_typ : conv_typ&0xFFFFFF00;
227  if ( conv_typ == typ && conv_clid == clid ) {
228  return addConverter(pConverter);
229  }
230  }
231  }
232  }
233  pConverter->release();
234  }
235  return NO_CONVERTER;
236 }
virtual const CLID & objType() const =0
Retrieve the class type of objects the converter produces.
virtual StatusCode configureConverter(long typ, const CLID &clid, IConverter *cnv)
Configure the new converter before initialize is called.
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
virtual StatusCode addConverter(const CLID &clid)
Add converter object to conversion service.
virtual long repSvcType() const
Retrieve the class type of the data store the converter uses.
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode initializeConverter(long typ, const CLID &clid, IConverter *cnv)
Initialize the new converter.
virtual unsigned long release()=0
Release Interface instance.
virtual IConverter * createConverter(long typ, const CLID &clid, const ICnvFactory *fac)
Create new Converter using factory.
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
virtual StatusCode activateConverter(long typ, const CLID &clid, IConverter *cnv)
Activate the new converter after initialization.
virtual StatusCode ConversionSvc::addConverter ( const CLID clid)
virtual

Add converter object to conversion service.

StatusCode ConversionSvc::addConverter ( IConverter pConverter)
virtual

Add converter object to conversion service.

Definition at line 239 of file ConversionSvc.cpp.

239  {
240  if ( pConverter ) {
241  const CLID& clid = pConverter->objType();
242  removeConverter(clid).ignore();
243  m_workers.emplace_back(clid, pConverter);
244  pConverter->addRef();
245  return StatusCode::SUCCESS;
246  }
247  return NO_CONVERTER;
248 }
virtual const CLID & objType() const =0
Retrieve the class type of objects the converter produces.
std::vector< WorkerEntry > m_workers
List of conversion workers.
virtual StatusCode removeConverter(const CLID &clid)
Remove converter object from conversion service (if present).
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
void ignore() const
Definition: StatusCode.h:108
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
virtual StatusCode ConversionSvc::addConverter ( IConverter pConverter)
virtual

Add converter object to conversion service.

SmartIF< IAddressCreator > & ConversionSvc::addressCreator ( ) const
virtual

Retrieve address creator facility.

Access the transient store.

Definition at line 197 of file ConversionSvc.cpp.

197  {
198  return m_addressCreator;
199 }
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
virtual SmartIF<IAddressCreator>& ConversionSvc::addressCreator ( ) const
virtual

Retrieve address creator facility.

virtual SmartIF<IAddressCreator>& ConversionSvc::addressCreator ( )
inlineprotectedvirtual

Retrieve address creation interface.

Definition at line 210 of file ConversionSvc.h.

210  {
211  return m_addressCreator;
212  }
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
virtual SmartIF<IAddressCreator>& ConversionSvc::addressCreator ( )
inlineprotectedvirtual

Retrieve address creation interface.

Definition at line 210 of file ConversionSvc.h.

210  {
211  return m_addressCreator;
212  }
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
StatusCode ConversionSvc::commitOutput ( const std::string &  output,
bool  do_commit 
)
virtual

Commit pending output.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

Definition at line 350 of file ConversionSvc.cpp.

350  {
351  return StatusCode::SUCCESS;
352 }
virtual StatusCode ConversionSvc::commitOutput ( const std::string &  output,
bool  do_commit 
)
virtual

Commit pending output.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

virtual StatusCode ConversionSvc::configureConverter ( long  typ,
const CLID clid,
IConverter cnv 
)
protectedvirtual

Configure the new converter before initialize is called.

StatusCode ConversionSvc::configureConverter ( long  typ,
const CLID clid,
IConverter cnv 
)
protectedvirtual

Configure the new converter before initialize is called.

Configure the freshly created converter.

Definition at line 302 of file ConversionSvc.cpp.

304  {
305  if ( !pConverter ) return NO_CONVERTER;
306  pConverter->setConversionSvc(this).ignore();
307  pConverter->setAddressCreator(m_addressCreator).ignore();
308  pConverter->setDataProvider(m_dataSvc).ignore();
309  return StatusCode::SUCCESS;
310 }
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
StatusCode ConversionSvc::connectOutput ( const std::string &  outputFile,
const std::string &  openMode 
)
virtual

Connect the output file to the service with open mode.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

Definition at line 339 of file ConversionSvc.cpp.

340  {
341  return connectOutput(outputFile);
342 }
virtual StatusCode connectOutput(const std::string &outputFile, const std::string &openMode)
Connect the output file to the service with open mode.
virtual StatusCode ConversionSvc::connectOutput ( const std::string &  outputFile,
const std::string &  openMode 
)
virtual

Connect the output file to the service with open mode.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

StatusCode ConversionSvc::connectOutput ( const std::string &  output)
virtual

Connect the output file to the service.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

Definition at line 345 of file ConversionSvc.cpp.

345  {
346  return StatusCode::SUCCESS;
347 }
virtual StatusCode ConversionSvc::connectOutput ( const std::string &  output)
virtual

Connect the output file to the service.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

SmartIF< IConversionSvc > & ConversionSvc::conversionSvc ( ) const
virtual

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

Get conversion service the converter is connected to.

Definition at line 207 of file ConversionSvc.cpp.

207  {
208  return m_cnvSvc;
209 }
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
virtual SmartIF<IConversionSvc>& ConversionSvc::conversionSvc ( ) const
virtual

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

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

Convert an address to string form.

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

Convert an address to string form.

Definition at line 365 of file ConversionSvc.cpp.

367 {
368  refAddress.clear();
369  return StatusCode::FAILURE;
370 }
IConverter * ConversionSvc::converter ( const CLID wanted)
virtual

Retrieve converter from list.

Definition at line 144 of file ConversionSvc.cpp.

144  {
145  IConverter* cnv = nullptr;
146  auto i = std::find_if(m_workers.begin(),m_workers.end(),CnvTest(clid));
147  if ( i != m_workers.end() ) {
148  cnv = i->converter();
149  }
150  if ( !cnv ) {
151  StatusCode status = addConverter(clid);
152  if ( status.isSuccess() ) {
153  i = std::find_if(m_workers.begin(),m_workers.end(),CnvTest(clid));
154  if ( i != m_workers.end() ) {
155  cnv = i->converter();
156  }
157  }
158  }
159  return cnv;
160 }
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
virtual StatusCode addConverter(const CLID &clid)
Add converter object to conversion service.
std::vector< WorkerEntry > m_workers
List of conversion workers.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
list i
Definition: ana.py:128
virtual IConverter* ConversionSvc::converter ( const CLID wanted)
virtual

Retrieve converter from list.

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.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

Definition at line 355 of file ConversionSvc.cpp.

359  {
360  refpAddress = nullptr;
361  return StatusCode::FAILURE;
362 }
virtual 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.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

virtual 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.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

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.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

Definition at line 373 of file ConversionSvc.cpp.

377 {
378  refpAddress = nullptr;
379  return StatusCode::FAILURE;
380 }
virtual IConverter* ConversionSvc::createConverter ( long  typ,
const CLID clid,
const ICnvFactory *  fac 
)
protectedvirtual

Create new Converter using factory.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

IConverter * ConversionSvc::createConverter ( long  typ,
const CLID clid,
const ICnvFactory *  fac 
)
protectedvirtual

Create new Converter using factory.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

Definition at line 290 of file ConversionSvc.cpp.

292  {
293  IConverter* pConverter = Converter::Factory::create(ConverterID(typ,clid), serviceLocator().get());
294  if ( !pConverter ) {
295  typ = (typ<0xFF) ? typ : typ&0xFFFFFF00;
296  pConverter = Converter::Factory::create(ConverterID(typ,clid), serviceLocator().get());
297  }
298  return pConverter;
299 }
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
StatusCode ConversionSvc::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 104 of file ConversionSvc.cpp.

104  {
105  return makeCall(CREATE_OBJ, false, true, false, pAddress, refpObj);
106 }
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
virtual StatusCode ConversionSvc::createObj ( IOpaqueAddress pAddress,
DataObject *&  refpObject 
)
virtual

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

StatusCode ConversionSvc::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 RootHistCnv::PersSvc.

Definition at line 124 of file ConversionSvc.cpp.

124  {
125  return makeCall(CREATE_REP, true, false, false, refpAddress, pObj);
126 }
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
virtual StatusCode ConversionSvc::createRep ( DataObject pObject,
IOpaqueAddress *&  refpAddress 
)
virtual

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

Reimplemented in RootHistCnv::PersSvc.

virtual SmartIF<IDataProviderSvc>& ConversionSvc::dataProvider ( ) const
virtual

Implementation of IConverter: Get Data provider service.

Returns
Pointer to data provider service
SmartIF< IDataProviderSvc > & ConversionSvc::dataProvider ( ) const
virtual

Implementation of IConverter: Get Data provider service.

Access the transient store.

Returns
Pointer to data provider service

Definition at line 177 of file ConversionSvc.cpp.

177  {
178  return m_dataSvc;
179 }
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
virtual StatusCode ConversionSvc::fillObjRefs ( IOpaqueAddress pAddress,
DataObject pObject 
)
virtual

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

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

109  {
110  return makeCall(FILL_OBJ_REFS, false, true, true, pAddress, pObj);
111 }
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
StatusCode ConversionSvc::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 129 of file ConversionSvc.cpp.

129  {
130  return makeCall(FILL_REP_REFS, true, false, false, pAddress, pObj);
131 }
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
virtual StatusCode ConversionSvc::fillRepRefs ( IOpaqueAddress pAddress,
DataObject pObject 
)
virtual

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

virtual StatusCode ConversionSvc::finalize ( )
virtual

stop the service.

Reimplemented in Gaudi::RootCnvSvc, Gaudi::RootCnvSvc, and RootHistCnv::PersSvc.

StatusCode ConversionSvc::finalize ( )
virtual

stop the service.

Reimplemented in Gaudi::RootCnvSvc, Gaudi::RootCnvSvc, and RootHistCnv::PersSvc.

Definition at line 271 of file ConversionSvc.cpp.

271  {
272  // Release all workers.
273  MsgStream log(msgSvc(), name());
274  for ( auto& i : m_workers ) {
275  if ( i.converter()->finalize().isFailure() ) {
276  log << MSG::ERROR << "finalizing worker" << endmsg;
277  }
278  i.converter()->release();
279  }
280  m_workers.clear();
281  // release interfaces
282  m_addressCreator = nullptr;
283  m_dataSvc = nullptr;
284  m_cnvSvc = nullptr;
285  return Service::finalize();
286 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode finalize() override
Definition: Service.cpp:188
std::vector< WorkerEntry > m_workers
List of conversion workers.
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
list i
Definition: ana.py:128
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
StatusCode ConversionSvc::initialize ( )
virtual

Initialize the service.

Reimplemented in Gaudi::RootCnvSvc, Gaudi::RootCnvSvc, and RootHistCnv::PersSvc.

Definition at line 265 of file ConversionSvc.cpp.

265  {
266  StatusCode status = Service::initialize();
267  return status;
268 }
StatusCode initialize() override
Definition: Service.cpp:63
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode ConversionSvc::initialize ( )
virtual

Initialize the service.

Reimplemented in Gaudi::RootCnvSvc, Gaudi::RootCnvSvc, and RootHistCnv::PersSvc.

StatusCode ConversionSvc::initializeConverter ( long  typ,
const CLID clid,
IConverter cnv 
)
protectedvirtual

Initialize the new converter.

Initialize new converter.

Definition at line 313 of file ConversionSvc.cpp.

315  {
316  return pConverter ? pConverter->initialize()
317  : NO_CONVERTER;
318 }
virtual StatusCode ConversionSvc::initializeConverter ( long  typ,
const CLID clid,
IConverter cnv 
)
protectedvirtual

Initialize the new converter.

void ConversionSvc::loadConverter ( DataObject pObject)
protectedvirtual

Load converter or dictionary needed by the converter.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

Definition at line 95 of file ConversionSvc.cpp.

95  {
96 
97 }
virtual void ConversionSvc::loadConverter ( DataObject pObject)
protectedvirtual

Load converter or dictionary needed by the converter.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

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

Definition at line 23 of file ConversionSvc.cpp.

28  {
29  if ( pAddress || ignore_add ) {
30  if ( pObject || ignore_obj ) {
31  const CLID& obj_class =
32  ( pObject && !ignore_obj) ? pObject->clID()
33  : ( pAddress && !ignore_add)
34  ? pAddress->clID()
35  : CLID_NULL;
36  IConverter* cnv = converter(obj_class);
37  if ( !cnv && pObject ) {
38  //Give it a try to autoload the class (dictionary) for which the converter is needed
39  loadConverter( pObject);
40  cnv = converter(obj_class);
41  }
42 
43  StatusCode status(StatusCode::FAILURE,true);
44  if ( cnv ) {
45  switch(typ) {
46  case CREATE_OBJ:
47  pObject = nullptr;
48  status = cnv->createObj(pAddress, pObject);
49  break;
50  case FILL_OBJ_REFS:
51  status = cnv->fillObjRefs(pAddress, pObject);
52  break;
53  case UPDATE_OBJ:
54  status = cnv->updateObj(pAddress, pObject);
55  break;
56  case UPDATE_OBJ_REFS:
57  status = cnv->updateObjRefs(pAddress, pObject);
58  break;
59  case CREATE_REP:
60  pAddress = nullptr;
61  status = cnv->createRep(pObject, pAddress);
62  break;
63  case FILL_REP_REFS:
64  status = cnv->fillRepRefs(pAddress, pObject);
65  break;
66  case UPDATE_REP:
67  status = cnv->updateRep(pAddress, pObject);
68  break;
69  case UPDATE_REP_REFS:
70  status = cnv->updateRepRefs(pAddress, pObject);
71  break;
72  default:
73  status = StatusCode::FAILURE;
74  break;
75  }
76  if ( status.isSuccess() && update ) {
77  status = updateServiceState(pAddress);
78  }
79  return status;
80  }
81  status.ignore();
82  MsgStream log(msgSvc(), name());
83  log << MSG::INFO << "No converter for object ";
84  if ( pObject ) {
85  log << System::typeinfoName(typeid(*pObject));
86  }
87  log << " CLID= " << obj_class << endmsg;
88  return NO_CONVERTER;
89  }
90  return INVALID_OBJECT;
91  }
92  return INVALID_ADDRESS;
93 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:297
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
virtual void loadConverter(DataObject *pObject)
Load converter or dictionary needed by the converter.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:68
virtual const CLID & clID() const =0
Retrieve class information from link.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
def update
Definition: install.py:213
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
virtual IConverter * converter(const CLID &wanted)
Retrieve converter from list.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
StatusCode ConversionSvc::makeCall ( int  typ,
bool  ignore_add,
bool  ignore_obj,
bool  update,
IOpaqueAddress *&  pAddress,
DataObject *&  pObject 
)
protected
const CLID & ConversionSvc::objType ( ) const

Implementation of IConverter: dummy call.

Retrieve the class type of objects the converter produces.

Definition at line 329 of file ConversionSvc.cpp.

329  {
330  return CLID_NULL;
331 }
const CLID& ConversionSvc::objType ( ) const

Implementation of IConverter: dummy call.

ConversionSvc& ConversionSvc::operator= ( const ConversionSvc )
private

Fake assignment operator (never implemented).

ConversionSvc& ConversionSvc::operator= ( const ConversionSvc )
private

Fake assignment operator (never implemented).

StatusCode ConversionSvc::removeConverter ( const CLID clid)
virtual

Remove converter object from conversion service (if present).

Definition at line 251 of file ConversionSvc.cpp.

251  {
252 
253  auto i = std::partition( std::begin(m_workers), std::end(m_workers),
254  std::not1( CnvTest{clid} ) );
255  if ( i == std::end(m_workers) ) return NO_CONVERTER;
256  std::for_each( i, std::end(m_workers), []( WorkerEntry& w ) {
257  w.converter()->finalize().ignore();
258  w.converter()->release();
259  });
260  m_workers.erase( i, std::end(m_workers) );
261  return StatusCode::SUCCESS;
262 }
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:45
std::vector< WorkerEntry > m_workers
List of conversion workers.
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
list i
Definition: ana.py:128
virtual StatusCode ConversionSvc::removeConverter ( const CLID clid)
virtual

Remove converter object from conversion service (if present).

virtual long ConversionSvc::repSvcType ( ) const
virtual

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

long ConversionSvc::repSvcType ( ) const
virtual

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

Definition at line 334 of file ConversionSvc.cpp.

334  {
335  return m_type;
336 }
long m_type
Conversion service type.
StatusCode ConversionSvc::setAddressCreator ( IAddressCreator creator)
virtual

Set address creator facility.

Definition at line 182 of file ConversionSvc.cpp.

182  {
183  m_addressCreator = creator;
184  for(auto& i : m_workers ) {
185  auto* cnv = i.converter();
186  if ( cnv ) {
187  if (cnv->setAddressCreator(m_addressCreator).isFailure()) {
188  MsgStream log(msgSvc(), name());
189  log << MSG::ERROR << "setting Address Creator" << endmsg;
190  }
191  }
192  }
193  return StatusCode::SUCCESS;
194 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::vector< WorkerEntry > m_workers
List of conversion workers.
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
list i
Definition: ana.py:128
virtual StatusCode ConversionSvc::setAddressCreator ( IAddressCreator creator)
virtual

Set address creator facility.

StatusCode ConversionSvc::setConversionSvc ( IConversionSvc svc)
virtual

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

Set conversion service the converter is connected to.

Definition at line 202 of file ConversionSvc.cpp.

202  {
203  return StatusCode::FAILURE;
204 }
virtual StatusCode ConversionSvc::setConversionSvc ( IConversionSvc svc)
virtual

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

virtual StatusCode ConversionSvc::setDataProvider ( IDataProviderSvc pService)
virtual

Implementation of IConverter: Set Data provider service.

Returns
Status code indicating success or failure
Parameters
pServicePointer to data provider service
StatusCode ConversionSvc::setDataProvider ( IDataProviderSvc pService)
virtual

Implementation of IConverter: Set Data provider service.

Define transient data store.

Returns
Status code indicating success or failure
Parameters
pServicePointer to data provider service

Definition at line 163 of file ConversionSvc.cpp.

163  {
164  if ( !pDataSvc ) return StatusCode::SUCCESS; //Atlas does not use DataSvc
165  m_dataSvc = pDataSvc;
166  for(auto& i : m_workers ) {
167  IConverter* cnv = i.converter();
168  if ( cnv && cnv->setDataProvider(m_dataSvc).isFailure()) {
169  MsgStream log(msgSvc(), name());
170  log << MSG::ERROR << "setting Data Provider" << endmsg;
171  }
172  }
173  return StatusCode::SUCCESS;
174 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
std::vector< WorkerEntry > m_workers
List of conversion workers.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
list i
Definition: ana.py:128
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
StatusCode ConversionSvc::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 114 of file ConversionSvc.cpp.

114  {
115  return makeCall(UPDATE_OBJ, false, true, false, pAddress, pObj);
116 }
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
virtual StatusCode ConversionSvc::updateObj ( IOpaqueAddress pAddress,
DataObject refpObject 
)
virtual

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

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

119  {
120  return makeCall(UPDATE_OBJ_REFS, false, true, true, pAddress, pObj);
121 }
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
virtual StatusCode ConversionSvc::updateObjRefs ( IOpaqueAddress pAddress,
DataObject pObject 
)
virtual

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

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

134  {
135  return makeCall(UPDATE_REP, true, false, false, pAddress, pObj);
136 }
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
virtual StatusCode ConversionSvc::updateRep ( IOpaqueAddress pAddress,
DataObject pObject 
)
virtual

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

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

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

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

139  {
140  return makeCall(UPDATE_REP_REFS, true, false, false, pAddress, pObj);
141 }
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
virtual StatusCode ConversionSvc::updateServiceState ( IOpaqueAddress pAddress)
virtual

Update state of the service.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

StatusCode ConversionSvc::updateServiceState ( IOpaqueAddress pAddress)
virtual

Update state of the service.

Reimplemented in Gaudi::RootCnvSvc, and Gaudi::RootCnvSvc.

Definition at line 99 of file ConversionSvc.cpp.

99  {
100  return StatusCode::SUCCESS;
101 }

Member Data Documentation

SmartIF< IAddressCreator > ConversionSvc::m_addressCreator
mutableprotected

Pointer to the address creation service interface.

Definition at line 225 of file ConversionSvc.h.

SmartIF< IConversionSvc > ConversionSvc::m_cnvSvc
mutableprotected

Pointer to the IConversionSvc interface of this.

Definition at line 227 of file ConversionSvc.h.

SmartIF< IDataProviderSvc > ConversionSvc::m_dataSvc
mutableprotected

Pointer to data provider service.

Definition at line 223 of file ConversionSvc.h.

long ConversionSvc::m_type
protected

Conversion service type.

Definition at line 229 of file ConversionSvc.h.

std::vector< WorkerEntry > ConversionSvc::m_workers
protected

List of conversion workers.

Definition at line 231 of file ConversionSvc.h.


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