All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Converter.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_CONVERTER_H
2 #define GAUDIKERNEL_CONVERTER_H
3 
4 // generic experiment headers
7 #include "GaudiKernel/IService.h"
11 
12 // Forward declarations
13 class IMessageSvc;
14 class IRegistry;
15 
24 class GAUDI_API Converter : public implements1<IConverter> {
25 public:
26 #ifndef __REFLEX__
29 #endif
30 
32  virtual StatusCode initialize();
33 
35  virtual StatusCode finalize();
36 
38  virtual StatusCode setDataProvider(IDataProviderSvc* svc);
39 
41  virtual SmartIF<IDataProviderSvc>& dataProvider() const;
42 
44  virtual StatusCode setConversionSvc(IConversionSvc* svc);
45 
47  virtual SmartIF<IConversionSvc>& conversionSvc() const;
48 
50  virtual StatusCode setAddressCreator(IAddressCreator* creator);
51 
53  virtual SmartIF<IAddressCreator>& addressCreator() const;
54 
56  virtual const CLID& objType() const;
57 
59  // MSF: Masked to generate compiler error due to interface change
60  virtual long i_repSvcType() const;
61 
63  virtual StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject);
64 
66  virtual StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
67 
69  virtual StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject);
70 
72  virtual StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
73 
75  virtual StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress);
76 
78  virtual StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject);
79 
81  virtual StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject);
82 
84  virtual StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject);
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  virtual ~Converter();
108 
110  SmartIF<ISvcLocator>& serviceLocator() const;
112  SmartIF<IMessageSvc>& msgSvc() const;
113  // Obsoleted name, kept due to the backwards compatibility
114  SmartIF<IMessageSvc>& messageService() const;
116  SmartIF<IDataManagerSvc>& dataManager() const;
117 
118 private:
119 
136 
138  StatusCode service_i(const std::string& svcName,
139  bool createIf,
140  const InterfaceID& iid,
141  void** ppSvc) const;
142  StatusCode service_i(const std::string& svcType,
143  const std::string& svcName,
144  const InterfaceID& iid,
145  void** ppSvc) const;
146 };
147 
148 
149 // Identified class for converters' factories
151 public:
152  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;
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 {
171 public:
172 #ifndef __REFLEX__
173  template <typename S, typename... Args>
174  static typename S::ReturnType create(Args... a1) {
175  return new T(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< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:125
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:133
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
CLID m_clid
Definition: Converter.h:160
static S::ReturnType create(Args...a1)
Definition: Converter.h:174
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:129
IAddressCreator interface definition.
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:163
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:135
long m_stype
Definition: Converter.h:159
Data provider interface definition.
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:131
Gaudi::InterfaceId< IInterface, 0, 0 > iid
Interface ID.
Definition: IInterface.h:164
Base class used to implement the interfaces.
Definition: implements.h:133
Interface ID class.
Definition: IInterface.h:55
long m_storageType
Storage type.
Definition: Converter.h:121
string type
Definition: gaudirun.py:126
bool operator==(const GaudiUtils::Allocator< T1 > &, const GaudiUtils::Allocator< T2 > &)
Definition: Allocator.h:249
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
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:91
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:123
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:152
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
Converter base class.
Definition: Converter.h:24
Class wrapping the signature for a factory with any number of arguments.
Definition: PluginService.h:47
string s
Definition: gaudirun.py:210
Gaudi::PluginService::Factory< IConverter *, ISvcLocator * > Factory
Definition: Converter.h:28
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:97
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:108
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:127