The Gaudi Framework  master (37c0b60a)
Converter.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 // Include Files
13 #include <GaudiKernel/Converter.h>
21 
23 const CLID& Converter::objType() const { return m_classType; }
24 
26 long Converter::i_repSvcType() const { return m_storageType; }
27 
30 
33 
36 
39 
42 
45 
48 
51 
54  // Get a reference to the Message Service
55  if ( !msgSvc() ) { return StatusCode::FAILURE; }
56  return StatusCode::SUCCESS;
57 }
58 
61  // release services
62  m_messageSvc = nullptr;
63  m_dataManager = nullptr;
64  m_dataProvider = nullptr;
65  m_conversionSvc = nullptr;
66  m_addressCreator = nullptr;
67  return StatusCode::SUCCESS;
68 }
69 
72  m_dataProvider = svc;
73  m_dataManager = svc;
74  return StatusCode::SUCCESS;
75 }
76 
79 
82 
85  m_conversionSvc = svc;
86  return StatusCode::SUCCESS;
87 }
88 
91 
95  return StatusCode::SUCCESS;
96 }
97 
100 
103 
106  if ( !m_messageSvc ) {
108  if ( !m_messageSvc ) { throw GaudiException( "Service [MessageSvc] not found", "Converter", StatusCode::FAILURE ); }
109  }
110  return m_messageSvc;
111 }
112 
114 Converter::Converter( long storage_type, const CLID& class_type, ISvcLocator* svc )
115  : m_storageType( storage_type ), m_classType( class_type ), m_svcLocator( svc ) {}
116 
117 StatusCode Converter::service_i( const std::string& svcName, bool createIf, const InterfaceID& iid,
118  void** ppSvc ) const {
119  // Check for name of conversion service
121  if ( cnvsvc ) {
122  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
123  return helper.getService( svcName, createIf, iid, ppSvc );
124  }
125  return StatusCode::FAILURE;
126 }
127 
128 StatusCode Converter::service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
129  void** ppSvc ) const {
130  // Check for name of conversion service
132  if ( cnvsvc ) {
133  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
134  return helper.createService( svcType, svcName, iid, ppSvc );
135  }
136  return StatusCode::FAILURE;
137 }
138 
139 SmartIF<IService> Converter::service( const std::string& name, const bool createIf ) const {
141  SmartIF<IService> svc;
142  if ( cnvsvc ) {
143  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
144  svc = helper.service( name, false, createIf );
145  }
146  return svc;
147 }
ServiceLocatorHelper::service
SmartIF< IService > service(std::string_view name, const bool quiet=false, const bool createIf=true) const
Definition: ServiceLocatorHelper.cpp:50
Converter::m_conversionSvc
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:133
Converter::dataProvider
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:78
IAddressCreator
Definition: IAddressCreator.h:38
std::string
STL class.
Converter::updateObjRefs
StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an updated transient object.
Definition: Converter.cpp:38
Converter::fillObjRefs
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the created transient object.
Definition: Converter.cpp:32
GaudiException.h
IOpaqueAddress
Definition: IOpaqueAddress.h:33
ISvcLocator
Definition: ISvcLocator.h:46
GaudiException
Definition: GaudiException.h:31
Converter::setAddressCreator
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: Converter.cpp:93
Converter::fillRepRefs
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the converted object.
Definition: Converter.cpp:44
IMessageSvc.h
IDataProviderSvc.h
Converter::addressCreator
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: Converter.cpp:99
Converter::updateObj
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Update the transient object from the other representation.
Definition: Converter.cpp:35
Converter.h
Converter::setDataProvider
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition: Converter.cpp:71
INamedInterface.h
Converter::dataManager
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition: Converter.cpp:81
StatusCode
Definition: StatusCode.h:65
Converter::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:127
Converter::m_dataProvider
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:129
Converter::conversionSvc
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition: Converter.cpp:90
Converter::m_dataManager
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:131
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes
Definition: ServiceLocatorHelper.h:27
Write.creator
creator
Definition: Write.py:23
Converter::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:102
ServiceLocatorHelper::getService
StatusCode getService(std::string_view name, bool createIf, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.h:52
SmartIF< IDataProviderSvc >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
Converter::i_repSvcType
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: Converter.cpp:26
Converter::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:23
Converter::Converter
Converter(long storage_type, const CLID &class_type, ISvcLocator *svc=0)
Standard Constructor.
Definition: Converter.cpp:114
Converter::setConversionSvc
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
Definition: Converter.cpp:84
Converter::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:135
Converter::updateRepRefs
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an already converted object.
Definition: Converter.cpp:50
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Converter::m_messageSvc
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:137
Converter::service
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:99
ServiceLocatorHelper.h
Converter::service_i
StatusCode service_i(const std::string &svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of legacy service method
Definition: Converter.cpp:117
DataObject
Definition: DataObject.h:36
Converter::m_storageType
long m_storageType
Storage type.
Definition: Converter.h:123
IDataProviderSvc
Definition: IDataProviderSvc.h:53
InterfaceID
Definition: IInterface.h:39
Converter::initialize
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:53
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:105
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ISvcLocator.h
ConversionSvc.h
Converter::m_classType
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:125
ServiceLocatorHelper::createService
StatusCode createService(std::string_view name, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.cpp:33
Converter::createObj
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition: Converter.cpp:29
Converter::createRep
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Convert the transient object to the requested representation.
Definition: Converter.cpp:41
IDataManagerSvc.h
Converter::finalize
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:60
Converter::updateRep
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the converted representation of a transient object.
Definition: Converter.cpp:47
IConversionSvc
Definition: IConversionSvc.h:47