The Gaudi Framework  v33r0 (d5ea422b)
Converter.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_CONVERTER_H
12 #define GAUDIKERNEL_CONVERTER_H
13 
14 // generic experiment headers
16 #include "GaudiKernel/IConverter.h"
19 #include "GaudiKernel/IService.h"
21 
22 // Forward declarations
23 class IMessageSvc;
24 class IRegistry;
25 
34 class GAUDI_API Converter : public implements<IConverter> {
35 public:
36  using Factory = Gaudi::PluginService::Factory<IConverter*( ISvcLocator* )>;
37 
39  StatusCode initialize() override;
40 
42  StatusCode finalize() override;
43 
45  StatusCode setDataProvider( IDataProviderSvc* svc ) override;
46 
48  SmartIF<IDataProviderSvc>& dataProvider() const override;
49 
51  StatusCode setConversionSvc( IConversionSvc* svc ) override;
52 
54  SmartIF<IConversionSvc>& conversionSvc() const override;
55 
57  StatusCode setAddressCreator( IAddressCreator* creator ) override;
58 
60  SmartIF<IAddressCreator>& addressCreator() const override;
61 
63  const CLID& objType() const override;
64 
66  // MSF: Masked to generate compiler error due to interface change
67  virtual long i_repSvcType() const;
68 
70  StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
71 
73  StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
74 
76  StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
77 
79  StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
80 
82  StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
83 
85  StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
86 
88  StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
89 
91  StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
92 
94  Converter( long storage_type, const CLID& class_type, ISvcLocator* svc = 0 );
95 
97  template <class T>
98  StatusCode service( const std::string& name, T*& psvc, bool createIf = false ) const {
99  return service_i( name, createIf, T::interfaceID(), (void**)&psvc );
100  }
101 
103  template <class T>
104  StatusCode service( const std::string& type, const std::string& name, T*& psvc ) const {
105  return service_i( type, name, T::interfaceID(), reinterpret_cast<void**>( &psvc ) );
106  }
107 
109  SmartIF<IService> service( const std::string& name, const bool createIf = true ) const;
110 
111 protected:
113  SmartIF<ISvcLocator>& serviceLocator() const;
115  SmartIF<IMessageSvc>& msgSvc() const;
117  SmartIF<IDataManagerSvc>& dataManager() const;
118 
119 private:
136 
138  StatusCode service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const;
139  StatusCode service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
140  void** ppSvc ) const;
141 };
142 
143 // Identified class for converters' factories
144 class GAUDI_API ConverterID final {
145 public:
146  ConverterID( long stype, CLID clid ) : m_stype( stype ), m_clid( clid ) {}
147  inline bool operator==( const ConverterID& id ) const { return m_stype == id.m_stype && m_clid == id.m_clid; }
148 
149 private:
150  friend std::ostream& operator<<( std::ostream&, const ConverterID& );
151  long m_stype;
153 };
154 
156  return s << "CNV_" << id.m_stype << "_" << id.m_clid;
157 }
158 
159 // Macro to declare component factories
160 #define DECLARE_CONVERTER( x ) DECLARE_COMPONENT_WITH_ID( x, ConverterID( x::storageType(), x::classID() ) )
161 
162 #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
Base class used to implement the interfaces.
Definition: implements.h:19
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
The data converters are responsible to translate data from one representation into another.
Definition: IConverter.h:68
CLID m_clid
Definition: Converter.h:152
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:104
bool operator==(const ConverterID &id) const
Definition: Converter.h:147
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:129
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:98
IAddressCreator interface definition.
std::ostream & operator<<(std::ostream &s, const ConverterID &id)
Definition: Converter.h:155
Gaudi::PluginService::Factory< IConverter *(ISvcLocator *)> Factory
Definition: Converter.h:36
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:135
long m_stype
Definition: Converter.h:151
Data provider interface definition.
STL class.
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:131
Interface ID class.
Definition: IInterface.h:39
long m_storageType
Storage type.
Definition: Converter.h:121
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:47
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:32
ConverterID(long stype, CLID clid)
Definition: Converter.h:146
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
Converter base class.
Definition: Converter.h:34
string s
Definition: gaudirun.py:328
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:81
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
STL class.
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:127