ATLAS Offline Software
AthCnvSvc.h
Go to the documentation of this file.
1 
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
27 class ISvcLocator;
28 template <class TYPE> class SvcFactory;
29 
30 
63 class AthCnvSvc : public extends<::AthService,
64  ::IConversionSvc,
65  ::IAddressCreator>
66 {
67  friend class SvcFactory<AthCnvSvc>;
68 
69 public:
70  class WorkerEntry {
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  }
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:
110 public:
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  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  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:
260 private:
262  AthCnvSvc(); //< not implemented
263  AthCnvSvc (const AthCnvSvc&); //< not implemented
264  AthCnvSvc& operator= (const AthCnvSvc&); //< not implemented
265 
267  // Protected data and methods:
269 protected:
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
AthCnvSvc::WorkerEntry::WorkerEntry
WorkerEntry(const CLID &cl, IConverter *cnv)
Definition: AthCnvSvc.h:76
AthCnvSvc::makeCall
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
Definition: AthCnvSvc.cxx:524
AthCnvSvc::updateRep
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the converted representation of a transient object.
Definition: AthCnvSvc.cxx:292
AthCnvSvc::addConverter
virtual StatusCode addConverter(const CLID &clid) override
Add converter object to conversion service.
Definition: AthCnvSvc.cxx:307
AthCnvSvc::WorkerEntry::clID
const CLID & clID() const
Definition: AthCnvSvc.h:92
AthCnvSvc::commitOutput
virtual StatusCode commitOutput(const std::string &output, bool do_commit) override
Commit pending output.
Definition: AthCnvSvc.cxx:400
AthCnvSvc::AthCnvSvc
AthCnvSvc(const AthCnvSvc &)
AthCnvSvc::WorkerEntry::~WorkerEntry
virtual ~WorkerEntry()
Definition: AthCnvSvc.h:87
AthCnvSvc::WorkerEntry
Definition: AthCnvSvc.h:70
AthCnvSvc::m_conv_mut
CallMutex m_conv_mut
Definition: AthCnvSvc.h:321
SvcFactory
Definition: AthCnvSvc.h:28
AthCnvSvc::activateConverter
virtual StatusCode activateConverter(long typ, const CLID &clid, IConverter *cnv)
Activate the new converter after initialization.
Definition: AthCnvSvc.cxx:507
AthCnvSvc::updateServiceState
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
Definition: AthCnvSvc.cxx:450
AthCnvSvc::setAddressCreator
virtual StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: AthCnvSvc.cxx:214
AthCnvSvc::updateObjRefs
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the references of an updated transient object.
Definition: AthCnvSvc.cxx:268
AthCnvSvc::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: AthCnvSvc.h:312
AthCnvSvc::WorkerEntry::operator==
bool operator==(const WorkerEntry &rhs)
Definition: AthCnvSvc.h:96
AthCnvSvc::setConversionSvc
virtual StatusCode setConversionSvc(IConversionSvc *svc) override
Implementation of IConverter: Set conversion service the converter is connected to.
Definition: AthCnvSvc.cxx:195
AthCnvSvc::AthCnvSvc
AthCnvSvc()
Default constructor:
AthCnvSvc::removeConverter
virtual StatusCode removeConverter(const CLID &clid) override
Remove converter object from conversion service (if present).
Definition: AthCnvSvc.cxx:350
AthCnvSvc::convertAddress
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress) override
Convert an address to string form.
Definition: AthCnvSvc.cxx:430
compareGeometries.outputFile
string outputFile
Definition: compareGeometries.py:25
AthCnvSvc::configureConverter
virtual StatusCode configureConverter(long typ, const CLID &clid, IConverter *cnv)
Configure the new converter before initialize is called.
Definition: AthCnvSvc.cxx:481
AthCnvSvc::WorkerEntry::converter
IConverter * converter()
Definition: AthCnvSvc.h:89
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthCnvSvc::CallMutex
std::recursive_mutex CallMutex
Mutex to protect Converter creation.
Definition: AthCnvSvc.h:320
AthCnvSvc::WorkerEntry::WorkerEntry
WorkerEntry(const WorkerEntry &copy)
Definition: AthCnvSvc.h:79
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
AthCnvSvc::m_cnvSvc
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
Definition: AthCnvSvc.h:314
AthCnvSvc::fillObjRefs
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the created transient object.
Definition: AthCnvSvc.cxx:252
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
AthCnvSvc::dataProvider
virtual SmartIF< IDataProviderSvc > & dataProvider() const override
Implementation of IConverter: Get Data provider service.
Definition: AthCnvSvc.cxx:183
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
AthCnvSvc::WorkerEntry::m_class
CLID m_class
Definition: AthCnvSvc.h:73
AthCnvSvc::m_workers
Workers m_workers
List of conversion workers.
Definition: AthCnvSvc.h:318
merge.output
output
Definition: merge.py:17
AthCnvSvc::initializeConverter
virtual StatusCode initializeConverter(long typ, const CLID &clid, IConverter *cnv)
Initialize the new converter.
Definition: AthCnvSvc.cxx:496
AthCnvSvc::operator=
AthCnvSvc & operator=(const AthCnvSvc &)
AthCnvSvc::updateRepRefs
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Update the references of an already converted object.
Definition: AthCnvSvc.cxx:300
AthCnvSvc::updateObj
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Implementation of IConverter: Update the transient object from the other representation.
Definition: AthCnvSvc.cxx:260
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
AthCnvSvc::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Implementation of IConverter: Create the transient representation of an object.
Definition: AthCnvSvc.cxx:244
AthCnvSvc::objType
virtual const CLID & objType() const override
Implementation of IConverter: dummy call.
Definition: AthCnvSvc.cxx:150
AthCnvSvc::createConverter
virtual IConverter * createConverter(long typ, const CLID &clid, const ICnvFactory *fac)
Create new Converter using factory.
Definition: AthCnvSvc.cxx:462
AthCnvSvc::addressCreator
virtual SmartIF< IAddressCreator > & addressCreator()
Retrieve address creation interface.
Definition: AthCnvSvc.h:297
AthCnvSvc::~AthCnvSvc
virtual ~AthCnvSvc()
Destructor:
Definition: AthCnvSvc.cxx:59
AthCnvSvc::WorkerEntry::operator<
bool operator<(const WorkerEntry &rhs)
Definition: AthCnvSvc.h:100
AthCnvSvc::finalize
virtual StatusCode finalize() override
Definition: AthCnvSvc.cxx:112
AthCnvSvc::converter
virtual IConverter * converter(const CLID &wanted) override
Retrieve converter from list.
Definition: AthCnvSvc.cxx:365
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthCnvSvc::WorkerEntry::operator=
WorkerEntry & operator=(const WorkerEntry &copy)
Definition: AthCnvSvc.h:82
AthCnvSvc::fillRepRefs
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Implementation of IConverter: Resolve the references of the converted object.
Definition: AthCnvSvc.cxx:284
AthCnvSvc::loadConverter
virtual void loadConverter(DataObject *pObject)
Load converter or dictionary needed by the converter.
Definition: AthCnvSvc.cxx:518
AthCnvSvc::Workers
std::unordered_map< CLID, WorkerEntry > Workers
Definition: AthCnvSvc.h:105
AthService.h
AthCnvSvc::m_dataSvc
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
Definition: AthCnvSvc.h:310
AthCnvSvc::repSvcType
virtual long repSvcType() const override
Retrieve the class type of the data store the converter uses.
Definition: AthCnvSvc.cxx:143
AthCnvSvc::disconnectOutput
virtual StatusCode disconnectOutput(const std::string &output)
Disconnect output files from the service.
Definition: AthCnvSvc.cxx:408
calibdata.copy
bool copy
Definition: calibdata.py:27
AthCnvSvc::conversionSvc
virtual SmartIF< IConversionSvc > & conversionSvc() const override
Implementation of IConverter: Get conversion service the converter is connected to.
Definition: AthCnvSvc.cxx:203
AthCnvSvc::setDataProvider
virtual StatusCode setDataProvider(IDataProviderSvc *pService) override
Implementation of IConverter: Set Data provider service.
Definition: AthCnvSvc.cxx:160
AthCnvSvc::WorkerEntry::m_converter
IConverter * m_converter
Definition: AthCnvSvc.h:74
AthCnvSvc::addressCreator
virtual SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: AthCnvSvc.cxx:232
AthCnvSvc::initialize
virtual StatusCode initialize() override
Gaudi Service Implementation.
Definition: AthCnvSvc.cxx:104
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
AthCnvSvc::connectOutput
virtual StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
Definition: AthCnvSvc.cxx:385
AthCnvSvc
Definition: AthCnvSvc.h:66
AthCnvSvc::createRep
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
Definition: AthCnvSvc.cxx:276
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67
AthCnvSvc::m_type
long m_type
Conversion service type.
Definition: AthCnvSvc.h:316
AthCnvSvc::createAddress
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.
Definition: AthCnvSvc.cxx:418