| The Gaudi Framework v32r1 (f65d50dc)

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 public:
26 using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>;
27
29 StatusCode initialize() override;
30
32 StatusCode finalize() override;
33
35 StatusCode setDataProvider( IDataProviderSvc* svc ) override;
36
38 SmartIF<IDataProviderSvc>& dataProvider() const override;
39
41 StatusCode setConversionSvc( IConversionSvc* svc ) override;
42
44 SmartIF<IConversionSvc>& conversionSvc() const override;
45
47 StatusCode setAddressCreator( IAddressCreator* creator ) override;
48
50 SmartIF<IAddressCreator>& addressCreator() const override;
51
53 const CLID& objType() const override;
54
56 // MSF: Masked to generate compiler error due to interface change
57 virtual long i_repSvcType() const;
58
60 StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
61
63 StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
64
66 StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
67
69 StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
70
72 StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
73
75 StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
76
78 StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
79
81 StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
82
84 Converter( long storage_type, const CLID& class_type, ISvcLocator* svc = 0 );
85
87 template <class T>
88 StatusCode service( const std::string& name, T*& psvc, bool createIf = false ) const {
89 return service_i( name, createIf, T::interfaceID(), (void**)&psvc );
90 }
91
93 template <class T>
94 StatusCode service( const std::string& type, const std::string& name, T*& psvc ) const {
95 return service_i( type, name, T::interfaceID(), reinterpret_cast<void**>( &psvc ) );
96 }
97
99 SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
100
101 protected:
103 SmartIF<ISvcLocator>& serviceLocator() const;
105 SmartIF<IMessageSvc>& msgSvc() const;
107 SmartIF<IDataManagerSvc>& dataManager() const;
108
109 private:
111 long m_storageType;
113 const CLID m_classType;
115 mutable SmartIF<IAddressCreator> m_addressCreator;
117 mutable SmartIF<IDataProviderSvc> m_dataProvider;
119 mutable SmartIF<IDataManagerSvc> m_dataManager;
121 mutable SmartIF<IConversionSvc> m_conversionSvc;
123 mutable SmartIF<ISvcLocator> m_svcLocator;
125 mutable SmartIF<IMessageSvc> m_messageSvc;
126
128 StatusCode service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const;
129 StatusCode service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
130 void** ppSvc ) const;
131 };
132
133 // Identified class for converters' factories
134 class GAUDI_API ConverterID final {
135 public:
136 ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
137 inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
138
139 private:
140 friend std::ostream& operator<<( std::ostream&, const ConverterID& );
141 long m_stype;
142 CLID m_clid;
143 };
144
145 inline std::ostream& operator<<( std::ostream& s, const ConverterID& id ) {
146 return s << "CNV_" << id.m_stype << "_" << id.m_clid;
147 }
148
149 // Macro to declare component factories
150 #define DECLARE_CONVERTER( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
151
152 #endif // GAUDIKERNEL_CONVERTER_H
Converter::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:115
Converter::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:123
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:58
ConverterID::m_clid
CLID m_clid
Definition: Converter.h:142
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
IConversionSvc
Definition: IConversionSvc.h:37
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't already exist.
Definition: Converter.h:94
ConversionSvc.h
ConverterID::operator==
bool operator==(const ConverterID &id) const
Definition: Converter.h:137
Converter::m_dataManager
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:119
Converter::service
StatusCode service(const std::string &name, T *&psvc, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
Definition: Converter.h:88
IAddressCreator
IAddressCreator interface definition.
Definition: IAddressCreator.h:28
operator<<
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:145
Converter::Factory
Gaudi::PluginService::Factory< IConverter *(ISvcLocator *)> Factory
Definition: Converter.h:26
Converter::m_messageSvc
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:125
ConverterID::m_stype
long m_stype
Definition: Converter.h:141
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:43
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:67
std::string
STL class.
Converter::m_conversionSvc
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:121
InterfaceID
Interface ID class.
Definition: IInterface.h:29
IDataManagerSvc.h
IDataProviderSvc.h
Converter::m_storageType
long m_storageType
Storage type.
Definition: Converter.h:111
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
gaudirun.type
type
Definition: gaudirun.py:142
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:37
Converter::m_classType
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:113
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:136
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Converter
Converter base class.
Definition: Converter.h:24
IService.h
gaudirun.s
string s
Definition: gaudirun.py:316
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
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:134
Converter::m_dataProvider
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:117