The Gaudi Framework  v30r3 (a5ef0a68)
Converter.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_CONVERTER_H
2 #define GAUDIKERNEL_CONVERTER_H
3 
4 // generic experiment headers
9 #include "GaudiKernel/IService.h"
11 
12 // Forward declarations
13 class IMessageSvc;
14 class IRegistry;
15 
24 class GAUDI_API Converter : public implements<IConverter>
25 {
26 public:
27  using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>;
28 
30  StatusCode initialize() override;
31 
33  StatusCode finalize() override;
34 
36  StatusCode setDataProvider( IDataProviderSvc* svc ) override;
37 
39  SmartIF<IDataProviderSvc>& dataProvider() const override;
40 
42  StatusCode setConversionSvc( IConversionSvc* svc ) override;
43 
45  SmartIF<IConversionSvc>& conversionSvc() const override;
46 
48  StatusCode setAddressCreator( IAddressCreator* creator ) override;
49 
51  SmartIF<IAddressCreator>& addressCreator() const override;
52 
54  const CLID& objType() const override;
55 
57  // MSF: Masked to generate compiler error due to interface change
58  virtual long i_repSvcType() const;
59 
61  StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
62 
64  StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
65 
67  StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
68 
70  StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
71 
73  StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
74 
76  StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
77 
79  StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
80 
82  StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
83 
85  Converter( long storage_type, const CLID& class_type, ISvcLocator* svc = 0 );
86 
88  template <class T>
89  StatusCode service( const std::string& name, T*& psvc, bool createIf = false ) const
90  {
91  return service_i( name, createIf, T::interfaceID(), (void**)&psvc );
92  }
93 
95  template <class T>
96  StatusCode service( const std::string& type, const std::string& name, T*& psvc ) const
97  {
98  return service_i( type, name, T::interfaceID(), reinterpret_cast<void**>( &psvc ) );
99  }
100 
102  SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
103 
104 protected:
106  SmartIF<ISvcLocator>& serviceLocator() const;
108  SmartIF<IMessageSvc>& msgSvc() const;
110  SmartIF<IDataManagerSvc>& dataManager() const;
111 
112 private:
129 
131  StatusCode service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const;
132  StatusCode service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
133  void** ppSvc ) const;
134 };
135 
136 // Identified class for converters' factories
138 {
139 public:
140  ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
141  inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
142 
143 private:
144  friend std::ostream& operator<<( std::ostream&, const ConverterID& );
145  long m_stype;
147 };
148 
150 {
151  return s << "CNV_" << id.m_stype << "_" << id.m_clid;
152 }
153 
154 // Macro to declare component factories
155 #define DECLARE_CONVERTER( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
156 
157 #endif // GAUDIKERNEL_CONVERTER_H
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:118
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:126
Base class used to implement the interfaces.
Definition: implements.h:9
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
CLID m_clid
Definition: Converter.h:146
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:122
IAddressCreator interface definition.
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:149
Gaudi::PluginService::Factory< IConverter *(ISvcLocator *)> Factory
Definition: Converter.h:27
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:128
long m_stype
Definition: Converter.h:145
Data provider interface definition.
STL class.
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:124
Interface ID class.
Definition: IInterface.h:29
long m_storageType
Storage type.
Definition: Converter.h:114
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
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:89
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:116
bool operator==(const ConverterID &id) const
Definition: Converter.h:141
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
ConverterID(long stype, CLID clid)
Definition: Converter.h:140
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Converter base class.
Definition: Converter.h:24
string s
Definition: gaudirun.py:253
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:96
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:104
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
STL class.
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:120