The Gaudi Framework  master (37c0b60a)
Converter.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_CONVERTER_H
12 #define GAUDIKERNEL_CONVERTER_H
13 
14 // generic experiment headers
16 #include <GaudiKernel/IConverter.h>
19 #include <GaudiKernel/IService.h>
21 
22 // Forward declarations
23 class IMessageSvc;
24 class IRegistry;
25 
34 class GAUDI_API Converter : public implements<IConverter> {
35 public:
36  using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>;
37 
39  StatusCode initialize() override;
40 
42  StatusCode finalize() override;
43 
45  StatusCode setDataProvider( IDataProviderSvc* svc ) override;
46 
48  SmartIF<IDataProviderSvc>& dataProvider() const override;
49 
51  StatusCode setConversionSvc( IConversionSvc* svc ) override;
52 
54  SmartIF<IConversionSvc>& conversionSvc() const override;
55 
57  StatusCode setAddressCreator( IAddressCreator* creator ) override;
58 
60  SmartIF<IAddressCreator>& addressCreator() const override;
61 
63  const CLID& objType() const override;
64 
66  // MSF: Masked to generate compiler error due to interface change
67  virtual long i_repSvcType() const;
68 
70  StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
71 
73  StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
74 
76  StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
77 
79  StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
80 
82  StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
83 
85  StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
86 
88  StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
89 
91  StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
92 
94  Converter( long storage_type, const CLID& class_type, ISvcLocator* svc = 0 );
95 
97  template <class T>
98  [[deprecated( "use service<T>(name, createIf) -> SmartIF<T>" )]] StatusCode
99  service( const std::string& name, T*& psvc, bool createIf = false ) const {
100  return service_i( name, createIf, T::interfaceID(), (void**)&psvc );
101  }
102 
104  template <class T>
105  [[deprecated( "use service<T>(name, createIf) -> SmartIF<T>" )]] StatusCode
106  service( const std::string& type, const std::string& name, T*& psvc ) const {
107  return service_i( type, name, T::interfaceID(), reinterpret_cast<void**>( &psvc ) );
108  }
109 
111  SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
112 
113 protected:
115  SmartIF<ISvcLocator>& serviceLocator() const;
117  SmartIF<IMessageSvc>& msgSvc() const;
119  SmartIF<IDataManagerSvc>& dataManager() const;
120 
121 private:
138 
140  [[deprecated]] StatusCode service_i( const std::string& svcName, bool createIf, const InterfaceID& iid,
141  void** ppSvc ) const;
142  [[deprecated]] StatusCode service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
143  void** ppSvc ) const;
144 };
145 
146 // Identified class for converters' factories
147 class GAUDI_API ConverterID final {
148 public:
149  ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
150  inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
151 
152 private:
153  friend std::ostream& operator<<( std::ostream&, const ConverterID& );
154  long m_stype;
156 };
157 
159  return s << "CNV_" << id.m_stype << "_" << id.m_clid;
160 }
161 
162 // Macro to declare component factories
163 #define DECLARE_CONVERTER( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
164 
165 #endif // GAUDIKERNEL_CONVERTER_H
operator<<
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:158
Converter::m_conversionSvc
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:133
IAddressCreator
Definition: IAddressCreator.h:38
IService.h
std::string
STL class.
IMessageSvc
Definition: IMessageSvc.h:47
gaudirun.s
string s
Definition: gaudirun.py:346
IOpaqueAddress
Definition: IOpaqueAddress.h:33
ISvcLocator
Definition: ISvcLocator.h:46
IConverter
Definition: IConverter.h:68
IRegistry
Definition: IRegistry.h:32
ConverterID::ConverterID
ConverterID(long stype, CLID clid)
Definition: Converter.h:149
IDataProviderSvc.h
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
ConverterID
Definition: Converter.h:147
StatusCode
Definition: StatusCode.h:65
Converter
Definition: Converter.h:34
ConverterID::operator==
bool operator==(const ConverterID &id) const
Definition: Converter.h:150
Converter::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:127
std::ostream
STL class.
ConverterID::m_clid
CLID m_clid
Definition: Converter.h:155
Converter::m_dataProvider
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:129
Converter::m_dataManager
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:131
Write.creator
creator
Definition: Write.py:23
SmartIF< IDataProviderSvc >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
Converter::service
StatusCode service(const std::string &type, const std::string &name, T *&psvc) const
Access a service by name, type creating it if it doesn't already exist.
Definition: Converter.h:106
IConverter.h
Converter::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:135
implements
Base class used to implement the interfaces.
Definition: implements.h:19
gaudirun.type
type
Definition: gaudirun.py:160
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Converter::m_messageSvc
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:137
Converter::service
StatusCode service(const std::string &name, T *&psvc, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
Definition: Converter.h:99
DataObject
Definition: DataObject.h:36
Converter::Factory
Gaudi::PluginService::Factory< IConverter *(ISvcLocator *)> Factory
Definition: Converter.h:36
Converter::m_storageType
long m_storageType
Storage type.
Definition: Converter.h:123
IDataProviderSvc
Definition: IDataProviderSvc.h:53
InterfaceID
Definition: IInterface.h:39
ISvcLocator.h
ConversionSvc.h
Converter::m_classType
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:125
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
IDataManagerSvc.h
ConverterID::m_stype
long m_stype
Definition: Converter.h:154
IConversionSvc
Definition: IConversionSvc.h:47