File indexing completed on 2025-02-21 10:00:28
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 StatusCode service( const std::string& name, T*& psvc, bool createIf = false ) const {
0099 return service_i( name, createIf, T::interfaceID(), (void**)&psvc );
0100 }
0101
0102
0103 template <class T>
0104 StatusCode service( const std::string& type, const std::string& name, T*& psvc ) const {
0105 return service_i( type, name, T::interfaceID(), reinterpret_cast<void**>( &psvc ) );
0106 }
0107
0108
0109 SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
0110
0111 protected:
0112
0113 SmartIF<ISvcLocator>& serviceLocator() const;
0114
0115 SmartIF<IMessageSvc>& msgSvc() const;
0116
0117 SmartIF<IDataManagerSvc>& dataManager() const;
0118
0119 private:
0120
0121 long m_storageType;
0122
0123 const CLID m_classType;
0124
0125 mutable SmartIF<IAddressCreator> m_addressCreator;
0126
0127 mutable SmartIF<IDataProviderSvc> m_dataProvider;
0128
0129 mutable SmartIF<IDataManagerSvc> m_dataManager;
0130
0131 mutable SmartIF<IConversionSvc> m_conversionSvc;
0132
0133 mutable SmartIF<ISvcLocator> m_svcLocator;
0134
0135 mutable SmartIF<IMessageSvc> m_messageSvc;
0136
0137
0138 StatusCode service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const;
0139 StatusCode service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
0140 void** ppSvc ) const;
0141 };
0142
0143
0144 class GAUDI_API ConverterID final {
0145 public:
0146 ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
0147 inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
0148
0149 private:
0150 friend std::ostream& operator<<( std::ostream&, const ConverterID& );
0151 long m_stype;
0152 CLID m_clid;
0153 };
0154
0155 inline std::ostream& operator<<( std::ostream& s, const ConverterID& id ) {
0156 return s << "CNV_" << id.m_stype << "_" << id.m_clid;
0157 }
0158
0159
0160 #define DECLARE_CONVERTER( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
0161
0162 #endif