The Gaudi Framework  master (37c0b60a)
ConversionSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #ifndef GAUDIKERNEL_CONVERSIONSVC_H
12 #define GAUDIKERNEL_CONVERSIONSVC_H 1
13 
14 // Include files
18 #include <GaudiKernel/Kernel.h>
19 #include <GaudiKernel/Service.h>
20 #include <algorithm>
21 #include <utility>
22 #include <vector>
23 
55 class GAUDI_API ConversionSvc : public extends<Service, IConversionSvc, IAddressCreator> {
56  class WorkerEntry final {
59 
60  public:
61  WorkerEntry( const CLID& cl, IConverter* cnv ) : m_class( cl ), m_converter( cnv ) {
62  if ( m_converter ) m_converter->addRef();
63  }
64 
66  if ( m_converter ) m_converter->release();
67  }
68 
69  WorkerEntry( WorkerEntry&& orig ) noexcept
70  : m_class{ orig.m_class }, m_converter{ std::exchange( orig.m_converter, nullptr ) } {}
71 
72  WorkerEntry& operator=( WorkerEntry&& orig ) noexcept {
73  m_class = orig.m_class;
74  std::swap( m_converter, orig.m_converter );
75  return *this;
76  }
77 
78  WorkerEntry( const WorkerEntry& copy ) = delete;
79  WorkerEntry& operator=( const WorkerEntry& copy ) = delete;
80 
81  IConverter* converter() { return m_converter; }
82 
83  const CLID& clID() const { return m_class; }
84  };
85 
86 public:
88  ConversionSvc( const std::string& name, ISvcLocator* svc, long type );
89 
91  ConversionSvc( const ConversionSvc& ) = delete;
92  ConversionSvc& operator=( const ConversionSvc& ) = delete;
93 
95  StatusCode initialize() override;
96 
98  StatusCode finalize() override;
99 
101  long repSvcType() const override;
102 
104  const CLID& objType() const override;
105 
110  StatusCode setDataProvider( IDataProviderSvc* pService ) override;
111 
115  SmartIF<IDataProviderSvc>& dataProvider() const override;
116 
118  StatusCode setConversionSvc( IConversionSvc* svc ) override;
119 
121  SmartIF<IConversionSvc>& conversionSvc() const override;
122 
124  StatusCode setAddressCreator( IAddressCreator* creator ) override;
125 
127  SmartIF<IAddressCreator>& addressCreator() const override;
128 
130  StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
131 
133  StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
134 
136  StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
137 
139  StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
140 
142  StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
143 
145  StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
146 
148  StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
149 
151  StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
152 
154  StatusCode addConverter( const CLID& clid ) override;
155 
157  StatusCode addConverter( IConverter* pConverter ) override;
158 
160  StatusCode removeConverter( const CLID& clid ) override;
161 
163  IConverter* converter( const CLID& wanted ) override;
164 
166  StatusCode connectOutput( const std::string& outputFile, const std::string& openMode ) override;
167 
169  StatusCode connectOutput( const std::string& output ) override;
170 
172  StatusCode commitOutput( const std::string& output, bool do_commit ) override;
173 
175  StatusCode createAddress( long svc_type, const CLID& clid, const std::string* par, const unsigned long* ip,
176  IOpaqueAddress*& refpAddress ) override;
177 
179  StatusCode convertAddress( const IOpaqueAddress* pAddress, std::string& refAddress ) override;
180 
182  StatusCode createAddress( long svc_type, const CLID& clid, const std::string& refAddress,
183  IOpaqueAddress*& refpAddress ) override;
184 
186  virtual StatusCode updateServiceState( IOpaqueAddress* pAddress );
187 
188 protected:
190  virtual IConverter* createConverter( long typ, const CLID& clid, const ICnvFactory* fac );
191 
193  virtual StatusCode configureConverter( long typ, const CLID& clid, IConverter* cnv );
194 
196  virtual StatusCode initializeConverter( long typ, const CLID& clid, IConverter* cnv );
197 
199  virtual StatusCode activateConverter( long typ, const CLID& clid, IConverter* cnv );
200 
202  virtual void loadConverter( DataObject* pObject );
203 
205  virtual SmartIF<IAddressCreator>& addressCreator() { return m_addressCreator; }
206 
207 protected:
208  StatusCode makeCall( int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress*& pAddress,
209  DataObject*& pObject );
210 
218  long m_type;
221 };
222 #endif // GAUDIKERNEL_CONVERSIONSVC_H
ConversionSvc
Definition: ConversionSvc.h:55
ConversionSvc::WorkerEntry::WorkerEntry
WorkerEntry(const CLID &cl, IConverter *cnv)
Definition: ConversionSvc.h:61
IAddressCreator
Definition: IAddressCreator.h:38
std::string
STL class.
ConversionSvc::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: ConversionSvc.h:214
ConversionSvc::WorkerEntry::operator=
WorkerEntry & operator=(const WorkerEntry &copy)=delete
ConversionSvc::addressCreator
virtual SmartIF< IAddressCreator > & addressCreator()
Retrieve address creation interface.
Definition: ConversionSvc.h:205
IOpaqueAddress
Definition: IOpaqueAddress.h:33
std::vector
STL class.
IAddressCreator.h
ISvcLocator
Definition: ISvcLocator.h:46
ConversionSvc::WorkerEntry::m_converter
IConverter * m_converter
Definition: ConversionSvc.h:58
IConverter
Definition: IConverter.h:68
ConversionSvc::WorkerEntry::~WorkerEntry
~WorkerEntry()
Definition: ConversionSvc.h:65
ConversionSvc::WorkerEntry
Definition: ConversionSvc.h:56
gaudirun.output
output
Definition: gaudirun.py:521
ConversionSvc::WorkerEntry::converter
IConverter * converter()
Definition: ConversionSvc.h:81
IDataProviderSvc.h
compareOutputFiles.par
par
Definition: compareOutputFiles.py:477
StatusCode
Definition: StatusCode.h:65
ConversionSvc::WorkerEntry::clID
const CLID & clID() const
Definition: ConversionSvc.h:83
ConversionSvc::WorkerEntry::WorkerEntry
WorkerEntry(const WorkerEntry &copy)=delete
Write.creator
creator
Definition: Write.py:23
ConversionSvc::m_type
long m_type
Conversion service type.
Definition: ConversionSvc.h:218
ConversionSvc::operator=
ConversionSvc & operator=(const ConversionSvc &)=delete
SmartIF< IDataProviderSvc >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
std::swap
T swap(T... args)
Service.h
ConversionSvc::m_cnvSvc
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
Definition: ConversionSvc.h:216
gaudirun.type
type
Definition: gaudirun.py:160
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
GaudiPython.Pythonizations.update
update
Definition: Pythonizations.py:145
Kernel.h
ConversionSvc::WorkerEntry::operator=
WorkerEntry & operator=(WorkerEntry &&orig) noexcept
Definition: ConversionSvc.h:72
DataObject
Definition: DataObject.h:36
IDataProviderSvc
Definition: IDataProviderSvc.h:53
IConversionSvc.h
IInterface::release
virtual unsigned long release()=0
Release Interface instance.
ConversionSvc::m_dataSvc
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
Definition: ConversionSvc.h:212
ConversionSvc::WorkerEntry::m_class
CLID m_class
Definition: ConversionSvc.h:57
IInterface::addRef
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
ConversionSvc::WorkerEntry::WorkerEntry
WorkerEntry(WorkerEntry &&orig) noexcept
Definition: ConversionSvc.h:69
ConversionSvc::m_workers
std::vector< WorkerEntry > m_workers
List of conversion workers.
Definition: ConversionSvc.h:220
ConversionSvc::ConversionSvc
ConversionSvc(const ConversionSvc &)=delete
disable copy and assignment
IConversionSvc
Definition: IConversionSvc.h:47