The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
ConversionSvc Class Reference

Base class for all conversion services. More...

#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.
 
 ConversionSvc (const ConversionSvc &)=delete
 disable copy and assignment
 
ConversionSvcoperator= (const ConversionSvc &)=delete
 
StatusCode initialize () override
 Initialize the service.
 
StatusCode finalize () override
 stop the service.
 
long repSvcType () const override
 Retrieve the class type of the data store the converter uses.
 
const CLIDobjType () const override
 Implementation of IConverter: dummy call.
 
StatusCode setDataProvider (IDataProviderSvc *pService) override
 Implementation of IConverter: Set Data provider service.
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Implementation of IConverter: Get Data provider service.
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Implementation of IConverter: Set conversion service the converter is connected to.
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Implementation of IConverter: Get conversion service the converter is connected to.
 
StatusCode setAddressCreator (IAddressCreator *creator) override
 Set address creator facility.
 
SmartIF< IAddressCreator > & addressCreator () const override
 Retrieve address creator facility.
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Implementation of IConverter: Create the transient representation of an object.
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the created transient object.
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Implementation of IConverter: Update the transient object from the other representation.
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an updated transient object.
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Implementation of IConverter: Convert the transient object to the requested representation.
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Resolve the references of the converted object.
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the converted representation of a transient object.
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Implementation of IConverter: Update the references of an already converted object.
 
StatusCode addConverter (const CLID &clid) override
 Add converter object to conversion service.
 
StatusCode addConverter (IConverter *pConverter) override
 Add converter object to conversion service.
 
StatusCode removeConverter (const CLID &clid) override
 Remove converter object from conversion service (if present).
 
IConverterconverter (const CLID &wanted) override
 Retrieve converter from list.
 
StatusCode connectOutput (const std::string &outputFile, const std::string &openMode) override
 Connect the output file to the service with open mode.
 
StatusCode connectOutput (const std::string &output) override
 Connect the output file to the service.
 
StatusCode commitOutput (const std::string &output, bool do_commit) override
 Commit pending output.
 
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.
 
StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress) override
 Convert an address to string form.
 
StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) override
 Convert an address in string form to object form.
 
virtual StatusCode updateServiceState (IOpaqueAddress *pAddress)
 Update state of the service.
 
- Public Member Functions inherited from extends< Service, IConversionSvc, IAddressCreator >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
 
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.
 
StatusCode sysStart () override
 Initialize Service.
 
StatusCode sysStop () override
 Initialize Service.
 
StatusCode sysFinalize () override
 Finalize Service.
 
StatusCode sysReinitialize () override
 Re-initialize the Service.
 
StatusCode sysRestart () override
 Re-initialize the Service.
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
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, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool.
 
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.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
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.
 
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.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
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)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Protected Member Functions

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 SmartIF< IAddressCreator > & addressCreator ()
 Retrieve address creation interface.
 
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
 
int outputLevel () const
 get the Service's output level
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 

Protected Attributes

SmartIF< IDataProviderSvcm_dataSvc
 Pointer to data provider service.
 
SmartIF< IAddressCreatorm_addressCreator
 Pointer to the address creation service interface.
 
SmartIF< IConversionSvcm_cnvSvc
 Pointer to the IConversionSvc interface of this.
 
long m_type
 Conversion service type.
 
std::vector< WorkerEntrym_workers
 List of conversion workers.
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
 
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
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service.
 

Additional Inherited Members

- Public Types inherited from extends< Service, IConversionSvc, IAddressCreator >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- 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
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 

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 53 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_dataSvc( nullptr ), m_cnvSvc( this ), m_type( type ) {
322 setAddressCreator( this ).ignore();
323}
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
long m_type
Conversion service type.
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
const std::string & name() const override
Retrieve name of the service.
Definition Service.cpp:333
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139

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

278 {
279 return pConverter ? StatusCode::SUCCESS : StatusCode( Status::NO_CONVERTER );
280}
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ addConverter() [1/2]

StatusCode ConversionSvc::addConverter ( const CLID & clid)
override

Add converter object to conversion service.

Definition at line 190 of file ConversionSvc.cpp.

190 {
191 // First look for the more specific converter
192 long typ = repSvcType();
193 IConverter* pConverter = createConverter( typ, clid, nullptr );
194 if ( pConverter ) {
195 StatusCode status = configureConverter( typ, clid, pConverter );
196 if ( status.isSuccess() ) {
197 status = initializeConverter( typ, clid, pConverter );
198 if ( status.isSuccess() ) {
199 status = activateConverter( typ, clid, pConverter );
200 if ( status.isSuccess() ) {
201 long conv_typ = pConverter->repSvcType();
202 const CLID& conv_clid = pConverter->objType();
203 typ = ( typ < 0xFF ) ? typ : typ & 0xFFFFFF00;
204 conv_typ = ( conv_typ < 0xFF ) ? conv_typ : conv_typ & 0xFFFFFF00;
205 if ( conv_typ == typ && conv_clid == clid ) { return addConverter( pConverter ); }
206 }
207 }
208 }
209 pConverter->release();
210 }
211 return Status::NO_CONVERTER;
212}
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
virtual IConverter * createConverter(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.
StatusCode addConverter(const CLID &clid) override
Add converter object to conversion service.
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
virtual const CLID & objType() const =0
Retrieve the class type of objects the converter produces.
virtual unsigned long release() const =0
Release Interface instance.
bool isSuccess() const
Definition StatusCode.h:314

◆ addConverter() [2/2]

StatusCode ConversionSvc::addConverter ( IConverter * pConverter)
override

Add converter object to conversion service.

Definition at line 215 of file ConversionSvc.cpp.

215 {
216 if ( pConverter ) {
217 const CLID& clid = pConverter->objType();
218 removeConverter( clid ).ignore();
219 m_workers.emplace_back( clid, pConverter );
220 return StatusCode::SUCCESS;
221 }
222 return Status::NO_CONVERTER;
223}
StatusCode removeConverter(const CLID &clid) override
Remove converter object from conversion service (if present).
std::vector< WorkerEntry > m_workers
List of conversion workers.

◆ addressCreator() [1/2]

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

Retrieve address creation interface.

Definition at line 203 of file ConversionSvc.h.

203{ return m_addressCreator; }
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.

◆ addressCreator() [2/2]

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

Retrieve address creator facility.

Access the transient store.

Definition at line 181 of file ConversionSvc.cpp.

181{ return m_addressCreator; }

◆ commitOutput()

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

Commit pending output.

Definition at line 297 of file ConversionSvc.cpp.

297{ 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 264 of file ConversionSvc.cpp.

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

◆ connectOutput() [1/2]

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

Connect the output file to the service.

Definition at line 294 of file ConversionSvc.cpp.

294{ 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 289 of file ConversionSvc.cpp.

289 {
290 return connectOutput( outputFile );
291}
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.

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

187{ 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}
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ converter()

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

Retrieve converter from list.

Definition at line 140 of file ConversionSvc.cpp.

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

◆ 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 300 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 254 of file ConversionSvc.cpp.

254 {
255 IConverter* pConverter = Converter::Factory::create( ConverterID( typ, clid ), serviceLocator().get() ).release();
256 if ( !pConverter ) {
257 typ = ( typ < 0xFF ) ? typ : typ & 0xFFFFFF00;
258 pConverter = Converter::Factory::create( ConverterID( typ, clid ), serviceLocator().get() ).release();
259 }
260 return pConverter;
261}
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition Service.cpp:336
get
decorate the vector of properties
Definition decorators.py:94

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

100 {
101 return makeCall( CREATE_OBJ, false, true, false, pAddress, refpObj );
102}
@ CREATE_OBJ
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)

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

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

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

166{ 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 105 of file ConversionSvc.cpp.

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

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

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

◆ finalize()

StatusCode ConversionSvc::finalize ( )
override

stop the service.

Definition at line 240 of file ConversionSvc.cpp.

240 {
241 // Release all workers.
242 for ( auto& i : m_workers ) {
243 if ( i.converter()->finalize().isFailure() ) { error() << "finalizing worker" << endmsg; }
244 }
245 m_workers.clear();
246 // release interfaces
247 m_addressCreator = nullptr;
248 m_dataSvc = nullptr;
249 m_cnvSvc = nullptr;
250 return Service::finalize();
251}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
StatusCode finalize() override
Definition Service.cpp:223

◆ initialize()

StatusCode ConversionSvc::initialize ( )
override

Initialize the service.

Definition at line 237 of file ConversionSvc.cpp.

237{ return Service::initialize(); }
StatusCode initialize() override
Definition Service.cpp:118

◆ initializeConverter()

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

Initialize the new converter.

Initialize new converter.

Definition at line 273 of file ConversionSvc.cpp.

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

◆ loadConverter()

void ConversionSvc::loadConverter ( DataObject * pObject)
protectedvirtual

Load converter or dictionary needed by the converter.

Reimplemented in Gaudi::RootCnvSvc.

Definition at line 95 of file ConversionSvc.cpp.

95{}

◆ 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 = ( pObject && !ignore_obj ) ? pObject->clID()
43 : ( pAddress && !ignore_add ) ? pAddress->clID()
44 : CLID_NULL;
45 IConverter* cnv = converter( obj_class );
46 if ( !cnv && pObject ) {
47 // Give it a try to autoload the class (dictionary) for which the converter is needed
48 loadConverter( pObject );
49 cnv = converter( obj_class );
50 }
51
52 StatusCode status{ StatusCode::FAILURE };
53 if ( cnv ) {
54 switch ( typ ) {
55 case CREATE_OBJ:
56 pObject = nullptr;
57 status = cnv->createObj( pAddress, pObject );
58 break;
59 case FILL_OBJ_REFS:
60 status = cnv->fillObjRefs( pAddress, pObject );
61 break;
62 case UPDATE_OBJ:
63 status = cnv->updateObj( pAddress, pObject );
64 break;
65 case UPDATE_OBJ_REFS:
66 status = cnv->updateObjRefs( pAddress, pObject );
67 break;
68 case CREATE_REP:
69 pAddress = nullptr;
70 status = cnv->createRep( pObject, pAddress );
71 break;
72 case FILL_REP_REFS:
73 status = cnv->fillRepRefs( pAddress, pObject );
74 break;
75 case UPDATE_REP:
76 status = cnv->updateRep( pAddress, pObject );
77 break;
78 case UPDATE_REP_REFS:
79 status = cnv->updateRepRefs( pAddress, pObject );
80 break;
81 default:
82 status = StatusCode::FAILURE;
83 break;
84 }
85 if ( status.isSuccess() && update ) { status = updateServiceState( pAddress ); }
86 return status;
87 }
88 status.ignore();
89 info() << "No converter for object ";
90 if ( pObject ) { msgStream() << System::typeinfoName( typeid( *pObject ) ); }
91 msgStream() << " CLID= " << obj_class << endmsg;
92 return Status::NO_CONVERTER;
93}
@ UPDATE_OBJ
@ UPDATE_REP
@ UPDATE_REP_REFS
@ UPDATE_OBJ_REFS
MsgStream & msgStream() const
Return an uninitialized MsgStream.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
virtual void loadConverter(DataObject *pObject)
Load converter or dictionary needed by the converter.
IConverter * converter(const CLID &wanted) override
Retrieve converter from list.
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the created transient object.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)=0
Create the transient representation of an object.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
virtual const CLID & clID() const =0
Retrieve class information from link.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition System.cpp:260

◆ objType()

const CLID & ConversionSvc::objType ( ) const
override

Implementation of IConverter: dummy call.

Retrieve the class type of objects the converter produces.

Definition at line 283 of file ConversionSvc.cpp.

283{ 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 226 of file ConversionSvc.cpp.

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

◆ repSvcType()

long ConversionSvc::repSvcType ( ) const
override

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

Definition at line 286 of file ConversionSvc.cpp.

286{ return m_type; }

◆ setAddressCreator()

StatusCode ConversionSvc::setAddressCreator ( IAddressCreator * creator)
override

Set address creator facility.

Definition at line 169 of file ConversionSvc.cpp.

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

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

184{ 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 155 of file ConversionSvc.cpp.

155 {
156 if ( !pDataSvc ) return StatusCode::SUCCESS; // Atlas does not use DataSvc
157 m_dataSvc = pDataSvc;
158 for ( auto& i : m_workers ) {
159 IConverter* cnv = i.converter();
160 if ( cnv && cnv->setDataProvider( m_dataSvc ).isFailure() ) { error() << "setting Data Provider" << endmsg; }
161 }
162 return StatusCode::SUCCESS;
163}
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
bool isFailure() const
Definition StatusCode.h:129

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

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

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

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

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

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

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

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

◆ updateServiceState()

StatusCode ConversionSvc::updateServiceState ( IOpaqueAddress * pAddress)
virtual

Update state of the service.

Reimplemented in Gaudi::RootCnvSvc.

Definition at line 97 of file ConversionSvc.cpp.

97{ return StatusCode::SUCCESS; }

Member Data Documentation

◆ m_addressCreator

SmartIF<IAddressCreator> ConversionSvc::m_addressCreator
mutableprotected

Pointer to the address creation service interface.

Definition at line 212 of file ConversionSvc.h.

◆ m_cnvSvc

SmartIF<IConversionSvc> ConversionSvc::m_cnvSvc
mutableprotected

Pointer to the IConversionSvc interface of this.

Definition at line 214 of file ConversionSvc.h.

◆ m_dataSvc

SmartIF<IDataProviderSvc> ConversionSvc::m_dataSvc
mutableprotected

Pointer to data provider service.

Definition at line 210 of file ConversionSvc.h.

◆ m_type

long ConversionSvc::m_type
protected

Conversion service type.

Definition at line 216 of file ConversionSvc.h.

◆ m_workers

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

List of conversion workers.

Definition at line 218 of file ConversionSvc.h.


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