ATLAS Offline Software
Loading...
Searching...
No Matches
AthCnvSvc.h
Go to the documentation of this file.
2
3/*
4 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
5*/
6
7// AthCnvSvc.h
8// Header file for class AthCnvSvc
9// Author: S.Binet<binet@cern.ch>
11#ifndef ATHENABASECOMPS_ATHCNVSVC_H
12#define ATHENABASECOMPS_ATHCNVSVC_H 1
13
14// STL includes
15#include <string>
16#include <unordered_map>
17#include <mutex>
18
19// GaudiKernel
20#include "GaudiKernel/IConversionSvc.h"
21#include "GaudiKernel/IAddressCreator.h"
22
23// AthenaBaseComps
25
26// Forward declaration
27class ISvcLocator;
28template <class TYPE> class SvcFactory;
29
30
62
63class AthCnvSvc : public extends<::AthService,
64 ::IConversionSvc,
65 ::IAddressCreator>
66{
67 friend class SvcFactory<AthCnvSvc>;
68
69public:
71 friend class AthCnvSvc;
72 private:
74 IConverter* m_converter;
75 public:
76 WorkerEntry(const CLID& cl, IConverter* cnv)
77 : m_class(cl), m_converter(cnv) {
78 }
80 : m_class(copy.m_class), m_converter(copy.m_converter) {
81 }
83 m_class = copy.m_class;
84 m_converter = copy.m_converter;
85 return *this;
86 }
87 virtual ~WorkerEntry() {
88 }
89 IConverter* converter() {
90 return m_converter;
91 }
92 const CLID& clID() const {
93 return m_class;
94 }
95 // comparison operators
96 bool operator == (const WorkerEntry& rhs)
97 {
98 return rhs.clID() == clID();
99 }
100 bool operator < (const WorkerEntry& rhs)
101 {
102 return this->clID() < rhs.clID();
103 }
104 };
105 typedef std::unordered_map<CLID,WorkerEntry> Workers;
106
108 // Public methods:
110public:
111
112 // Copy constructor:
113
115 AthCnvSvc( const std::string& name, ISvcLocator* pSvcLocator, long type );
116
117 // Assignment operator:
118 //AthCnvSvc &operator=(const AthCnvSvc &alg);
119
121
122 virtual StatusCode initialize() override;
123 virtual StatusCode finalize() override;
125
127
128
129 virtual long repSvcType() const override;
130
132 virtual const CLID& objType() const override;
133
138 virtual
139 StatusCode setDataProvider(IDataProviderSvc* pService) override;
140
144 virtual SmartIF<IDataProviderSvc>& dataProvider() const override;
145
147 virtual
148 StatusCode setConversionSvc(IConversionSvc* svc) override;
149
151 virtual
152 SmartIF<IConversionSvc>& conversionSvc() const override;
153
155 virtual
156 StatusCode setAddressCreator(IAddressCreator* creator) override;
157
159 virtual
160 SmartIF<IAddressCreator>& addressCreator() const override;
161
163 virtual
164 StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject) override;
165
167 virtual
168 StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
169
171 virtual
172 StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject) override;
173
175 virtual
176 StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
177
179 virtual
180 StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress) override;
181
183 virtual
184 StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject) override;
185
187 virtual
188 StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject) override;
189
191 virtual
192 StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
193
195 virtual
196 StatusCode addConverter(const CLID& clid) override;
197
199 virtual
200 StatusCode addConverter(IConverter* pConverter) override;
201
203 virtual
204 StatusCode removeConverter(const CLID& clid) override;
205
207 virtual
208 IConverter* converter(const CLID& wanted) override;
209
211 virtual
212 StatusCode connectOutput(const std::string& outputFile,
213 const std::string& openMode) override;
214
216 virtual
217 StatusCode connectOutput(const std::string& output) override;
218
220 virtual
221 StatusCode commitOutput(const std::string& output, bool do_commit) override;
222
224
226 virtual
227 StatusCode disconnectOutput(const std::string& output);
228
230
231
232 virtual
233 StatusCode createAddress (long svc_type,
234 const CLID& clid,
235 const std::string* par,
236 const unsigned long* ip,
237 IOpaqueAddress*& refpAddress) override;
238
240 virtual
241 StatusCode convertAddress (const IOpaqueAddress* pAddress,
242 std::string& refAddress) override;
243
245 virtual
246 StatusCode createAddress (long svc_type,
247 const CLID& clid,
248 const std::string& refAddress,
249 IOpaqueAddress*& refpAddress) override;
250
252 virtual
253 StatusCode updateServiceState(IOpaqueAddress* pAddress);
254
256
258 // Private data:
260private:
262 AthCnvSvc(); //< not implemented
263 AthCnvSvc (const AthCnvSvc&); //< not implemented
264 AthCnvSvc& operator= (const AthCnvSvc&); //< not implemented
265
267 // Protected data and methods:
269protected:
270
272 virtual ~AthCnvSvc();
273
275 virtual
276 IConverter* createConverter (long typ, const CLID& clid,
277 const ICnvFactory* fac);
278
280 virtual
281 StatusCode configureConverter (long typ, const CLID& clid, IConverter* cnv);
282
284 virtual
285 StatusCode initializeConverter (long typ, const CLID& clid, IConverter* cnv);
286
288 virtual
289 StatusCode activateConverter (long typ, const CLID& clid, IConverter* cnv);
290
292 virtual
293 void loadConverter(DataObject* pObject);
294
296 virtual
297 SmartIF<IAddressCreator>& addressCreator()
298 {
299 return m_addressCreator;
300 }
301
302 StatusCode makeCall (int typ,
303 bool ignore_add,
304 bool ignore_obj,
305 bool update,
306 IOpaqueAddress*& pAddress,
307 DataObject*& pObject);
308
310 SmartIF<IDataProviderSvc> m_dataSvc;
312 SmartIF<IAddressCreator> m_addressCreator;
314 SmartIF<IConversionSvc> m_cnvSvc;
316 long m_type;
320 typedef std::recursive_mutex CallMutex;
322};
323
324// I/O operators
326
328// Inline methods:
330
331#endif //> !ATHENABASECOMPS_ATHCNVSVC_H
uint32_t CLID
The Class ID type.
bool operator<(const WorkerEntry &rhs)
Definition AthCnvSvc.h:100
bool operator==(const WorkerEntry &rhs)
Definition AthCnvSvc.h:96
WorkerEntry(const CLID &cl, IConverter *cnv)
Definition AthCnvSvc.h:76
IConverter * m_converter
Definition AthCnvSvc.h:74
WorkerEntry & operator=(const WorkerEntry &copy)
Definition AthCnvSvc.h:82
const CLID & clID() const
Definition AthCnvSvc.h:92
IConverter * converter()
Definition AthCnvSvc.h:89
WorkerEntry(const WorkerEntry &copy)
Definition AthCnvSvc.h:79
friend class AthCnvSvc
Definition AthCnvSvc.h:71
virtual SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
virtual StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
virtual StatusCode activateConverter(long typ, const CLID &clid, IConverter *cnv)
Activate the new converter after initialization.
virtual 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.
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the references of an already converted object.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the references of an updated transient object.
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
Definition AthCnvSvc.h:310
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Implementation of IConverter: Update the transient object from the other representation.
virtual void loadConverter(DataObject *pObject)
Load converter or dictionary needed by the converter.
virtual StatusCode finalize() override
virtual SmartIF< IConversionSvc > & conversionSvc() const override
Implementation of IConverter: Get conversion service the converter is connected to.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
virtual StatusCode setDataProvider(IDataProviderSvc *pService) override
Implementation of IConverter: Set Data provider service.
virtual ~AthCnvSvc()
Destructor:
Definition AthCnvSvc.cxx:59
virtual long repSvcType() const override
Retrieve the class type of the data store the converter uses.
AthCnvSvc(const std::string &name, ISvcLocator *pSvcLocator, long type)
Constructor with parameters:
Definition AthCnvSvc.cxx:46
virtual StatusCode addConverter(const CLID &clid) override
Add converter object to conversion service.
virtual StatusCode removeConverter(const CLID &clid) override
Remove converter object from conversion service (if present).
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress) override
Convert an address to string form.
Workers m_workers
List of conversion workers.
Definition AthCnvSvc.h:318
virtual const CLID & objType() const override
Implementation of IConverter: dummy call.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the converted representation of a transient object.
virtual 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.
virtual StatusCode initializeConverter(long typ, const CLID &clid, IConverter *cnv)
Initialize the new converter.
std::unordered_map< CLID, WorkerEntry > Workers
Definition AthCnvSvc.h:105
AthCnvSvc()
Default constructor:
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.
virtual StatusCode disconnectOutput(const std::string &output)
Disconnect output files from the service.
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition AthCnvSvc.h:312
long m_type
Conversion service type.
Definition AthCnvSvc.h:316
CallMutex m_conv_mut
Definition AthCnvSvc.h:321
virtual StatusCode initialize() override
Gaudi Service Implementation.
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the created transient object.
virtual IConverter * converter(const CLID &wanted) override
Retrieve converter from list.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the converted object.
virtual StatusCode commitOutput(const std::string &output, bool do_commit) override
Commit pending output.
virtual SmartIF< IDataProviderSvc > & dataProvider() const override
Implementation of IConverter: Get Data provider service.
virtual StatusCode configureConverter(long typ, const CLID &clid, IConverter *cnv)
Configure the new converter before initialize is called.
std::recursive_mutex CallMutex
Mutex to protect Converter creation.
Definition AthCnvSvc.h:320
virtual SmartIF< IAddressCreator > & addressCreator()
Retrieve address creation interface.
Definition AthCnvSvc.h:297
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
Definition AthCnvSvc.h:314
AthCnvSvc & operator=(const AthCnvSvc &)
AthCnvSvc(const AthCnvSvc &)
virtual StatusCode setConversionSvc(IConversionSvc *svc) override
Implementation of IConverter: Set conversion service the converter is connected to.