| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Converter.cpp
Go to the documentation of this file.
1 // Include Files
2 #include "GaudiKernel/Converter.h"
3 #include "GaudiKernel/INamedInterface.h"
4 #include "GaudiKernel/ISvcLocator.h"
5 #include "GaudiKernel/IMessageSvc.h"
6 #include "GaudiKernel/IDataManagerSvc.h"
7 #include "GaudiKernel/IDataProviderSvc.h"
8 #include "GaudiKernel/GaudiException.h"
9 #include "GaudiKernel/ServiceLocatorHelper.h"
10 #include "GaudiKernel/ThreadGaudi.h"
11 #include "GaudiKernel/ConversionSvc.h"
12
14 const CLID& Converter::objType() const {
15 return m_classType;
16 }
17
19 long Converter::i_repSvcType() const {
20 return m_storageType;
21 }
22
24 StatusCode Converter::createObj(IOpaqueAddress*, DataObject*&) {
25 return StatusCode::SUCCESS;
26 }
27
28
30 StatusCode Converter::fillObjRefs(IOpaqueAddress*, DataObject*) {
31 return StatusCode::SUCCESS;
32 }
33
35 StatusCode Converter::updateObj(IOpaqueAddress*, DataObject*) {
36 return StatusCode::SUCCESS;
37 }
38
40 StatusCode Converter::updateObjRefs(IOpaqueAddress*, DataObject*) {
41 return StatusCode::SUCCESS;
42 }
43
45 StatusCode Converter::createRep(DataObject*, IOpaqueAddress*&) {
46 return StatusCode::SUCCESS;
47 }
48
50 StatusCode Converter::fillRepRefs(IOpaqueAddress*, DataObject*) {
51 return StatusCode::SUCCESS;
52 }
53
55 StatusCode Converter::updateRep(IOpaqueAddress*, DataObject*) {
56 return StatusCode::SUCCESS;
57 }
58
60 StatusCode Converter::updateRepRefs(IOpaqueAddress*, DataObject*) {
61 return StatusCode::SUCCESS;
62 }
63
65 StatusCode Converter::initialize() {
66 // Get a reference to the Message Service
67 if ( !msgSvc() ) {
68 return StatusCode::FAILURE;
69 }
70 return StatusCode::SUCCESS;
71 }
72
74 StatusCode Converter::finalize() {
75 // release services
76 m_messageSvc = nullptr;
77 m_dataManager = nullptr;
78 m_dataProvider = nullptr;
79 m_conversionSvc = nullptr;
80 m_addressCreator = nullptr;
81 return StatusCode::SUCCESS;
82 }
83
85 StatusCode Converter::setDataProvider(IDataProviderSvc* svc) {
86 m_dataProvider = svc;
87 m_dataManager = svc;
88 return StatusCode::SUCCESS;
89 }
90
92 SmartIF<IDataProviderSvc>& Converter::dataProvider() const {
93 return m_dataProvider;
94 }
95
97 SmartIF<IDataManagerSvc>& Converter::dataManager() const {
98 return m_dataManager;
99 }
100
102 StatusCode Converter::setConversionSvc(IConversionSvc* svc) {
103 m_conversionSvc = svc;
104 return StatusCode::SUCCESS;
105 }
106
108 SmartIF<IConversionSvc>& Converter::conversionSvc() const {
109 return m_conversionSvc;
110 }
111
113 StatusCode Converter::setAddressCreator(IAddressCreator* creator) {
114 m_addressCreator = creator;
115 return StatusCode::SUCCESS;
116 }
117
119 SmartIF<IAddressCreator>& Converter::addressCreator() const {
120 return m_addressCreator;
121 }
122
124 SmartIF<ISvcLocator>& Converter::serviceLocator() const {
125 return m_svcLocator;
126 }
127
129 SmartIF<IMessageSvc>& Converter::msgSvc() const {
130 if ( !m_messageSvc ) {
131 m_messageSvc = serviceLocator();
132 if( !m_messageSvc ) {
133 throw GaudiException("Service [MessageSvc] not found", "Converter", StatusCode::FAILURE);
134 }
135 }
136 return m_messageSvc;
137 }
138
139 // Obsoleted name, kept due to the backwards compatibility
140 SmartIF<IMessageSvc>& Converter::messageService() const {
141 return msgSvc();
142 }
143
145 Converter::Converter(long storage_type, const CLID& class_type, ISvcLocator* svc) :
146 m_storageType(storage_type),
147 m_classType(class_type),
148 m_svcLocator(svc)
149 {
150 }
151
152 StatusCode
153 Converter::service_i(const std::string& svcName, bool createIf,
154 const InterfaceID& iid, void** ppSvc) const {
155 // Check for name of conversion service
156 SmartIF<INamedInterface> cnvsvc(conversionSvc());
157 if (cnvsvc) {
158 const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
159 return helper.getService(svcName, createIf, iid, ppSvc);
160 }
161 return StatusCode::FAILURE;
162 }
163
164 StatusCode
165 Converter::service_i(const std::string& svcType, const std::string& svcName,
166 const InterfaceID& iid, void** ppSvc) const {
167 // Check for name of conversion service
168 SmartIF<INamedInterface> cnvsvc(conversionSvc());
169 if (cnvsvc) {
170 const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
171 return helper.createService(svcType, svcName, iid, ppSvc);
172 }
173 return StatusCode::FAILURE;
174 }
175
176 SmartIF<IService> Converter::service(const std::string& name, const bool createIf) const {
177 SmartIF<INamedInterface> cnvsvc(conversionSvc());
178 SmartIF<IService> svc;
179 if (cnvsvc) {
180 const ServiceLocatorHelper helper(*serviceLocator(), "Converter", cnvsvc->name());
181 svc = helper.service(name, false, createIf);
182 }
183 return svc;
184 }
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:145
StatusCode::SUCCESS
Definition: StatusCode.h:30
SmartIF< IDataProviderSvc >
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:23
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
StatusCode::FAILURE
Definition: StatusCode.h:29
IConversionSvc
Definition: IConversionSvc.h:37
Converter::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:14
ConversionSvc.h
Converter::setConversionSvc
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
Definition: Converter.cpp:102
Converter::initialize
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:65
IAddressCreator
IAddressCreator interface definition.
Definition: IAddressCreator.h:28
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:129
Converter::updateRepRefs
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an already converted object.
Definition: Converter.cpp:60
Converter::createObj
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition: Converter.cpp:24
Converter::conversionSvc
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition: Converter.cpp:108
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
ThreadGaudi.h
std::string
STL class.
Converter::finalize
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:74
InterfaceID
Interface ID class.
Definition: IInterface.h:30
Converter::updateRep
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the converted representation of a transient object.
Definition: Converter.cpp:55
INamedInterface.h
IDataManagerSvc.h
IDataProviderSvc.h
Converter::fillObjRefs
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the created transient object.
Definition: Converter.cpp:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException.h
Converter::service
StatusCode service(const std::string &name, T *&psvc, bool createIf=false) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Converter.h:91
IMessageSvc.h
Converter::createRep
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Convert the transient object to the requested representation.
Definition: Converter.cpp:45
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:40
Converter::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:124
Converter::setAddressCreator
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: Converter.cpp:113
Converter::dataProvider
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:92
Converter::i_repSvcType
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: Converter.cpp:19
Converter::addressCreator
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: Converter.cpp:119
Converter::setDataProvider
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition: Converter.cpp:85
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:50
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
ISvcLocator.h
ServiceLocatorHelper::getService
StatusCode getService(const std::string &name, bool createIf, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.h:43
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
ServiceLocatorHelper::createService
StatusCode createService(const std::string &name, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.cpp:40
Converter::updateObj
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Update the transient object from the other representation.
Definition: Converter.cpp:35