| The Gaudi Framework v30r0 (c919700c)

- 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/ConversionSvc.h"
6 #include "GaudiKernel/IConverter.h"
7 #include "GaudiKernel/IDataManagerSvc.h"
8 #include "GaudiKernel/IDataProviderSvc.h"
9 #include "GaudiKernel/IService.h"
10 #include "GaudiKernel/ISvcLocator.h"
11
12 // Forward declarations
13 class IMessageSvc;
14 class IRegistry;
15
24 class GAUDI_API Converter : public implements<IConverter>
25 {
26 public:
27 #ifndef __REFLEX__
28 typedef Gaudi::PluginService::Factory<IConverter*, 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 {
93 return service_i( name, createIf, T::interfaceID(), (void**)&psvc );
94 }
95
97 template <class T>
98 StatusCode service( const std::string& type, const std::string& name, T*& psvc ) const
99 {
100 return service_i( type, name, T::interfaceID(), (void**)&psvc );
101 }
102
104 SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
105
106 protected:
108 ~Converter() override = default;
109
111 SmartIF<ISvcLocator>& serviceLocator() const;
113 SmartIF<IMessageSvc>& msgSvc() const;
115 SmartIF<IDataManagerSvc>& dataManager() const;
116
117 private:
119 long m_storageType;
121 const CLID m_classType;
123 mutable SmartIF<IAddressCreator> m_addressCreator;
125 mutable SmartIF<IDataProviderSvc> m_dataProvider;
127 mutable SmartIF<IDataManagerSvc> m_dataManager;
129 mutable SmartIF<IConversionSvc> m_conversionSvc;
131 mutable SmartIF<ISvcLocator> m_svcLocator;
133 mutable SmartIF<IMessageSvc> m_messageSvc;
134
136 StatusCode service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const;
137 StatusCode service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
138 void** ppSvc ) const;
139 };
140
141 // Identified class for converters' factories
142 class GAUDI_API ConverterID final
143 {
144 public:
145 ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
146 inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
147
148 private:
149 friend std::ostream& operator<<( std::ostream&, const ConverterID& );
150 long m_stype;
151 CLID m_clid;
152 };
153
154 inline std::ostream& operator<<( std::ostream& s, const ConverterID& id )
155 {
156 return s << "CNV_" << id.m_stype << "_" << id.m_clid;
157 }
158
159 #ifndef GAUDI_NEW_PLUGIN_SERVICE
160 template <class T>
161 class CnvFactory final
162 {
163 public:
164 #ifndef __REFLEX__
165 template <typename S, typename... Args>
166 static typename S::ReturnType create( Args&&... a1 )
167 {
168 return new T( std::forward<Args>( a1 )... );
169 }
170 #endif
171 };
172
173 // Macro to declare component factories
174 #define DECLARE_CONVERTER_FACTORY( x ) \
175 DECLARE_FACTORY_WITH_CREATOR_AND_ID( x, CnvFactory<x>, ConverterID( x::storageType(), x::classID() ), \
176 Converter::Factory )
177 #define DECLARE_NAMESPACE_CONVERTER_FACTORY( n, x ) DECLARE_CONVERTER_FACTORY( n::x )
178
179 #else
180
181 // Macro to declare component factories
182 #define DECLARE_CONVERTER_FACTORY( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
183 #define DECLARE_NAMESPACE_CONVERTER_FACTORY( n, x ) DECLARE_CONVERTER_FACTORY( n::x )
184
185 #endif
186
187 #endif // GAUDIKERNEL_CONVERTER_H
Converter::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:123
Converter::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:131
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
ConverterID::m_clid
CLID m_clid
Definition: Converter.h:151
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
IConversionSvc
Definition: IConversionSvc.h:37
ConversionSvc.h
Converter::m_dataManager
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:127
IAddressCreator
IAddressCreator interface definition.
Definition: IAddressCreator.h:28
operator<<
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:154
Converter::m_messageSvc
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:133
CnvFactory::create
static S::ReturnType create(Args &&...a1)
Definition: Converter.h:166
ConverterID::m_stype
long m_stype
Definition: Converter.h:150
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:46
std::string
STL class.
Converter::m_conversionSvc
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:129
InterfaceID
Interface ID class.
Definition: IInterface.h:29
IDataManagerSvc.h
IDataProviderSvc.h
Converter::m_storageType
long m_storageType
Storage type.
Definition: Converter.h:119
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
gaudirun.type
type
Definition: gaudirun.py:133
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:38
Converter::m_classType
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:121
ConverterID::operator==
bool operator==(const ConverterID &id) const
Definition: Converter.h:146
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:145
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:45
AutoLoadUnmetDataInputs.a1
a1
Definition: AutoLoadUnmetDataInputs.py:27
gaudirun.s
string s
Definition: gaudirun.py:253
CnvFactory
Definition: Converter.h:161
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:98
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
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:142
Converter::m_dataProvider
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:125