11#define GAUDIKERNEL_CONVERSIONSVC_CPP
24 auto CnvTest = [](
CLID clid ) {
return [clid](
const auto& i ) {
return i.clID() == clid; }; };
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()
46 if ( !cnv && pObject ) {
57 status = cnv->
createObj( pAddress, pObject );
63 status = cnv->
updateObj( pAddress, pObject );
70 status = cnv->
createRep( pObject, pAddress );
76 status = cnv->
updateRep( pAddress, pObject );
89 info() <<
"No converter for object ";
92 return Status::NO_CONVERTER;
143 if ( i !=
m_workers.end() ) cnv = i->converter();
148 if ( i !=
m_workers.end() ) cnv = i->converter();
172 auto* cnv = i.converter();
205 typ = ( typ < 0xFF ) ? typ : typ & 0xFFFFFF00;
206 conv_typ = ( conv_typ < 0xFF ) ? conv_typ : conv_typ & 0xFFFFFF00;
207 if ( conv_typ == typ && conv_clid == clid ) {
return addConverter( pConverter ); }
213 return Status::NO_CONVERTER;
221 m_workers.emplace_back( clid, pConverter );
224 return Status::NO_CONVERTER;
231 [f = CnvTest( clid )](
const WorkerEntry& we ) {
return !f( we ); } );
232 if ( i == std::end(
m_workers ) )
return Status::NO_CONVERTER;
245 if ( i.converter()->finalize().isFailure() ) {
error() <<
"finalizing worker" <<
endmsg; }
258 typ = ( typ < 0xFF ) ? typ : typ & 0xFFFFFF00;
266 if ( !pConverter )
return Status::NO_CONVERTER;
275 return pConverter ? pConverter->
initialize() : Status::NO_CONVERTER;
303 refpAddress =
nullptr;
316 refpAddress =
nullptr;
unsigned int CLID
Class ID definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & msgStream() const
Return an uninitialized MsgStream.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
SmartIF< IConversionSvc > conversionSvc() override
Implementation of IConverter: Get conversion service the converter is connected to.
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
virtual IConverter * createConverter(long typ, const CLID &clid, const ICnvFactory *fac)
Create new Converter using factory.
StatusCode removeConverter(const CLID &clid) override
Remove converter object from conversion service (if present).
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the converted object.
StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress) override
Convert an address to string form.
virtual void loadConverter(DataObject *pObject)
Load converter or dictionary needed by the converter.
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 finalize() override
stop the service.
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
virtual StatusCode configureConverter(long typ, const CLID &clid, IConverter *cnv)
Configure the new converter before initialize is called.
StatusCode setConversionSvc(IConversionSvc *svc) override
Implementation of IConverter: Set conversion service the converter is connected to.
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
virtual StatusCode initializeConverter(long typ, const CLID &clid, IConverter *cnv)
Initialize the new converter.
long m_type
Conversion service type.
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
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 setDataProvider(IDataProviderSvc *pService) override
Implementation of IConverter: Set Data provider service.
virtual StatusCode activateConverter(long typ, const CLID &clid, IConverter *cnv)
Activate the new converter after initialization.
IConverter * converter(const CLID &wanted) override
Retrieve converter from list.
StatusCode initialize() override
Initialize the service.
SmartIF< IDataProviderSvc > & dataProvider() const override
Implementation of IConverter: Get Data provider service.
const CLID & objType() const override
Implementation of IConverter: dummy call.
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
StatusCode commitOutput(const std::string &output, bool do_commit) override
Commit pending output.
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 createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
ConversionSvc(const std::string &name, ISvcLocator *svc, long type)
Standard Constructor.
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.
StatusCode addConverter(const CLID &clid) override
Add converter object to conversion service.
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the created transient object.
std::vector< WorkerEntry > m_workers
List of conversion workers.
A DataObject is the base class of any identifiable object on any data store.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
IAddressCreator interface definition.
The data converters are responsible to translate data from one representation into another.
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 finalize()=0
Terminate the converter.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
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 setConversionSvc(IConversionSvc *pService)=0
Set conversion service the converter is connected to.
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
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 initialize()=0
Initialize the converter.
virtual const CLID & objType() const =0
Retrieve the class type of objects the converter produces.
virtual StatusCode setAddressCreator(IAddressCreator *creator)=0
Set address creator facility.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
Data provider interface definition.
virtual unsigned long release() const =0
Release Interface instance.
Opaque address interface definition.
virtual const CLID & clID() const =0
Retrieve class information from link.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode finalize() override
const std::string & name() const override
Retrieve name of the service.
StatusCode initialize() override
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
void ignore() const
Allow discarding a StatusCode without warning.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.