The Gaudi Framework  v33r0 (d5ea422b)
ConversionSvc.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_CONVERSIONSVC_H
12 #define GAUDIKERNEL_CONVERSIONSVC_H 1
13 
14 // Include files
18 #include "GaudiKernel/Kernel.h"
19 #include "GaudiKernel/Service.h"
20 #include <algorithm>
21 #include <utility>
22 #include <vector>
23 
55 class GAUDI_API ConversionSvc : public extends<Service, IConversionSvc, IAddressCreator> {
56  class WorkerEntry final {
59 
60  public:
61  WorkerEntry( const CLID& cl, IConverter* cnv ) : m_class( cl ), m_converter( cnv ) {
62  if ( m_converter ) m_converter->addRef();
63  }
64 
66  if ( m_converter ) m_converter->release();
67  }
68 
69  WorkerEntry( WorkerEntry&& orig ) noexcept
70  : m_class{orig.m_class}, m_converter{std::exchange( orig.m_converter, nullptr )} {}
71 
72  WorkerEntry& operator=( WorkerEntry&& orig ) noexcept {
73  m_class = orig.m_class;
74  std::swap( m_converter, orig.m_converter );
75  return *this;
76  }
77 
78  WorkerEntry( const WorkerEntry& copy ) = delete;
79  WorkerEntry& operator=( const WorkerEntry& copy ) = delete;
80 
81  IConverter* converter() { return m_converter; }
82 
83  const CLID& clID() const { return m_class; }
84  };
85 
86 public:
88  ConversionSvc( const std::string& name, ISvcLocator* svc, long type );
89 
91  ConversionSvc( const ConversionSvc& ) = delete;
92  ConversionSvc& operator=( const ConversionSvc& ) = delete;
93 
95  StatusCode initialize() override;
96 
98  StatusCode finalize() override;
99 
101  long repSvcType() const override;
102 
104  const CLID& objType() const override;
105 
110  StatusCode setDataProvider( IDataProviderSvc* pService ) override;
111 
115  SmartIF<IDataProviderSvc>& dataProvider() const override;
116 
118  StatusCode setConversionSvc( IConversionSvc* svc ) override;
119 
121  SmartIF<IConversionSvc>& conversionSvc() const override;
122 
124  StatusCode setAddressCreator( IAddressCreator* creator ) override;
125 
127  SmartIF<IAddressCreator>& addressCreator() const override;
128 
130  StatusCode createObj( IOpaqueAddress* pAddress, DataObject*& refpObject ) override;
131 
133  StatusCode fillObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
134 
136  StatusCode updateObj( IOpaqueAddress* pAddress, DataObject* refpObject ) override;
137 
139  StatusCode updateObjRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
140 
142  StatusCode createRep( DataObject* pObject, IOpaqueAddress*& refpAddress ) override;
143 
145  StatusCode fillRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
146 
148  StatusCode updateRep( IOpaqueAddress* pAddress, DataObject* pObject ) override;
149 
151  StatusCode updateRepRefs( IOpaqueAddress* pAddress, DataObject* pObject ) override;
152 
154  StatusCode addConverter( const CLID& clid ) override;
155 
157  StatusCode addConverter( IConverter* pConverter ) override;
158 
160  StatusCode removeConverter( const CLID& clid ) override;
161 
163  IConverter* converter( const CLID& wanted ) override;
164 
166  StatusCode connectOutput( const std::string& outputFile, const std::string& openMode ) override;
167 
169  StatusCode connectOutput( const std::string& output ) override;
170 
172  StatusCode commitOutput( const std::string& output, bool do_commit ) override;
173 
175  StatusCode createAddress( long svc_type, const CLID& clid, const std::string* par, const unsigned long* ip,
176  IOpaqueAddress*& refpAddress ) override;
177 
179  StatusCode convertAddress( const IOpaqueAddress* pAddress, std::string& refAddress ) override;
180 
182  StatusCode createAddress( long svc_type, const CLID& clid, const std::string& refAddress,
183  IOpaqueAddress*& refpAddress ) override;
184 
186  virtual StatusCode updateServiceState( IOpaqueAddress* pAddress );
187 
188 protected:
190  virtual IConverter* createConverter( long typ, const CLID& clid, const ICnvFactory* fac );
191 
193  virtual StatusCode configureConverter( long typ, const CLID& clid, IConverter* cnv );
194 
196  virtual StatusCode initializeConverter( long typ, const CLID& clid, IConverter* cnv );
197 
199  virtual StatusCode activateConverter( long typ, const CLID& clid, IConverter* cnv );
200 
202  virtual void loadConverter( DataObject* pObject );
203 
205  virtual SmartIF<IAddressCreator>& addressCreator() { return m_addressCreator; }
206 
207 protected:
208  StatusCode makeCall( int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress*& pAddress,
209  DataObject*& pObject );
210 
218  long m_type;
221 };
222 #endif // GAUDIKERNEL_CONVERSIONSVC_H
IConverter * converter()
Definition: ConversionSvc.h:81
const CLID & clID() const
Definition: ConversionSvc.h:83
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:35
The data converters are responsible to translate data from one representation into another.
Definition: IConverter.h:68
T swap(T... args)
IAddressCreator interface definition.
~WorkerEntry()
Definition: ConversionSvc.h:65
Definition: ConversionSvc.h:56
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Data provider interface definition.
STL class.
CLID m_class
Definition: ConversionSvc.h:57
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
WorkerEntry(const CLID &cl, IConverter *cnv)
Definition: ConversionSvc.h:61
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
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:20
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:55
std::vector< WorkerEntry > m_workers
List of conversion workers.
#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
WorkerEntry(WorkerEntry &&orig) noexcept
Definition: ConversionSvc.h:69
IConverter * m_converter
Definition: ConversionSvc.h:58
WorkerEntry & operator=(WorkerEntry &&orig) noexcept
Definition: ConversionSvc.h:72