The Gaudi Framework  master (d98a2936)
Converter.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 \***********************************************************************************/
12 #include <GaudiKernel/Converter.h>
20 
22 const CLID& Converter::objType() const { return m_classType; }
23 
25 long Converter::i_repSvcType() const { return m_storageType; }
26 
29 
32 
35 
38 
41 
44 
47 
50 
53  // Get a reference to the Message Service
54  if ( !msgSvc() ) { return StatusCode::FAILURE; }
55  return StatusCode::SUCCESS;
56 }
57 
60  // release services
61  m_messageSvc = nullptr;
62  m_dataManager = nullptr;
63  m_dataProvider = nullptr;
64  m_conversionSvc = nullptr;
65  m_addressCreator = nullptr;
66  return StatusCode::SUCCESS;
67 }
68 
71  m_dataProvider = svc;
72  m_dataManager = svc;
73  return StatusCode::SUCCESS;
74 }
75 
78 
81 
84  m_conversionSvc = svc;
85  return StatusCode::SUCCESS;
86 }
87 
90 
94  return StatusCode::SUCCESS;
95 }
96 
99 
102 
105  if ( !m_messageSvc ) {
107  if ( !m_messageSvc ) { throw GaudiException( "Service [MessageSvc] not found", "Converter", StatusCode::FAILURE ); }
108  }
109  return m_messageSvc;
110 }
111 
113 Converter::Converter( long storage_type, const CLID& class_type, ISvcLocator* svc )
114  : m_storageType( storage_type ), m_classType( class_type ), m_svcLocator( svc ) {}
115 
116 SmartIF<IService> Converter::service( const std::string& name, const bool createIf ) const {
118  SmartIF<IService> svc;
119  if ( cnvsvc ) {
120  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
121  svc = helper.service( name, false, createIf );
122  }
123  return svc;
124 }
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:118
Converter::dataProvider
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:77
IAddressCreator
Definition: IAddressCreator.h:33
Converter::updateObjRefs
StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an updated transient object.
Definition: Converter.cpp:37
Converter::fillObjRefs
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the created transient object.
Definition: Converter.cpp:31
GaudiException.h
IOpaqueAddress
Definition: IOpaqueAddress.h:28
ISvcLocator
Definition: ISvcLocator.h:42
GaudiException
Definition: GaudiException.h:29
Converter::setAddressCreator
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: Converter.cpp:92
Converter::fillRepRefs
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the converted object.
Definition: Converter.cpp:43
IMessageSvc.h
IDataProviderSvc.h
Converter::addressCreator
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: Converter.cpp:98
Converter::updateObj
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Update the transient object from the other representation.
Definition: Converter.cpp:34
Converter.h
Converter::setDataProvider
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition: Converter.cpp:70
INamedInterface.h
Converter::dataManager
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition: Converter.cpp:80
StatusCode
Definition: StatusCode.h:64
Converter::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:112
Converter::m_dataProvider
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:114
Converter::conversionSvc
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition: Converter.cpp:89
Converter::m_dataManager
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:116
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes
Definition: ServiceLocatorHelper.h:26
Write.creator
creator
Definition: Write.py:23
Converter::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:101
SmartIF< IDataProviderSvc >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:16
Converter::i_repSvcType
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: Converter.cpp:25
Converter::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:22
Converter::Converter
Converter(long storage_type, const CLID &class_type, ISvcLocator *svc=0)
Standard Constructor.
Definition: Converter.cpp:113
Converter::setConversionSvc
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
Definition: Converter.cpp:83
Converter::service
SmartIF< IService > service(const std::string &name, const bool createIf=true) const
Return a pointer to the service identified by name (or "type/name")
Definition: Converter.cpp:116
Converter::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:120
Converter::updateRepRefs
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an already converted object.
Definition: Converter.cpp:49
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:99
Converter::m_messageSvc
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:122
ServiceLocatorHelper.h
DataObject
Definition: DataObject.h:37
Converter::m_storageType
long m_storageType
Storage type.
Definition: Converter.h:108
IDataProviderSvc
Definition: IDataProviderSvc.h:48
Converter::initialize
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:52
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:104
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
ISvcLocator.h
ConversionSvc.h
Converter::m_classType
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:110
Converter::createObj
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition: Converter.cpp:28
Converter::createRep
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Convert the transient object to the requested representation.
Definition: Converter.cpp:40
IDataManagerSvc.h
Converter::finalize
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:59
Converter::updateRep
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the converted representation of a transient object.
Definition: Converter.cpp:46
IConversionSvc
Definition: IConversionSvc.h:43