The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
ConversionSvc.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
16#include <GaudiKernel/Kernel.h>
17#include <GaudiKernel/Service.h>
18#include <algorithm>
19#include <utility>
20#include <vector>
21
53class GAUDI_API ConversionSvc : public extends<Service, IConversionSvc, IAddressCreator> {
54 class WorkerEntry final {
57
58 public:
59 WorkerEntry( const CLID& cl, IConverter* cnv ) : m_class( cl ), m_converter( cnv ) {
60 if ( m_converter ) m_converter->addRef();
61 }
62
64 if ( m_converter ) m_converter->release();
65 }
66
67 WorkerEntry( WorkerEntry&& orig ) noexcept
68 : m_class{ orig.m_class }, m_converter{ std::exchange( orig.m_converter, nullptr ) } {}
69
70 WorkerEntry& operator=( WorkerEntry&& orig ) noexcept {
71 m_class = orig.m_class;
72 std::swap( m_converter, orig.m_converter );
73 return *this;
74 }
75
76 WorkerEntry( const WorkerEntry& copy ) = delete;
77 WorkerEntry& operator=( const WorkerEntry& copy ) = delete;
78
80
81 const CLID& clID() const { return m_class; }
82 };
83
84public:
86 ConversionSvc( const std::string& name, ISvcLocator* svc, long type );
87
89 ConversionSvc( const ConversionSvc& ) = delete;
91
93 StatusCode initialize() override;
94
96 StatusCode finalize() override;
97
99 long repSvcType() const override;
100
102 const CLID& objType() const override;
103
108 StatusCode setDataProvider( IDataProviderSvc* pService ) override;
109
113 SmartIF<IDataProviderSvc>& dataProvider() const override;
114
117
119 SmartIF<IConversionSvc>& conversionSvc() const override;
120
122 StatusCode setAddressCreator( IAddressCreator* creator ) override;
123
126
128 StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
129
131 StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
132
134 StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
135
137 StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
138
140 StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
141
143 StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
144
146 StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
147
149 StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
150
152 StatusCode addConverter( const CLID& clid ) override;
153
155 StatusCode addConverter( IConverter* pConverter ) override;
156
158 StatusCode removeConverter( const CLID& clid ) override;
159
161 IConverter* converter( const CLID& wanted ) override;
162
164 StatusCode connectOutput( const std::string& outputFile, const std::string& openMode ) override;
165
167 StatusCode connectOutput( const std::string& output ) override;
168
170 StatusCode commitOutput( const std::string& output, bool do_commit ) override;
171
173 StatusCode createAddress( long svc_type, const CLID& clid, const std::string* par, const unsigned long* ip,
174 IOpaqueAddress*& refpAddress ) override;
175
177 StatusCode convertAddress( const IOpaqueAddress* pAddress, std::string& refAddress ) override;
178
180 StatusCode createAddress( long svc_type, const CLID& clid, const std::string& refAddress,
181 IOpaqueAddress*& refpAddress ) override;
182
184 virtual StatusCode updateServiceState( IOpaqueAddress* pAddress );
185
186protected:
188 virtual IConverter* createConverter( long typ, const CLID& clid, const ICnvFactory* fac );
189
191 virtual StatusCode configureConverter( long typ, const CLID& clid, IConverter* cnv );
192
194 virtual StatusCode initializeConverter( long typ, const CLID& clid, IConverter* cnv );
195
197 virtual StatusCode activateConverter( long typ, const CLID& clid, IConverter* cnv );
198
200 virtual void loadConverter( DataObject* pObject );
201
204
205protected:
206 StatusCode makeCall( int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress*& pAddress,
207 DataObject*& pObject );
208
216 long m_type;
218 std::vector<WorkerEntry> m_workers;
219};
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
#define GAUDI_API
Definition Kernel.h:49
IConverter * m_converter
CLID m_class
WorkerEntry(WorkerEntry &&orig) noexcept
WorkerEntry(const CLID &cl, IConverter *cnv)
~WorkerEntry()
WorkerEntry(const WorkerEntry &copy)=delete
WorkerEntry & operator=(const WorkerEntry &copy)=delete
WorkerEntry & operator=(WorkerEntry &&orig) noexcept
IConverter * converter()
const CLID & clID() const
Base class for all conversion services.
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.
SmartIF< IConversionSvc > & conversionSvc() const override
Implementation of IConverter: Get conversion service the converter is connected to.
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.
ConversionSvc(const ConversionSvc &)=delete
disable copy and assignment
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.
virtual SmartIF< IAddressCreator > & addressCreator()
Retrieve address creation interface.
StatusCode initialize() override
Initialize the service.
SmartIF< IDataProviderSvc > & dataProvider() const override
Implementation of IConverter: Get Data provider service.
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
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 & operator=(const ConversionSvc &)=delete
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.
Definition DataObject.h:37
IAddressCreator interface definition.
The data converters are responsible to translate data from one representation into another.
Definition IConverter.h:65
Data provider interface definition.
Opaque address interface definition.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
Base class used to extend a class implementing other interfaces.
Definition extends.h:19
void swap(GaudiUtils::VectorMap< KEY, VALUE, KEYCOMPARE, ALLOCATOR > &left, GaudiUtils::VectorMap< KEY, VALUE, KEYCOMPARE, ALLOCATOR > &right)
the definition of specialized algorithm for swapping
Definition VectorMap.h:726