| The Gaudi Framework v32r1 (f65d50dc)

Converter.cpp
Go to the documentation of this file.
1 // Include Files
2 #include "GaudiKernel/Converter.h"
3 #include "GaudiKernel/ConversionSvc.h"
4 #include "GaudiKernel/GaudiException.h"
5 #include "GaudiKernel/IDataManagerSvc.h"
6 #include "GaudiKernel/IDataProviderSvc.h"
7 #include "GaudiKernel/IMessageSvc.h"
8 #include "GaudiKernel/INamedInterface.h"
9 #include "GaudiKernel/ISvcLocator.h"
10 #include "GaudiKernel/ServiceLocatorHelper.h"
11
13 const CLID& Converter::objType() const { return m_classType; }
14
16 long Converter::i_repSvcType() const { return m_storageType; }
17
19 StatusCode Converter::createObj( IOpaqueAddress*, DataObject*& ) { return StatusCode::SUCCESS; }
20
22 StatusCode Converter::fillObjRefs( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
23
25 StatusCode Converter::updateObj( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
26
28 StatusCode Converter::updateObjRefs( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
29
31 StatusCode Converter::createRep( DataObject*, IOpaqueAddress*& ) { return StatusCode::SUCCESS; }
32
34 StatusCode Converter::fillRepRefs( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
35
37 StatusCode Converter::updateRep( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
38
40 StatusCode Converter::updateRepRefs( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
41
43 StatusCode Converter::initialize() {
44 // Get a reference to the Message Service
45 if ( !msgSvc() ) { return StatusCode::FAILURE; }
46 return StatusCode::SUCCESS;
47 }
48
50 StatusCode Converter::finalize() {
51 // release services
52 m_messageSvc = nullptr;
53 m_dataManager = nullptr;
54 m_dataProvider = nullptr;
55 m_conversionSvc = nullptr;
56 m_addressCreator = nullptr;
57 return StatusCode::SUCCESS;
58 }
59
61 StatusCode Converter::setDataProvider( IDataProviderSvc* svc ) {
62 m_dataProvider = svc;
63 m_dataManager = svc;
64 return StatusCode::SUCCESS;
65 }
66
68 SmartIF<IDataProviderSvc>& Converter::dataProvider() const { return m_dataProvider; }
69
71 SmartIF<IDataManagerSvc>& Converter::dataManager() const { return m_dataManager; }
72
74 StatusCode Converter::setConversionSvc( IConversionSvc* svc ) {
75 m_conversionSvc = svc;
76 return StatusCode::SUCCESS;
77 }
78
80 SmartIF<IConversionSvc>& Converter::conversionSvc() const { return m_conversionSvc; }
81
83 StatusCode Converter::setAddressCreator( IAddressCreator* creator ) {
84 m_addressCreator = creator;
85 return StatusCode::SUCCESS;
86 }
87
89 SmartIF<IAddressCreator>& Converter::addressCreator() const { return m_addressCreator; }
90
92 SmartIF<ISvcLocator>& Converter::serviceLocator() const { return m_svcLocator; }
93
95 SmartIF<IMessageSvc>& Converter::msgSvc() const {
96 if ( !m_messageSvc ) {
97 m_messageSvc = serviceLocator();
98 if ( !m_messageSvc ) { throw GaudiException( "Service [MessageSvc] not found", "Converter", StatusCode::FAILURE ); }
99 }
100 return m_messageSvc;
101 }
102
104 Converter::Converter( long storage_type, const CLID& class_type, ISvcLocator* svc )
105 : m_storageType( storage_type ), m_classType( class_type ), m_svcLocator( svc ) {}
106
107 StatusCode Converter::service_i( const std::string& svcName, bool createIf, const InterfaceID& iid,
108 void** ppSvc ) const {
109 // Check for name of conversion service
110 SmartIF<INamedInterface> cnvsvc( conversionSvc() );
111 if ( cnvsvc ) {
112 const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
113 return helper.getService( svcName, createIf, iid, ppSvc );
114 }
115 return StatusCode::FAILURE;
116 }
117
118 StatusCode Converter::service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
119 void** ppSvc ) const {
120 // Check for name of conversion service
121 SmartIF<INamedInterface> cnvsvc( conversionSvc() );
122 if ( cnvsvc ) {
123 const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
124 return helper.createService( svcType, svcName, iid, ppSvc );
125 }
126 return StatusCode::FAILURE;
127 }
128
129 SmartIF<IService> Converter::service( const std::string& name, const bool createIf ) const {
130 SmartIF<INamedInterface> cnvsvc( conversionSvc() );
131 SmartIF<IService> svc;
132 if ( cnvsvc ) {
133 const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
134 svc = helper.service( name, false, createIf );
135 }
136 return svc;
137 }
Converter::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:115
Converter::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:123
ServiceLocatorHelper
an helper to share the implementation of service() among the various kernel base classes
Definition: ServiceLocatorHelper.h:17
Converter::Converter
Converter(long storage_type, const CLID &class_type, ISvcLocator *svc=0)
Standard Constructor.
Definition: Converter.cpp:104
SmartIF< IDataProviderSvc >
Converter::conversionSvc
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition: Converter.cpp:80
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
ServiceLocatorHelper::createService
StatusCode createService(const std::string &name, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.cpp:21
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Converter::service_i
StatusCode service_i(const std::string &svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of service method
Definition: Converter.cpp:107
IConversionSvc
Definition: IConversionSvc.h:37
Converter::i_repSvcType
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: Converter.cpp:16
ConversionSvc.h
ServiceLocatorHelper::getService
StatusCode getService(const std::string &name, bool createIf, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.h:41
Converter::setConversionSvc
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
Definition: Converter.cpp:74
Converter::m_dataManager
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:119
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:88
Converter::initialize
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:43
IAddressCreator
IAddressCreator interface definition.
Definition: IAddressCreator.h:28
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Converter::updateRepRefs
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an already converted object.
Definition: Converter.cpp:40
Converter::m_messageSvc
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:125
Converter::createObj
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition: Converter.cpp:19
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:43
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string
STL class.
Converter::m_conversionSvc
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:121
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:95
Converter::finalize
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:50
InterfaceID
Interface ID class.
Definition: IInterface.h:29
Converter::updateRep
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the converted representation of a transient object.
Definition: Converter.cpp:37
INamedInterface.h
IDataManagerSvc.h
IDataProviderSvc.h
Converter::m_storageType
long m_storageType
Storage type.
Definition: Converter.h:111
Converter::fillObjRefs
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the created transient object.
Definition: Converter.cpp:22
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
GaudiException.h
Converter::m_classType
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:113
IMessageSvc.h
Converter::createRep
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Convert the transient object to the requested representation.
Definition: Converter.cpp:31
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Converter::updateObjRefs
StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an updated transient object.
Definition: Converter.cpp:28
Converter::dataProvider
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:68
Converter::setAddressCreator
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: Converter.cpp:83
Converter::setDataProvider
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition: Converter.cpp:61
Converter::addressCreator
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: Converter.cpp:89
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
ServiceLocatorHelper.h
Converter.h
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
Converter::fillRepRefs
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the converted object.
Definition: Converter.cpp:34
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
Converter::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:92
ISvcLocator.h
Converter::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:13
Converter::m_dataProvider
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:117
Converter::dataManager
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition: Converter.cpp:71
Converter::updateObj
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Update the transient object from the other representation.
Definition: Converter.cpp:25