ATLAS Offline Software
AthCnvSvc.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2019 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
64  : virtual public ::IConversionSvc,
65  virtual public ::IAddressCreator,
66  public ::AthService
67 {
68  friend class SvcFactory<AthCnvSvc>;
69 
70 public:
71  class WorkerEntry {
72  friend class AthCnvSvc;
73  private:
75  IConverter* m_converter;
76  public:
77  WorkerEntry(const CLID& cl, IConverter* cnv)
78  : m_class(cl), m_converter(cnv) {
79  }
82  }
84  m_class = copy.m_class;
85  m_converter = copy.m_converter;
86  return *this;
87  }
88  virtual ~WorkerEntry() {
89  }
90  IConverter* converter() {
91  return m_converter;
92  }
93  const CLID& clID() const {
94  return m_class;
95  }
96  // comparison operators
97  bool operator == (const WorkerEntry& rhs)
98  {
99  return rhs.clID() == clID();
100  }
101  bool operator < (const WorkerEntry& rhs)
102  {
103  return this->clID() < rhs.clID();
104  }
105  };
106  typedef std::unordered_map<CLID,WorkerEntry> Workers;
107 
109  // Public methods:
111 public:
112 
113  // Copy constructor:
114 
116  AthCnvSvc( const std::string& name, ISvcLocator* pSvcLocator, long type );
117 
118  // Assignment operator:
119  //AthCnvSvc &operator=(const AthCnvSvc &alg);
120 
122 
123  virtual StatusCode initialize();
124  virtual StatusCode finalize();
125  virtual StatusCode queryInterface (const InterfaceID& riid,
126  void** ppvInterface);
128 
130 
131  virtual long repSvcType() const;
133 
135  const CLID& objType() const;
136 
141  virtual
142  StatusCode setDataProvider(IDataProviderSvc* pService);
143 
147  virtual SmartIF<IDataProviderSvc>& dataProvider() const;
148 
150  virtual
151  StatusCode setConversionSvc(IConversionSvc* svc);
152 
154  virtual
155  SmartIF<IConversionSvc>& conversionSvc() const;
156 
158  virtual
159  StatusCode setAddressCreator(IAddressCreator* creator);
160 
162  virtual
163  SmartIF<IAddressCreator>& addressCreator() const;
164 
166  virtual
167  StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject);
168 
170  virtual
171  StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
172 
174  virtual
175  StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject);
176 
178  virtual
179  StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
180 
182  virtual
183  StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress);
184 
186  virtual
187  StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject);
188 
190  virtual
191  StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject);
192 
194  virtual
195  StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject);
196 
198  virtual
199  StatusCode addConverter(const CLID& clid);
200 
202  virtual
203  StatusCode addConverter(IConverter* pConverter);
204 
206  virtual
207  StatusCode removeConverter(const CLID& clid);
208 
210  virtual
211  IConverter* converter(const CLID& wanted);
212 
214  virtual
215  StatusCode connectOutput(const std::string& outputFile,
216  const std::string& openMode);
217 
219  virtual
220  StatusCode connectOutput(const std::string& output);
221 
223  virtual
224  StatusCode commitOutput(const std::string& output, bool do_commit);
225 
227 
229  virtual
230  StatusCode disconnectOutput(const std::string& output);
231 
233 
234  virtual
236  StatusCode createAddress (long svc_type,
237  const CLID& clid,
238  const std::string* par,
239  const unsigned long* ip,
240  IOpaqueAddress*& refpAddress);
241 
243  virtual
244  StatusCode convertAddress (const IOpaqueAddress* pAddress,
245  std::string& refAddress);
246 
248  virtual
249  StatusCode createAddress (long svc_type,
250  const CLID& clid,
251  const std::string& refAddress,
252  IOpaqueAddress*& refpAddress);
253 
255  virtual
256  StatusCode updateServiceState(IOpaqueAddress* pAddress);
257 
259 
261  // Private data:
263 private:
265  AthCnvSvc(); //< not implemented
266  AthCnvSvc (const AthCnvSvc&); //< not implemented
267  AthCnvSvc& operator= (const AthCnvSvc&); //< not implemented
268 
270  // Protected data and methods:
272 protected:
273 
275  virtual ~AthCnvSvc();
276 
278  virtual
279  IConverter* createConverter (long typ, const CLID& clid,
280  const ICnvFactory* fac);
281 
283  virtual
284  StatusCode configureConverter (long typ, const CLID& clid, IConverter* cnv);
285 
287  virtual
288  StatusCode initializeConverter (long typ, const CLID& clid, IConverter* cnv);
289 
291  virtual
292  StatusCode activateConverter (long typ, const CLID& clid, IConverter* cnv);
293 
295  virtual
296  void loadConverter(DataObject* pObject);
297 
299  virtual
300  SmartIF<IAddressCreator>& addressCreator()
301  {
302  return m_addressCreator;
303  }
304 
305  StatusCode makeCall (int typ,
306  bool ignore_add,
307  bool ignore_obj,
308  bool update,
309  IOpaqueAddress*& pAddress,
310  DataObject*& pObject);
311 
313  SmartIF<IDataProviderSvc> m_dataSvc;
315  SmartIF<IAddressCreator> m_addressCreator;
317  SmartIF<IConversionSvc> m_cnvSvc;
319  long m_type;
323  typedef std::recursive_mutex CallMutex;
325 };
326 
327 // I/O operators
329 
331 // Inline methods:
333 
334 #endif //> !ATHENABASECOMPS_ATHCNVSVC_H
AthCnvSvc::WorkerEntry::WorkerEntry
WorkerEntry(const CLID &cl, IConverter *cnv)
Definition: AthCnvSvc.h:77
AthCnvSvc::makeCall
StatusCode makeCall(int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
Definition: AthCnvSvc.cxx:553
AthCnvSvc::finalize
virtual StatusCode finalize()
Definition: AthCnvSvc.cxx:116
AthCnvSvc::WorkerEntry::clID
const CLID & clID() const
Definition: AthCnvSvc.h:93
AthCnvSvc::updateObjRefs
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Update the references of an updated transient object.
Definition: AthCnvSvc.cxx:297
AthCnvSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Definition: AthCnvSvc.cxx:149
AthCnvSvc::AthCnvSvc
AthCnvSvc(const AthCnvSvc &)
AthCnvSvc::removeConverter
virtual StatusCode removeConverter(const CLID &clid)
Remove converter object from conversion service (if present).
Definition: AthCnvSvc.cxx:379
AthCnvSvc::WorkerEntry::~WorkerEntry
virtual ~WorkerEntry()
Definition: AthCnvSvc.h:88
AthCnvSvc::WorkerEntry
Definition: AthCnvSvc.h:71
AthCnvSvc::m_conv_mut
CallMutex m_conv_mut
Definition: AthCnvSvc.h:324
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:536
AthCnvSvc::updateServiceState
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
Definition: AthCnvSvc.cxx:479
AthCnvSvc::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: AthCnvSvc.h:315
AthCnvSvc::WorkerEntry::operator==
bool operator==(const WorkerEntry &rhs)
Definition: AthCnvSvc.h:97
AthCnvSvc::initialize
virtual StatusCode initialize()
Gaudi Service Implementation.
Definition: AthCnvSvc.cxx:111
AthCnvSvc::AthCnvSvc
AthCnvSvc()
Default constructor:
AthCnvSvc::convertAddress
virtual StatusCode convertAddress(const IOpaqueAddress *pAddress, std::string &refAddress)
Convert an address to string form.
Definition: AthCnvSvc.cxx:459
AthCnvSvc::connectOutput
virtual StatusCode connectOutput(const std::string &outputFile, const std::string &openMode)
Connect the output file to the service with open mode.
Definition: AthCnvSvc.cxx:414
AthCnvSvc::setAddressCreator
virtual StatusCode setAddressCreator(IAddressCreator *creator)
Set address creator facility.
Definition: AthCnvSvc.cxx:243
AthCnvSvc::addressCreator
virtual SmartIF< IAddressCreator > & addressCreator() const
Retrieve address creator facility.
Definition: AthCnvSvc.cxx:261
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:510
AthCnvSvc::WorkerEntry::converter
IConverter * converter()
Definition: AthCnvSvc.h:90
AthCnvSvc::setConversionSvc
virtual StatusCode setConversionSvc(IConversionSvc *svc)
Implementation of IConverter: Set conversion service the converter is connected to.
Definition: AthCnvSvc.cxx:224
AthCnvSvc::createAddress
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
Create a Generic address using explicit arguments to identify a single object.
Definition: AthCnvSvc.cxx:447
AthCnvSvc::conversionSvc
virtual SmartIF< IConversionSvc > & conversionSvc() const
Implementation of IConverter: Get conversion service the converter is connected to.
Definition: AthCnvSvc.cxx:232
AthCnvSvc::updateRepRefs
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Update the references of an already converted object.
Definition: AthCnvSvc.cxx:329
AthCnvSvc::setDataProvider
virtual StatusCode setDataProvider(IDataProviderSvc *pService)
Implementation of IConverter: Set Data provider service.
Definition: AthCnvSvc.cxx:189
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthCnvSvc::createRep
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Implementation of IConverter: Convert the transient object to the requested representation.
Definition: AthCnvSvc.cxx:305
AthService
Definition: AthService.h:32
AthCnvSvc::CallMutex
std::recursive_mutex CallMutex
Mutex to protect Converter creation.
Definition: AthCnvSvc.h:323
AthCnvSvc::objType
const CLID & objType() const
Implementation of IConverter: dummy call.
Definition: AthCnvSvc.cxx:179
AthCnvSvc::WorkerEntry::WorkerEntry
WorkerEntry(const WorkerEntry &copy)
Definition: AthCnvSvc.h:80
AthCnvSvc::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)
Implementation of IConverter: Create the transient representation of an object.
Definition: AthCnvSvc.cxx:273
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:317
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
AthCnvSvc::dataProvider
virtual SmartIF< IDataProviderSvc > & dataProvider() const
Implementation of IConverter: Get Data provider service.
Definition: AthCnvSvc.cxx:212
AthCnvSvc::WorkerEntry::m_class
CLID m_class
Definition: AthCnvSvc.h:74
AthCnvSvc::m_workers
Workers m_workers
List of conversion workers.
Definition: AthCnvSvc.h:321
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:525
AthCnvSvc::updateRep
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Update the converted representation of a transient object.
Definition: AthCnvSvc.cxx:321
AthCnvSvc::operator=
AthCnvSvc & operator=(const AthCnvSvc &)
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
AthCnvSvc::addConverter
virtual StatusCode addConverter(const CLID &clid)
Add converter object to conversion service.
Definition: AthCnvSvc.cxx:336
AthCnvSvc::fillRepRefs
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Resolve the references of the converted object.
Definition: AthCnvSvc.cxx:313
AthCnvSvc::fillObjRefs
virtual StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)
Implementation of IConverter: Resolve the references of the created transient object.
Definition: AthCnvSvc.cxx:281
AthCnvSvc::updateObj
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)
Implementation of IConverter: Update the transient object from the other representation.
Definition: AthCnvSvc.cxx:289
AthCnvSvc::createConverter
virtual IConverter * createConverter(long typ, const CLID &clid, const ICnvFactory *fac)
Create new Converter using factory.
Definition: AthCnvSvc.cxx:491
AthCnvSvc::commitOutput
virtual StatusCode commitOutput(const std::string &output, bool do_commit)
Commit pending output.
Definition: AthCnvSvc.cxx:429
AthCnvSvc::addressCreator
virtual SmartIF< IAddressCreator > & addressCreator()
Retrieve address creation interface.
Definition: AthCnvSvc.h:300
AthCnvSvc::converter
virtual IConverter * converter(const CLID &wanted)
Retrieve converter from list.
Definition: AthCnvSvc.cxx:394
AthCnvSvc::~AthCnvSvc
virtual ~AthCnvSvc()
Destructor:
Definition: AthCnvSvc.cxx:66
AthCnvSvc::WorkerEntry::operator<
bool operator<(const WorkerEntry &rhs)
Definition: AthCnvSvc.h:101
dqt_zlumi_pandas.update
update
Definition: dqt_zlumi_pandas.py:42
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthCnvSvc::WorkerEntry::operator=
WorkerEntry & operator=(const WorkerEntry &copy)
Definition: AthCnvSvc.h:83
AthCnvSvc::loadConverter
virtual void loadConverter(DataObject *pObject)
Load converter or dictionary needed by the converter.
Definition: AthCnvSvc.cxx:547
AthCnvSvc::Workers
std::unordered_map< CLID, WorkerEntry > Workers
Definition: AthCnvSvc.h:106
AthService.h
AthCnvSvc::m_dataSvc
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
Definition: AthCnvSvc.h:313
AthCnvSvc::disconnectOutput
virtual StatusCode disconnectOutput(const std::string &output)
Disconnect output files from the service.
Definition: AthCnvSvc.cxx:437
calibdata.copy
bool copy
Definition: calibdata.py:27
AthCnvSvc::WorkerEntry::m_converter
IConverter * m_converter
Definition: AthCnvSvc.h:75
AthCnvSvc::repSvcType
virtual long repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: AthCnvSvc.cxx:172
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
AthCnvSvc
Definition: AthCnvSvc.h:67
AthCnvSvc::m_type
long m_type
Conversion service type.
Definition: AthCnvSvc.h:319