File indexing completed on 2025-09-17 08:57:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef GAUDIKERNEL_CONVERTER_H
0012 #define GAUDIKERNEL_CONVERTER_H
0013
0014
0015 #include <GaudiKernel/ConversionSvc.h>
0016 #include <GaudiKernel/IConverter.h>
0017 #include <GaudiKernel/IDataManagerSvc.h>
0018 #include <GaudiKernel/IDataProviderSvc.h>
0019 #include <GaudiKernel/IService.h>
0020 #include <GaudiKernel/ISvcLocator.h>
0021
0022
0023 class IMessageSvc;
0024 class IRegistry;
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 class GAUDI_API Converter : public implements<IConverter> {
0035 public:
0036 using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>;
0037
0038
0039 StatusCode initialize() override;
0040
0041
0042 StatusCode finalize() override;
0043
0044
0045 StatusCode setDataProvider( IDataProviderSvc* svc ) override;
0046
0047
0048 SmartIF<IDataProviderSvc>& dataProvider() const override;
0049
0050
0051 StatusCode setConversionSvc( IConversionSvc* svc ) override;
0052
0053
0054 SmartIF<IConversionSvc>& conversionSvc() const override;
0055
0056
0057 StatusCode setAddressCreator( IAddressCreator* creator ) override;
0058
0059
0060 SmartIF<IAddressCreator>& addressCreator() const override;
0061
0062
0063 const CLID& objType() const override;
0064
0065
0066
0067 virtual long i_repSvcType() const;
0068
0069
0070 StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
0071
0072
0073 StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
0074
0075
0076 StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
0077
0078
0079 StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
0080
0081
0082 StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
0083
0084
0085 StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
0086
0087
0088 StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
0089
0090
0091 StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
0092
0093
0094 Converter( long storage_type, const CLID& class_type, ISvcLocator* svc = 0 );
0095
0096
0097 template <class T>
0098 [[deprecated( "use service<T>(name, createIf) -> SmartIF<T>" )]] StatusCode
0099 service( const std::string& name, T*& psvc, bool createIf = false ) const {
0100 return service_i( name, createIf, T::interfaceID(), (void**)&psvc );
0101 }
0102
0103
0104 template <class T>
0105 [[deprecated( "use service<T>(name, createIf) -> SmartIF<T>" )]] StatusCode
0106 service( const std::string& type, const std::string& name, T*& psvc ) const {
0107 return service_i( type, name, T::interfaceID(), reinterpret_cast<void**>( &psvc ) );
0108 }
0109
0110
0111 SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
0112
0113 protected:
0114
0115 SmartIF<ISvcLocator>& serviceLocator() const;
0116
0117 SmartIF<IMessageSvc>& msgSvc() const;
0118
0119 SmartIF<IDataManagerSvc>& dataManager() const;
0120
0121 private:
0122
0123 long m_storageType;
0124
0125 const CLID m_classType;
0126
0127 mutable SmartIF<IAddressCreator> m_addressCreator;
0128
0129 mutable SmartIF<IDataProviderSvc> m_dataProvider;
0130
0131 mutable SmartIF<IDataManagerSvc> m_dataManager;
0132
0133 mutable SmartIF<IConversionSvc> m_conversionSvc;
0134
0135 mutable SmartIF<ISvcLocator> m_svcLocator;
0136
0137 mutable SmartIF<IMessageSvc> m_messageSvc;
0138
0139
0140 [[deprecated]] StatusCode service_i( const std::string& svcName, bool createIf, const InterfaceID& iid,
0141 void** ppSvc ) const;
0142 [[deprecated]] StatusCode service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
0143 void** ppSvc ) const;
0144 };
0145
0146
0147 class GAUDI_API ConverterID final {
0148 public:
0149 ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
0150 inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
0151
0152 private:
0153 friend std::ostream& operator<<( std::ostream&, const ConverterID& );
0154 long m_stype;
0155 CLID m_clid;
0156 };
0157
0158 inline std::ostream& operator<<( std::ostream& s, const ConverterID& id ) {
0159 return s << "CNV_" << id.m_stype << "_" << id.m_clid;
0160 }
0161
0162
0163 #define DECLARE_CONVERTER( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
0164
0165 #endif