The Gaudi Framework  v28r3 (cc1cf868)
ConversionSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_CONVERSIONSVC_H
2 #define GAUDIKERNEL_CONVERSIONSVC_H 1
3 
4 // Include files
5 #include <vector>
6 #include <algorithm>
7 #include <utility>
8 #include "GaudiKernel/Kernel.h"
9 #include "GaudiKernel/Service.h"
13 
14 
46 class GAUDI_API ConversionSvc: public extends<Service,
47  IConversionSvc,
48  IAddressCreator>
49 {
50  class WorkerEntry final {
53  public:
54  WorkerEntry(const CLID& cl, IConverter* cnv)
55  : m_class(cl), m_converter(cnv) {
56  if (m_converter) m_converter->addRef();
57  }
58 
60  if (m_converter) m_converter->release();
61  }
62 
63  WorkerEntry(WorkerEntry&& orig) noexcept
64  : m_class{ orig.m_class },
65  m_converter{ std::exchange( orig.m_converter, nullptr ) } {
66  }
67 
68  WorkerEntry& operator=(WorkerEntry&& orig) noexcept {
69  m_class = orig.m_class;
70  std::swap( m_converter, orig.m_converter );
71  return *this;
72  }
73 
74  WorkerEntry(const WorkerEntry& copy) = delete;
75  WorkerEntry& operator = (const WorkerEntry& copy) = delete;
76 
78  return m_converter;
79  }
80 
81  const CLID& clID() const {
82  return m_class;
83  }
84  };
85 
86 
87 public:
89  ConversionSvc(const std::string& name, ISvcLocator* svc, long type);
90 
92  ConversionSvc(const ConversionSvc&) = delete;
93  ConversionSvc& operator= (const ConversionSvc&) = delete;
94 
95 
97  StatusCode initialize() override;
98 
100  StatusCode finalize() override;
101 
103  long repSvcType() const override;
104 
106  const CLID& objType() const override;
107 
112  StatusCode setDataProvider(IDataProviderSvc* pService) override;
113 
117  SmartIF<IDataProviderSvc>& dataProvider() const override;
118 
120  StatusCode setConversionSvc(IConversionSvc* svc) override;
121 
123  SmartIF<IConversionSvc>& conversionSvc() const override;
124 
126  StatusCode setAddressCreator(IAddressCreator* creator) override;
127 
129  SmartIF<IAddressCreator>& addressCreator() const override;
130 
132  StatusCode createObj(IOpaqueAddress* pAddress,DataObject*& refpObject) override;
133 
135  StatusCode fillObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
136 
138  StatusCode updateObj(IOpaqueAddress* pAddress, DataObject* refpObject) override;
139 
141  StatusCode updateObjRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
142 
144  StatusCode createRep(DataObject* pObject, IOpaqueAddress*& refpAddress) override;
145 
147  StatusCode fillRepRefs(IOpaqueAddress* pAddress,DataObject* pObject) override;
148 
150  StatusCode updateRep(IOpaqueAddress* pAddress, DataObject* pObject) override;
151 
153  StatusCode updateRepRefs(IOpaqueAddress* pAddress, DataObject* pObject) override;
154 
156  StatusCode addConverter(const CLID& clid) override;
157 
159  StatusCode addConverter(IConverter* pConverter) override;
160 
162  StatusCode removeConverter(const CLID& clid) override;
163 
165  IConverter* converter(const CLID& wanted) override;
166 
168  StatusCode connectOutput(const std::string& outputFile, const std::string& openMode) override;
169 
171  StatusCode connectOutput(const std::string& output) override;
172 
174  StatusCode commitOutput(const std::string& output, bool do_commit) override;
175 
177  StatusCode createAddress( long svc_type,
178  const CLID& clid,
179  const std::string* par,
180  const unsigned long* ip,
181  IOpaqueAddress*& refpAddress) override;
182 
184  StatusCode convertAddress( const IOpaqueAddress* pAddress, std::string& refAddress) override;
185 
187  StatusCode createAddress( long svc_type,
188  const CLID& clid,
189  const std::string& refAddress,
190  IOpaqueAddress*& refpAddress) override;
191 
193  virtual StatusCode updateServiceState(IOpaqueAddress* pAddress);
194 
195 protected:
196 
198  virtual IConverter* createConverter(long typ, const CLID& clid, const ICnvFactory* fac);
199 
201  virtual StatusCode configureConverter(long typ, const CLID& clid, IConverter* cnv);
202 
204  virtual StatusCode initializeConverter(long typ, const CLID& clid, IConverter* cnv);
205 
207  virtual StatusCode activateConverter(long typ, const CLID& clid, IConverter* cnv);
208 
210  virtual void loadConverter(DataObject* pObject);
211 
214  return m_addressCreator;
215  }
216 
217 protected:
218  StatusCode makeCall( int typ,
219  bool ignore_add,
220  bool ignore_obj,
221  bool update,
222  IOpaqueAddress*& pAddress,
223  DataObject*& pObject);
224 
232  long m_type;
235 
236 };
237 #endif // GAUDIKERNEL_CONVERSIONSVC_H
IConverter * converter()
Definition: ConversionSvc.h:77
virtual SmartIF< IAddressCreator > & addressCreator()
Retrieve address creation interface.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
The data converters are responsible to translate data from one representation into another...
Definition: IConverter.h:57
T swap(T...args)
IAddressCreator interface definition.
~WorkerEntry()
Definition: ConversionSvc.h:59
const CLID & clID() const
Definition: ConversionSvc.h:81
Definition: ConversionSvc.h:50
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Data provider interface definition.
PropertyMgr & operator=(const PropertyMgr &)=delete
STL class.
CLID m_class
Definition: ConversionSvc.h:51
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
WorkerEntry(const CLID &cl, IConverter *cnv)
Definition: ConversionSvc.h:54
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
SmartIF< IDataProviderSvc > m_dataSvc
Pointer to data provider service.
STL class.
virtual unsigned long release()=0
Release Interface instance.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
SmartIF< IConversionSvc > m_cnvSvc
Pointer to the IConversionSvc interface of this.
long m_type
Conversion service type.
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
Opaque address interface definition.
Base class for all conversion services.
Definition: ConversionSvc.h:46
std::vector< WorkerEntry > m_workers
List of conversion workers.
#define GAUDI_API
Definition: Kernel.h:107
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
WorkerEntry(WorkerEntry &&orig) noexcept
Definition: ConversionSvc.h:63
IConverter * m_converter
Definition: ConversionSvc.h:52
WorkerEntry & operator=(WorkerEntry &&orig) noexcept
Definition: ConversionSvc.h:68