| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Converter.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_CONVERTER_H
2 #define GAUDIKERNEL_CONVERTER_H
3
4 // generic experiment headers
5 #include "GaudiKernel/IConverter.h"
6 #include "GaudiKernel/ISvcLocator.h"
7 #include "GaudiKernel/IService.h"
8 #include "GaudiKernel/ConversionSvc.h"
9 #include "GaudiKernel/IDataProviderSvc.h"
10 #include "GaudiKernel/IDataManagerSvc.h"
11
12 // Forward declarations
13 class IMessageSvc;
14 class IRegistry;
15
24 class GAUDI_API Converter : public implements<IConverter> {
25 public:
26 #ifndef __REFLEX__
27 typedef Gaudi::PluginService::Factory<IConverter*,
28 ISvcLocator*> Factory;
29 #endif
30
32 StatusCode initialize() override;
33
35 StatusCode finalize() override;
36
38 StatusCode setDataProvider(IDataProviderSvc* svc) override;
39
41 SmartIF<IDataProviderSvc>& dataProvider() const override;
42
44 StatusCode setConversionSvc(IConversionSvc* svc) override;
45
47 SmartIF<IConversionSvc>& conversionSvc() const override;
48
50 StatusCode setAddressCreator(IAddressCreator* creator) override;
51
53 SmartIF<IAddressCreator>& addressCreator() const override;
54
56 const CLID& objType() const override;
57
59 // MSF: Masked to generate compiler error due to interface change
60 virtual long i_repSvcType() const;
61
63 StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject) override;
64
66 StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
67
69 StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject) override;
70
72 StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
73
75 StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress) override;
76
78 StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject) override;
79
81 StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject) override;
82
84 StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
85
87 Converter(long storage_type, const CLID& class_type, ISvcLocator* svc = 0);
88
90 template <class T>
91 StatusCode service( const std::string& name, T*& psvc, bool createIf = false ) const {
92 return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
93 }
94
96 template <class T>
97 StatusCode service( const std::string& type, const std::string& name, T*& psvc) const {
98 return service_i(type, name, T::interfaceID(), (void**)&psvc);
99 }
100
102 SmartIF<IService> service(const std::string& name, const bool createIf = true) const;
103
104 protected:
105
107 ~Converter() override = default;
108
110 SmartIF<ISvcLocator>& serviceLocator() const;
112 SmartIF<IMessageSvc>& msgSvc() const;
114 [[deprecated("will be removed in v29r0, use msgSvc() instead, see https://gitlab.cern.ch/gaudi/Gaudi/merge_requests/80")]]
115 SmartIF<IMessageSvc>& messageService() const;
117 SmartIF<IDataManagerSvc>& dataManager() const;
118
119 private:
120
122 long m_storageType;
124 const CLID m_classType;
126 mutable SmartIF<IAddressCreator> m_addressCreator;
128 mutable SmartIF<IDataProviderSvc> m_dataProvider;
130 mutable SmartIF<IDataManagerSvc> m_dataManager;
132 mutable SmartIF<IConversionSvc> m_conversionSvc;
134 mutable SmartIF<ISvcLocator> m_svcLocator;
136 mutable SmartIF<IMessageSvc> m_messageSvc;
137
139 StatusCode service_i(const std::string& svcName,
140 bool createIf,
141 const InterfaceID& iid,
142 void** ppSvc) const;
143 StatusCode service_i(const std::string& svcType,
144 const std::string& svcName,
145 const InterfaceID& iid,
146 void** ppSvc) const;
147 };
148
149
150 // Identified class for converters' factories
151 class GAUDI_API ConverterID final{
152 public:
153 ConverterID( long stype, CLID clid ) : m_stype(stype), m_clid(clid) {}
154 inline bool operator ==(const ConverterID& id) const {
155 return m_stype == id.m_stype && m_clid == id.m_clid;
156 }
157 private:
158 friend std::ostream& operator << ( std::ostream&, const ConverterID&);
159 long m_stype;
160 CLID m_clid;
161 };
162
163 inline std::ostream& operator << ( std::ostream& s, const ConverterID& id) {
164 return s << "CNV_" << id.m_stype << "_" << id.m_clid;
165 }
166
167
168 #ifndef GAUDI_NEW_PLUGIN_SERVICE
169 template <class T>
170 class CnvFactory final {
171 public:
172 #ifndef __REFLEX__
173 template <typename S, typename... Args>
174 static typename S::ReturnType create(Args&&... a1) {
175 return new T(std::forward<Args>(a1)...);
176 }
177 #endif
178 };
179
180 // Macro to declare component factories
181 #define DECLARE_CONVERTER_FACTORY(x) \
182 DECLARE_FACTORY_WITH_CREATOR_AND_ID(x, CnvFactory< x >, \
183 ConverterID(x::storageType(), x::classID()), Converter::Factory)
184 #define DECLARE_NAMESPACE_CONVERTER_FACTORY(n, x) \
185 DECLARE_CONVERTER_FACTORY(n::x)
186
187 #else
188
189 // Macro to declare component factories
190 #define DECLARE_CONVERTER_FACTORY(x) \
191 DECLARE_COMPONENT_WITH_ID(x, ConverterID(x::storageType(), x::classID()))
192 #define DECLARE_NAMESPACE_CONVERTER_FACTORY(n, x) \
193 DECLARE_CONVERTER_FACTORY(n::x)
194
195 #endif
196
197 #endif // GAUDIKERNEL_CONVERTER_H
SmartIF< IDataProviderSvc >
implements
Base class used to implement the interfaces.
Definition: implements.h:9
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
IConverter
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
ConverterID::m_clid
CLID m_clid
Definition: Converter.h:160
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
IConversionSvc
Definition: IConversionSvc.h:37
ConversionSvc.h
IAddressCreator
IAddressCreator interface definition.
Definition: IAddressCreator.h:28
Gaudi::Functional::deprecated
struct deprecated("use MergingTransformer instead")]] ListTransformer
Definition: ListTransformer.h:9
operator<<
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:163
CnvFactory::create
static S::ReturnType create(Args &&...a1)
Definition: Converter.h:174
ConverterID::m_stype
long m_stype
Definition: Converter.h:159
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
std::string
STL class.
AvalancheSchedulerSimpleTest.a1
a1
Definition: AvalancheSchedulerSimpleTest.py:80
InterfaceID
Interface ID class.
Definition: IInterface.h:30
IDataManagerSvc.h
IDataProviderSvc.h
operator==
bool operator==(const GaudiUtils::Allocator< T1 > &, const GaudiUtils::Allocator< T2 > &)
Definition: Allocator.h:249
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
ForwardSchedulerSimpleTest.msgSvc
msgSvc
Definition: ForwardSchedulerSimpleTest.py:112
gaudirun.type
type
Definition: gaudirun.py:125
Converter::service
StatusCode service(const std::string &name, T *&psvc, bool createIf=false) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Converter.h:91
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
ConverterID::ConverterID
ConverterID(long stype, CLID clid)
Definition: Converter.h:153
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Converter
Converter base class.
Definition: Converter.h:24
IService.h
Gaudi::PluginService::Factory
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginService.h:47
gaudirun.s
string s
Definition: gaudirun.py:245
CnvFactory
Definition: Converter.h:170
Converter::Factory
Gaudi::PluginService::Factory< IConverter *, ISvcLocator * > Factory
Definition: Converter.h:28
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&#39;t already exist.
Definition: Converter.h:97
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
IConverter.h
std::ostream
STL class.
ISvcLocator.h
ConverterID
Definition: Converter.h:151