The Gaudi Framework  v36r1 (3e2fb5a8)
ConversionSvc Class Reference

#include <GaudiKernel/ConversionSvc.h>

Inheritance diagram for ConversionSvc:
Collaboration diagram for ConversionSvc:

Classes

class  WorkerEntry
 

Public Member Functions

 ConversionSvc (const std::string &name, ISvcLocator *svc, long type)
 Standard Constructor. More...
 
 ConversionSvc (const ConversionSvc &)=delete
 disable copy and assignment More...
 
ConversionSvcoperator= (const ConversionSvc &)=delete
 
StatusCode initialize () override
 Initialize the service. More...
 
StatusCode finalize () override
 stop the service. More...
 
long repSvcType () const override
 Retrieve the class type of the data store the converter uses. More...
 
const CLIDobjType () const override
 Implementation of IConverter: dummy call. More...
 
StatusCode setDataProvider (IDataProviderSvc *pService) override
 Implementation of IConverter: Set Data provider service. More...
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Implementation of IConverter: Get Data provider service. More...
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Implementation of IConverter: Set conversion service the converter is connected to. More...
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Implementation of IConverter: Get conversion service the converter is connected to. More...
 
StatusCode setAddressCreator (IAddressCreator *creator) override
 Set address creator facility. More...
 
SmartIF< IAddressCreator > & addressCreator () const override
 Retrieve address creator facility. More...
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Implementation of IConverter: Create the transient representation of an object. More...
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the created transient object. More...
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Implementation of IConverter: Update the transient object from the other representation. More...
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an updated transient object. More...
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Implementation of IConverter: Convert the transient object to the requested representation. More...
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the converted object. More...
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the converted representation of a transient object. More...
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an already converted object. More...
 
StatusCode addConverter (const CLID &clid) override
 Add converter object to conversion service. More...
 
StatusCode addConverter (IConverter *pConverter) override
 Add converter object to conversion service. More...
 
StatusCode removeConverter (const CLID &clid) override
 Remove converter object from conversion service (if present). More...
 
IConverterconverter (const CLID &wanted) override
 Retrieve converter from list. More...
 
StatusCode connectOutput (const std::string &outputFile, const std::string &openMode) override
 Connect the output file to the service with open mode. More...
 
StatusCode connectOutput (const std::string &output) override
 Connect the output file to the service. More...
 
StatusCode commitOutput (const std::string &output, bool do_commit) override
 Commit pending output. More...
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
 Create a Generic address using explicit arguments to identify a single object. More...
 
StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress) override
 Convert an address to string form. More...
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) override
 Convert an address in string form to object form. More...
 
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service. More...
 
- Public Member Functions inherited from extends< Service, IConversionSvc, IAddressCreator >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service
More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service
More...
 
StatusCode sysStart () override
 Initialize Service
More...
 
StatusCode sysStop () override
 Initialize Service
More...
 
StatusCode sysFinalize () override
 Finalize Service
More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator
More...
 
StatusCode setProperties ()
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Protected Member Functions

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 Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 Standard Destructor
More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

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...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
Gaudi::Property< bool > m_autoRetrieveTools {this, "AutoRetrieveTools", true, "retrieve all AlgTools during initialize"}
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service
More...
 

Additional Inherited Members

- Public Types inherited from extends< Service, IConversionSvc, IAddressCreator >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

Detailed Description

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 55 of file ConversionSvc.h.

Constructor & Destructor Documentation

◆ ConversionSvc() [1/2]

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

Standard Constructor.

Definition at line 320 of file ConversionSvc.cpp.

321  : base_class( name, svc ), m_cnvSvc( this ) {
322  m_type = type;
323  m_dataSvc = nullptr;
324  setAddressCreator( this ).ignore();
325 }

◆ ConversionSvc() [2/2]

ConversionSvc::ConversionSvc ( const ConversionSvc )
delete

disable copy and assignment

Member Function Documentation

◆ activateConverter()

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 277 of file ConversionSvc.cpp.

277  {
278  return pConverter ? StatusCode::SUCCESS : StatusCode( Status::NO_CONVERTER );
279 }

◆ addConverter() [1/2]

StatusCode ConversionSvc::addConverter ( const CLID clid)
override

Add converter object to conversion service.

Definition at line 189 of file ConversionSvc.cpp.

189  {
190  // First look for the more specific converter
191  long typ = repSvcType();
192  IConverter* pConverter = createConverter( typ, clid, nullptr );
193  if ( pConverter ) {
194  StatusCode status = configureConverter( typ, clid, pConverter );
195  if ( status.isSuccess() ) {
196  status = initializeConverter( typ, clid, pConverter );
197  if ( status.isSuccess() ) {
198  status = activateConverter( typ, clid, pConverter );
199  if ( status.isSuccess() ) {
200  long conv_typ = pConverter->repSvcType();
201  const CLID& conv_clid = pConverter->objType();
202  typ = ( typ < 0xFF ) ? typ : typ & 0xFFFFFF00;
203  conv_typ = ( conv_typ < 0xFF ) ? conv_typ : conv_typ & 0xFFFFFF00;
204  if ( conv_typ == typ && conv_clid == clid ) { return addConverter( pConverter ); }
205  }
206  }
207  }
208  pConverter->release();
209  }
210  return Status::NO_CONVERTER;
211 }

◆ addConverter() [2/2]

StatusCode ConversionSvc::addConverter ( IConverter pConverter)
override

Add converter object to conversion service.

Definition at line 214 of file ConversionSvc.cpp.

214  {
215  if ( pConverter ) {
216  const CLID& clid = pConverter->objType();
217  removeConverter( clid ).ignore();
218  m_workers.emplace_back( clid, pConverter );
219  return StatusCode::SUCCESS;
220  }
221  return Status::NO_CONVERTER;
222 }

◆ addressCreator() [1/2]

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

Retrieve address creation interface.

Definition at line 205 of file ConversionSvc.h.

205 { return m_addressCreator; }

◆ addressCreator() [2/2]

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

Retrieve address creator facility.

Access the transient store.

Definition at line 180 of file ConversionSvc.cpp.

180 { return m_addressCreator; }

◆ commitOutput()

StatusCode ConversionSvc::commitOutput ( const std::string output,
bool  do_commit 
)
override

Commit pending output.

Definition at line 296 of file ConversionSvc.cpp.

296 { return StatusCode::SUCCESS; }

◆ configureConverter()

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 263 of file ConversionSvc.cpp.

263  {
264  if ( !pConverter ) return Status::NO_CONVERTER;
265  pConverter->setConversionSvc( this ).ignore();
266  pConverter->setAddressCreator( m_addressCreator ).ignore();
267  pConverter->setDataProvider( m_dataSvc ).ignore();
268  return StatusCode::SUCCESS;
269 }

◆ connectOutput() [1/2]

StatusCode ConversionSvc::connectOutput ( const std::string output)
override

Connect the output file to the service.

Definition at line 293 of file ConversionSvc.cpp.

293 { return StatusCode::SUCCESS; }

◆ connectOutput() [2/2]

StatusCode ConversionSvc::connectOutput ( const std::string outputFile,
const std::string openMode 
)
override

Connect the output file to the service with open mode.

Definition at line 288 of file ConversionSvc.cpp.

288  {
289  return connectOutput( outputFile );
290 }

◆ conversionSvc()

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

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

Get conversion service the converter is connected to.

Definition at line 186 of file ConversionSvc.cpp.

186 { return m_cnvSvc; }

◆ convertAddress()

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

Convert an address to string form.

Definition at line 307 of file ConversionSvc.cpp.

307  {
308  refAddress.clear();
309  return StatusCode::FAILURE;
310 }

◆ converter()

IConverter * ConversionSvc::converter ( const CLID wanted)
override

Retrieve converter from list.

Definition at line 139 of file ConversionSvc.cpp.

139  {
140  IConverter* cnv = nullptr;
141  auto i = std::find_if( m_workers.begin(), m_workers.end(), CnvTest( clid ) );
142  if ( i != m_workers.end() ) cnv = i->converter();
143  if ( !cnv ) {
144  StatusCode status = addConverter( clid );
145  if ( status.isSuccess() ) {
146  i = std::find_if( m_workers.begin(), m_workers.end(), CnvTest( clid ) );
147  if ( i != m_workers.end() ) cnv = i->converter();
148  }
149  }
150  return cnv;
151 }

◆ createAddress() [1/2]

StatusCode ConversionSvc::createAddress ( long  svc_type,
const CLID clid,
const std::string refAddress,
IOpaqueAddress *&  refpAddress 
)
override

Convert an address in string form to object form.

Definition at line 313 of file ConversionSvc.cpp.

314  {
315  refpAddress = nullptr;
316  return StatusCode::FAILURE;
317 }

◆ createAddress() [2/2]

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

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

Definition at line 299 of file ConversionSvc.cpp.

301  {
302  refpAddress = nullptr;
303  return StatusCode::FAILURE;
304 }

◆ createConverter()

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

Create new Converter using factory.

Reimplemented in Gaudi::RootCnvSvc.

Definition at line 253 of file ConversionSvc.cpp.

253  {
254  IConverter* pConverter = Converter::Factory::create( ConverterID( typ, clid ), serviceLocator().get() ).release();
255  if ( !pConverter ) {
256  typ = ( typ < 0xFF ) ? typ : typ & 0xFFFFFF00;
257  pConverter = Converter::Factory::create( ConverterID( typ, clid ), serviceLocator().get() ).release();
258  }
259  return pConverter;
260 }

◆ createObj()

StatusCode ConversionSvc::createObj ( IOpaqueAddress pAddress,
DataObject *&  refpObject 
)
override

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

Create the transient representation of an object.

Definition at line 99 of file ConversionSvc.cpp.

99  {
100  return makeCall( CREATE_OBJ, false, true, false, pAddress, refpObj );
101 }

◆ createRep()

StatusCode ConversionSvc::createRep ( DataObject pObject,
IOpaqueAddress *&  refpAddress 
)
override

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

Convert the transient object to the requested representation.

Definition at line 119 of file ConversionSvc.cpp.

119  {
120  return makeCall( CREATE_REP, true, false, false, refpAddress, pObj );
121 }

◆ dataProvider()

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

Implementation of IConverter: Get Data provider service.

Access the transient store.

Returns
Pointer to data provider service

Definition at line 165 of file ConversionSvc.cpp.

165 { return m_dataSvc; }

◆ fillObjRefs()

StatusCode ConversionSvc::fillObjRefs ( IOpaqueAddress pAddress,
DataObject pObject 
)
override

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

Resolve the references of the created transient object.

Definition at line 104 of file ConversionSvc.cpp.

104  {
105  return makeCall( FILL_OBJ_REFS, false, true, true, pAddress, pObj );
106 }

◆ fillRepRefs()

StatusCode ConversionSvc::fillRepRefs ( IOpaqueAddress pAddress,
DataObject pObject 
)
override

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

Resolve the references of the converted object.

Definition at line 124 of file ConversionSvc.cpp.

124  {
125  return makeCall( FILL_REP_REFS, true, false, false, pAddress, pObj );
126 }

◆ finalize()

StatusCode ConversionSvc::finalize ( )
override

stop the service.

Definition at line 239 of file ConversionSvc.cpp.

239  {
240  // Release all workers.
241  for ( auto& i : m_workers ) {
242  if ( i.converter()->finalize().isFailure() ) { error() << "finalizing worker" << endmsg; }
243  }
244  m_workers.clear();
245  // release interfaces
246  m_addressCreator = nullptr;
247  m_dataSvc = nullptr;
248  m_cnvSvc = nullptr;
249  return Service::finalize();
250 }

◆ initialize()

StatusCode ConversionSvc::initialize ( )
override

Initialize the service.

Definition at line 236 of file ConversionSvc.cpp.

236 { return Service::initialize(); }

◆ initializeConverter()

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

Initialize the new converter.

Initialize new converter.

Definition at line 272 of file ConversionSvc.cpp.

272  {
273  return pConverter ? pConverter->initialize() : Status::NO_CONVERTER;
274 }

◆ loadConverter()

void ConversionSvc::loadConverter ( DataObject pObject)
protectedvirtual

Load converter or dictionary needed by the converter.

Reimplemented in Gaudi::RootCnvSvc.

Definition at line 94 of file ConversionSvc.cpp.

94 {}

◆ makeCall()

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

Definition at line 38 of file ConversionSvc.cpp.

39  {
40  if ( !pAddress && !ignore_add ) return Status::INVALID_ADDRESS;
41  if ( !pObject && !ignore_obj ) return Status::INVALID_OBJECT;
42  const CLID& obj_class =
43  ( pObject && !ignore_obj ) ? pObject->clID() : ( pAddress && !ignore_add ) ? pAddress->clID() : CLID_NULL;
44  IConverter* cnv = converter( obj_class );
45  if ( !cnv && pObject ) {
46  // Give it a try to autoload the class (dictionary) for which the converter is needed
47  loadConverter( pObject );
48  cnv = converter( obj_class );
49  }
50 
52  if ( cnv ) {
53  switch ( typ ) {
54  case CREATE_OBJ:
55  pObject = nullptr;
56  status = cnv->createObj( pAddress, pObject );
57  break;
58  case FILL_OBJ_REFS:
59  status = cnv->fillObjRefs( pAddress, pObject );
60  break;
61  case UPDATE_OBJ:
62  status = cnv->updateObj( pAddress, pObject );
63  break;
64  case UPDATE_OBJ_REFS:
65  status = cnv->updateObjRefs( pAddress, pObject );
66  break;
67  case CREATE_REP:
68  pAddress = nullptr;
69  status = cnv->createRep( pObject, pAddress );
70  break;
71  case FILL_REP_REFS:
72  status = cnv->fillRepRefs( pAddress, pObject );
73  break;
74  case UPDATE_REP:
75  status = cnv->updateRep( pAddress, pObject );
76  break;
77  case UPDATE_REP_REFS:
78  status = cnv->updateRepRefs( pAddress, pObject );
79  break;
80  default:
81  status = StatusCode::FAILURE;
82  break;
83  }
84  if ( status.isSuccess() && update ) { status = updateServiceState( pAddress ); }
85  return status;
86  }
87  status.ignore();
88  info() << "No converter for object ";
89  if ( pObject ) { msgStream() << System::typeinfoName( typeid( *pObject ) ); }
90  msgStream() << " CLID= " << obj_class << endmsg;
91  return Status::NO_CONVERTER;
92 }

◆ objType()

const CLID & ConversionSvc::objType ( ) const
override

Implementation of IConverter: dummy call.

Retrieve the class type of objects the converter produces.

Definition at line 282 of file ConversionSvc.cpp.

282 { return CLID_NULL; }

◆ operator=()

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

◆ removeConverter()

StatusCode ConversionSvc::removeConverter ( const CLID clid)
override

Remove converter object from conversion service (if present).

Definition at line 225 of file ConversionSvc.cpp.

225  {
226 
228  [f = CnvTest( clid )]( const WorkerEntry& we ) { return !f( we ); } );
229  if ( i == std::end( m_workers ) ) return Status::NO_CONVERTER;
230  std::for_each( i, std::end( m_workers ), []( WorkerEntry& w ) { w.converter()->finalize().ignore(); } );
231  m_workers.erase( i, std::end( m_workers ) );
232  return StatusCode::SUCCESS;
233 }

◆ repSvcType()

long ConversionSvc::repSvcType ( ) const
override

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

Definition at line 285 of file ConversionSvc.cpp.

285 { return m_type; }

◆ setAddressCreator()

StatusCode ConversionSvc::setAddressCreator ( IAddressCreator creator)
override

Set address creator facility.

Definition at line 168 of file ConversionSvc.cpp.

168  {
170  for ( auto& i : m_workers ) {
171  auto* cnv = i.converter();
172  if ( cnv ) {
173  if ( cnv->setAddressCreator( m_addressCreator ).isFailure() ) { error() << "setting Address Creator" << endmsg; }
174  }
175  }
176  return StatusCode::SUCCESS;
177 }

◆ setConversionSvc()

StatusCode ConversionSvc::setConversionSvc ( IConversionSvc svc)
override

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

Set conversion service the converter is connected to.

Definition at line 183 of file ConversionSvc.cpp.

183 { return StatusCode::FAILURE; }

◆ setDataProvider()

StatusCode ConversionSvc::setDataProvider ( IDataProviderSvc pService)
override

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 154 of file ConversionSvc.cpp.

154  {
155  if ( !pDataSvc ) return StatusCode::SUCCESS; // Atlas does not use DataSvc
156  m_dataSvc = pDataSvc;
157  for ( auto& i : m_workers ) {
158  IConverter* cnv = i.converter();
159  if ( cnv && cnv->setDataProvider( m_dataSvc ).isFailure() ) { error() << "setting Data Provider" << endmsg; }
160  }
161  return StatusCode::SUCCESS;
162 }

◆ updateObj()

StatusCode ConversionSvc::updateObj ( IOpaqueAddress pAddress,
DataObject refpObject 
)
override

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

Update the transient object from the other representation.

Definition at line 109 of file ConversionSvc.cpp.

109  {
110  return makeCall( UPDATE_OBJ, false, true, false, pAddress, pObj );
111 }

◆ updateObjRefs()

StatusCode ConversionSvc::updateObjRefs ( IOpaqueAddress pAddress,
DataObject pObject 
)
override

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

Update the references of an updated transient object.

Definition at line 114 of file ConversionSvc.cpp.

114  {
115  return makeCall( UPDATE_OBJ_REFS, false, true, true, pAddress, pObj );
116 }

◆ updateRep()

StatusCode ConversionSvc::updateRep ( IOpaqueAddress pAddress,
DataObject pObject 
)
override

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

Update the converted representation of a transient object.

Definition at line 129 of file ConversionSvc.cpp.

129  {
130  return makeCall( UPDATE_REP, true, false, false, pAddress, pObj );
131 }

◆ updateRepRefs()

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

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

Update the references of an already converted object.

Definition at line 134 of file ConversionSvc.cpp.

134  {
135  return makeCall( UPDATE_REP_REFS, true, false, false, pAddress, pObj );
136 }

◆ updateServiceState()

StatusCode ConversionSvc::updateServiceState ( IOpaqueAddress pAddress)
virtual

Update state of the service.

Reimplemented in Gaudi::RootCnvSvc.

Definition at line 96 of file ConversionSvc.cpp.

96 { return StatusCode::SUCCESS; }

Member Data Documentation

◆ m_addressCreator

SmartIF<IAddressCreator> ConversionSvc::m_addressCreator
mutableprotected

Pointer to the address creation service interface.

Definition at line 214 of file ConversionSvc.h.

◆ m_cnvSvc

SmartIF<IConversionSvc> ConversionSvc::m_cnvSvc
mutableprotected

Pointer to the IConversionSvc interface of this.

Definition at line 216 of file ConversionSvc.h.

◆ m_dataSvc

SmartIF<IDataProviderSvc> ConversionSvc::m_dataSvc
mutableprotected

Pointer to data provider service.

Definition at line 212 of file ConversionSvc.h.

◆ m_type

long ConversionSvc::m_type
protected

Conversion service type.

Definition at line 218 of file ConversionSvc.h.

◆ m_workers

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

List of conversion workers.

Definition at line 220 of file ConversionSvc.h.


The documentation for this class was generated from the following files:
UPDATE_REP_REFS
@ UPDATE_REP_REFS
Definition: PersistencySvc.cpp:57
std::for_each
T for_each(T... args)
ConversionSvc::addConverter
StatusCode addConverter(const CLID &clid) override
Add converter object to conversion service.
Definition: ConversionSvc.cpp:189
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
ConversionSvc::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: ConversionSvc.h:214
IConverter::fillRepRefs
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:355
IConverter::updateRepRefs
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
ConversionSvc::configureConverter
virtual StatusCode configureConverter(long typ, const CLID &clid, IConverter *cnv)
Configure the new converter before initialize is called.
Definition: ConversionSvc.cpp:263
ConversionSvc::makeCall
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
Definition: ConversionSvc.cpp:38
CREATE_OBJ
@ CREATE_OBJ
Definition: PersistencySvc.cpp:50
std::find_if
T find_if(T... args)
IConverter
Definition: IConverter.h:68
ConversionSvc::converter
IConverter * converter(const CLID &wanted) override
Retrieve converter from list.
Definition: ConversionSvc.cpp:139
IConverter::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:308
ConversionSvc::activateConverter
virtual StatusCode activateConverter(long typ, const CLID &clid, IConverter *cnv)
Activate the new converter after initialization.
Definition: ConversionSvc.cpp:277
ConversionSvc::loadConverter
virtual void loadConverter(DataObject *pObject)
Load converter or dictionary needed by the converter.
Definition: ConversionSvc.cpp:94
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
extends< Service, IConversionSvc, IAddressCreator >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:24
std::string::clear
T clear(T... args)
FILL_OBJ_REFS
@ FILL_OBJ_REFS
Definition: PersistencySvc.cpp:51
IConverter::setDataProvider
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
ConversionSvc::updateServiceState
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
Definition: ConversionSvc.cpp:96
ConversionSvc::removeConverter
StatusCode removeConverter(const CLID &clid) override
Remove converter object from conversion service (if present).
Definition: ConversionSvc.cpp:225
ConverterID
Definition: Converter.h:144
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:391
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
IConverter::createRep
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
ConversionSvc::connectOutput
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
Definition: ConversionSvc.cpp:288
CREATE_REP
@ CREATE_REP
Definition: PersistencySvc.cpp:54
IConverter::updateObj
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
IOpaqueAddress::clID
virtual const CLID & clID() const =0
Retrieve class information from link.
Write.creator
creator
Definition: Write.py:22
ConversionSvc::m_type
long m_type
Conversion service type.
Definition: ConversionSvc.h:218
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
IConverter::repSvcType
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
UPDATE_REP
@ UPDATE_REP
Definition: PersistencySvc.cpp:56
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:156
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:142
ConversionSvc::m_cnvSvc
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
Definition: ConversionSvc.h:216
gaudirun.type
type
Definition: gaudirun.py:154
UPDATE_OBJ_REFS
@ UPDATE_OBJ_REFS
Definition: PersistencySvc.cpp:53
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConversionSvc::createConverter
virtual IConverter * createConverter(long typ, const CLID &clid, const ICnvFactory *fac)
Create new Converter using factory.
Definition: ConversionSvc.cpp:253
IConverter::updateObjRefs
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
std::begin
T begin(T... args)
IConverter::updateRep
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
ConversionSvc::finalize
StatusCode finalize() override
stop the service.
Definition: ConversionSvc.cpp:239
GaudiPython.Pythonizations.update
update
Definition: Pythonizations.py:131
UPDATE_OBJ
@ UPDATE_OBJ
Definition: PersistencySvc.cpp:52
IConverter::fillObjRefs
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
std::end
T end(T... args)
IConverter::objType
virtual const CLID & objType() const =0
Retrieve the class type of objects the converter produces.
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ConversionSvc::initializeConverter
virtual StatusCode initializeConverter(long typ, const CLID &clid, IConverter *cnv)
Initialize the new converter.
Definition: ConversionSvc.cpp:272
ConversionSvc::setAddressCreator
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: ConversionSvc.cpp:168
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
ConversionSvc::m_dataSvc
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
Definition: ConversionSvc.h:212
DataObject::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:66
std::partition
T partition(T... args)
ConversionSvc::repSvcType
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
Definition: ConversionSvc.cpp:285
FILL_REP_REFS
@ FILL_REP_REFS
Definition: PersistencySvc.cpp:55
ConversionSvc::m_workers
std::vector< WorkerEntry > m_workers
List of conversion workers.
Definition: ConversionSvc.h:220
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
Definition: Service.cpp:335