| The Gaudi Framework v29r0 (ff2e7097)

- 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/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 #include "GaudiKernel/ThreadGaudi.h"
12
14 const CLID& Converter::objType() const { return m_classType; }
15
17 long Converter::i_repSvcType() const { return m_storageType; }
18
20 StatusCode Converter::createObj( IOpaqueAddress*, DataObject*& ) { return StatusCode::SUCCESS; }
21
23 StatusCode Converter::fillObjRefs( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
24
26 StatusCode Converter::updateObj( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
27
29 StatusCode Converter::updateObjRefs( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
30
32 StatusCode Converter::createRep( DataObject*, IOpaqueAddress*& ) { return StatusCode::SUCCESS; }
33
35 StatusCode Converter::fillRepRefs( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
36
38 StatusCode Converter::updateRep( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
39
41 StatusCode Converter::updateRepRefs( IOpaqueAddress*, DataObject* ) { return StatusCode::SUCCESS; }
42
44 StatusCode Converter::initialize()
45 {
46 // Get a reference to the Message Service
47 if ( !msgSvc() ) {
48 return StatusCode::FAILURE;
49 }
50 return StatusCode::SUCCESS;
51 }
52
54 StatusCode Converter::finalize()
55 {
56 // release services
57 m_messageSvc = nullptr;
58 m_dataManager = nullptr;
59 m_dataProvider = nullptr;
60 m_conversionSvc = nullptr;
61 m_addressCreator = nullptr;
62 return StatusCode::SUCCESS;
63 }
64
66 StatusCode Converter::setDataProvider( IDataProviderSvc* svc )
67 {
68 m_dataProvider = svc;
69 m_dataManager = svc;
70 return StatusCode::SUCCESS;
71 }
72
74 SmartIF<IDataProviderSvc>& Converter::dataProvider() const { return m_dataProvider; }
75
77 SmartIF<IDataManagerSvc>& Converter::dataManager() const { return m_dataManager; }
78
80 StatusCode Converter::setConversionSvc( IConversionSvc* svc )
81 {
82 m_conversionSvc = svc;
83 return StatusCode::SUCCESS;
84 }
85
87 SmartIF<IConversionSvc>& Converter::conversionSvc() const { return m_conversionSvc; }
88
90 StatusCode Converter::setAddressCreator( IAddressCreator* creator )
91 {
92 m_addressCreator = creator;
93 return StatusCode::SUCCESS;
94 }
95
97 SmartIF<IAddressCreator>& Converter::addressCreator() const { return m_addressCreator; }
98
100 SmartIF<ISvcLocator>& Converter::serviceLocator() const { return m_svcLocator; }
101
103 SmartIF<IMessageSvc>& Converter::msgSvc() const
104 {
105 if ( !m_messageSvc ) {
106 m_messageSvc = serviceLocator();
107 if ( !m_messageSvc ) {
108 throw GaudiException( "Service [MessageSvc] not found", "Converter", StatusCode::FAILURE );
109 }
110 }
111 return m_messageSvc;
112 }
113
115 Converter::Converter( long storage_type, const CLID& class_type, ISvcLocator* svc )
116 : m_storageType( storage_type ), m_classType( class_type ), m_svcLocator( svc )
117 {
118 }
119
120 StatusCode Converter::service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const
121 {
122 // Check for name of conversion service
123 SmartIF<INamedInterface> cnvsvc( conversionSvc() );
124 if ( cnvsvc ) {
125 const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
126 return helper.getService( svcName, createIf, iid, ppSvc );
127 }
128 return StatusCode::FAILURE;
129 }
130
131 StatusCode Converter::service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
132 void** ppSvc ) const
133 {
134 // Check for name of conversion service
135 SmartIF<INamedInterface> cnvsvc( conversionSvc() );
136 if ( cnvsvc ) {
137 const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
138 return helper.createService( svcType, svcName, iid, ppSvc );
139 }
140 return StatusCode::FAILURE;
141 }
142
143 SmartIF<IService> Converter::service( const std::string& name, const bool createIf ) const
144 {
145 SmartIF<INamedInterface> cnvsvc( conversionSvc() );
146 SmartIF<IService> svc;
147 if ( cnvsvc ) {
148 const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
149 svc = helper.service( name, false, createIf );
150 }
151 return svc;
152 }
Converter::m_addressCreator
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:123
Converter::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:131
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:115
StatusCode::SUCCESS
Definition: StatusCode.h:31
SmartIF< IDataProviderSvc >
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
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:32
StatusCode::FAILURE
Definition: StatusCode.h:31
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:80
Converter::m_dataManager
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:127
Converter::initialize
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:44
IAddressCreator
IAddressCreator interface definition.
Definition: IAddressCreator.h:28
Converter::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:103
Converter::updateRepRefs
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an already converted object.
Definition: Converter.cpp:41
Converter::m_messageSvc
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:133
Converter::createObj
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition: Converter.cpp:20
Converter::conversionSvc
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition: Converter.cpp:87
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
ThreadGaudi.h
std::string
STL class.
Converter::m_conversionSvc
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:129
Converter::finalize
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:54
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:38
INamedInterface.h
IDataManagerSvc.h
IDataProviderSvc.h
Converter::m_storageType
long m_storageType
Storage type.
Definition: Converter.h:119
Converter::fillObjRefs
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the created transient object.
Definition: Converter.cpp:23
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
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
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:120
Converter::m_classType
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:121
IMessageSvc.h
Converter::createRep
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Convert the transient object to the requested representation.
Definition: Converter.cpp:32
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:29
Converter::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:100
Converter::setAddressCreator
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: Converter.cpp:90
Converter::dataProvider
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:74
Converter::i_repSvcType
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: Converter.cpp:17
Converter::addressCreator
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: Converter.cpp:97
Converter::dataManager
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition: Converter.cpp:77
Converter::setDataProvider
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition: Converter.cpp:66
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:35
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
ISvcLocator.h
ServiceLocatorHelper::getService
StatusCode getService(const std::string &name, bool createIf, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.h:50
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
Converter::m_dataProvider
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:125
ServiceLocatorHelper::createService
StatusCode createService(const std::string &name, const InterfaceID &iid, void **ppSvc) const
Definition: ServiceLocatorHelper.cpp:31
Converter::updateObj
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Update the transient object from the other representation.
Definition: Converter.cpp:26