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:
28 
30  virtual StatusCode initialize();
31 
33  virtual StatusCode finalize();
34 
36  virtual StatusCode setDataProvider(IDataProviderSvc* svc);
37 
39  virtual SmartIF<IDataProviderSvc>& dataProvider() const;
40 
42  virtual StatusCode setConversionSvc(IConversionSvc* svc);
43 
45  virtual SmartIF<IConversionSvc>& conversionSvc() const;
46 
48  virtual StatusCode setAddressCreator(IAddressCreator* creator);
49 
51  virtual SmartIF<IAddressCreator>& addressCreator() const;
52 
54  virtual const CLID& objType() const;
55 
57  // MSF: Masked to generate compiler error due to interface change
58  virtual long i_repSvcType() const;
59 
61  virtual StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject);
62 
64  virtual StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
65 
67  virtual StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject);
68 
70  virtual StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject);
71 
73  virtual StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress);
74 
76  virtual StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject);
77 
79  virtual StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject);
80 
82  virtual StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject);
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  return service_i(name, createIf, T::interfaceID(), (void**)&psvc);
91  }
92 
94  template <class T>
95  StatusCode service( const std::string& type, const std::string& name, T*& psvc) const {
96  return service_i(type, name, T::interfaceID(), (void**)&psvc);
97  }
98 
100  SmartIF<IService> service(const std::string& name, const bool createIf = true) const;
101 
102 protected:
103 
105  virtual ~Converter();
106 
108  SmartIF<ISvcLocator>& serviceLocator() const;
110  SmartIF<IMessageSvc>& msgSvc() const;
111  // Obsoleted name, kept due to the backwards compatibility
112  SmartIF<IMessageSvc>& messageService() const;
114  SmartIF<IDataManagerSvc>& dataManager() const;
115 
116 private:
117 
134 
136  StatusCode service_i(const std::string& svcName,
137  bool createIf,
138  const InterfaceID& iid,
139  void** ppSvc) const;
140  StatusCode service_i(const std::string& svcType,
141  const std::string& svcName,
142  const InterfaceID& iid,
143  void** ppSvc) const;
144 };
145 
146 
147 // Identified class for converters' factories
149 public:
150  ConverterID( long stype, CLID clid ) : m_stype(stype), m_clid(clid) {}
152  inline bool operator ==(const ConverterID& id) const {
153  return m_stype == id.m_stype && m_clid == id.m_clid;
154  }
155 private:
156  friend std::ostream& operator << ( std::ostream&, const ConverterID&);
157  long m_stype;
159 };
160 
161 inline std::ostream& operator << ( std::ostream& s, const ConverterID& id) {
162  return s << "CNV_" << id.m_stype << "_" << id.m_clid;
163 }
164 
165 
166 #ifndef GAUDI_NEW_PLUGIN_SERVICE
167 template <class T>
168 class CnvFactory {
169 public:
170  template <typename S>
171  static typename S::ReturnType create(typename S::Arg1Type a1) {
172  return new T(a1);
173  }
174 };
175 
176 // Macro to declare component factories
177 #define DECLARE_CONVERTER_FACTORY(x) \
178  DECLARE_FACTORY_WITH_CREATOR_AND_ID(x, CnvFactory< x >, \
179  ConverterID(x::storageType(), x::classID()), Converter::Factory)
180 #define DECLARE_NAMESPACE_CONVERTER_FACTORY(n, x) \
181  DECLARE_CONVERTER_FACTORY(n::x)
182 
183 #else
184 
185 // Macro to declare component factories
186 #define DECLARE_CONVERTER_FACTORY(x) \
187  DECLARE_COMPONENT_WITH_ID(x, ConverterID(x::storageType(), x::classID()))
188 #define DECLARE_NAMESPACE_CONVERTER_FACTORY(n, x) \
189  DECLARE_CONVERTER_FACTORY(n::x)
190 
191 #endif
192 
193 #endif // GAUDIKERNEL_CONVERTER_H
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:123
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:131
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:158
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:127
IAddressCreator interface definition.
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:161
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:133
long m_stype
Definition: Converter.h:157
Data provider interface definition.
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:129
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
Gaudi::PluginService::Factory1< IConverter *, ISvcLocator * > Factory
Definition: Converter.h:27
long m_storageType
Storage type.
Definition: Converter.h:119
string type
Definition: gaudirun.py:126
static S::ReturnType create(typename S::Arg1Type a1)
Definition: Converter.h:171
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:89
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:121
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:150
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
Converter base class.
Definition: Converter.h:24
string s
Definition: gaudirun.py:210
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:95
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
Class wrapping the signature for a factory with 1 argument.
Definition: PluginService.h:64
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:125