The Gaudi Framework  master (d98a2936)
Converter.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 
13 // generic experiment headers
15 #include <GaudiKernel/IConverter.h>
18 #include <GaudiKernel/IService.h>
20 
21 // Forward declarations
22 class IMessageSvc;
23 class IRegistry;
24 
33 class GAUDI_API Converter : public implements<IConverter> {
34 public:
35  using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>;
36 
38  StatusCode initialize() override;
39 
41  StatusCode finalize() override;
42 
44  StatusCode setDataProvider( IDataProviderSvc* svc ) override;
45 
47  SmartIF<IDataProviderSvc>& dataProvider() const override;
48 
50  StatusCode setConversionSvc( IConversionSvc* svc ) override;
51 
53  SmartIF<IConversionSvc>& conversionSvc() const override;
54 
56  StatusCode setAddressCreator( IAddressCreator* creator ) override;
57 
59  SmartIF<IAddressCreator>& addressCreator() const override;
60 
62  const CLID& objType() const override;
63 
65  // MSF: Masked to generate compiler error due to interface change
66  virtual long i_repSvcType() const;
67 
69  StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
70 
72  StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
73 
75  StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
76 
78  StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
79 
81  StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
82 
84  StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
85 
87  StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
88 
90  StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
91 
93  Converter( long storage_type, const CLID& class_type, ISvcLocator* svc = 0 );
94 
96  SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
97 
98 protected:
100  SmartIF<ISvcLocator>& serviceLocator() const;
102  SmartIF<IMessageSvc>& msgSvc() const;
104  SmartIF<IDataManagerSvc>& dataManager() const;
105 
106 private:
123 };
124 
125 // Identified class for converters' factories
126 class GAUDI_API ConverterID final {
127 public:
128  ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
129  inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
130 
131 private:
132  friend std::ostream& operator<<( std::ostream&, const ConverterID& );
133  long m_stype;
135 };
136 
137 inline std::ostream& operator<<( std::ostream& s, const ConverterID& id ) {
138  return s << "CNV_" << id.m_stype << "_" << id.m_clid;
139 }
140 
141 // Macro to declare component factories
142 #define DECLARE_CONVERTER( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
operator<<
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:137
Converter::m_conversionSvc
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:118
IAddressCreator
Definition: IAddressCreator.h:33
IService.h
IMessageSvc
Definition: IMessageSvc.h:34
gaudirun.s
string s
Definition: gaudirun.py:346
IOpaqueAddress
Definition: IOpaqueAddress.h:28
ISvcLocator
Definition: ISvcLocator.h:42
IConverter
Definition: IConverter.h:65
IRegistry
Definition: IRegistry.h:29
ConverterID::ConverterID
ConverterID(long stype, CLID clid)
Definition: Converter.h:128
IDataProviderSvc.h
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
ConverterID
Definition: Converter.h:126
StatusCode
Definition: StatusCode.h:64
Converter
Definition: Converter.h:33
ConverterID::operator==
bool operator==(const ConverterID &id) const
Definition: Converter.h:129
Converter::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:112
ConverterID::m_clid
CLID m_clid
Definition: Converter.h:134
Converter::m_dataProvider
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:114
Converter::m_dataManager
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:116
Write.creator
creator
Definition: Write.py:23
SmartIF< IDataProviderSvc >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:16
IConverter.h
Converter::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:120
implements
Base class used to implement the interfaces.
Definition: implements.h:19
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Converter::m_messageSvc
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:122
DataObject
Definition: DataObject.h:37
Converter::Factory
Gaudi::PluginService::Factory< IConverter *(ISvcLocator *)> Factory
Definition: Converter.h:35
Converter::m_storageType
long m_storageType
Storage type.
Definition: Converter.h:108
IDataProviderSvc
Definition: IDataProviderSvc.h:48
ISvcLocator.h
ConversionSvc.h
Converter::m_classType
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:110
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:49
IDataManagerSvc.h
ConverterID::m_stype
long m_stype
Definition: Converter.h:133
IConversionSvc
Definition: IConversionSvc.h:43