The Gaudi Framework  v31r0 (aeb156f0)
Converter.cpp
Go to the documentation of this file.
1 // Include Files
11 
13 const CLID& Converter::objType() const { return m_classType; }
14 
16 long Converter::i_repSvcType() const { return m_storageType; }
17 
20 
23 
26 
29 
32 
35 
38 
41 
44  // Get a reference to the Message Service
45  if ( !msgSvc() ) { return StatusCode::FAILURE; }
46  return StatusCode::SUCCESS;
47 }
48 
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 
62  m_dataProvider = svc;
63  m_dataManager = svc;
64  return StatusCode::SUCCESS;
65 }
66 
69 
72 
75  m_conversionSvc = svc;
76  return StatusCode::SUCCESS;
77 }
78 
81 
84  m_addressCreator = creator;
85  return StatusCode::SUCCESS;
86 }
87 
90 
93 
96  if ( !m_messageSvc ) {
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
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
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 {
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 }
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:115
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:123
an helper to share the implementation of service() among the various kernel base classes ...
Converter(long storage_type, const CLID &class_type, ISvcLocator *svc=0)
Standard Constructor.
Definition: Converter.cpp:104
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:13
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
Definition: Converter.cpp:74
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:119
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:43
IAddressCreator interface definition.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:95
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an already converted object.
Definition: Converter.cpp:40
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:125
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition: Converter.cpp:19
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition: Converter.cpp:80
Data provider interface definition.
STL class.
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:121
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:50
Interface ID class.
Definition: IInterface.h:29
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the converted representation of a transient object.
Definition: Converter.cpp:37
long m_storageType
Storage type.
Definition: Converter.h:111
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the created transient object.
Definition: Converter.cpp:22
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
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:88
StatusCode service_i(const std::string &svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of service method
Definition: Converter.cpp:107
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:113
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Convert the transient object to the requested representation.
Definition: Converter.cpp:31
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an updated transient object.
Definition: Converter.cpp:28
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:92
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: Converter.cpp:83
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:68
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: Converter.cpp:16
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: Converter.cpp:89
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition: Converter.cpp:71
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition: Converter.cpp:61
constexpr static const auto FAILURE
Definition: StatusCode.h:86
Opaque address interface definition.
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the converted object.
Definition: Converter.cpp:34
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
StatusCode getService(const std::string &name, bool createIf, const InterfaceID &iid, void **ppSvc) const
virtual const std::string & name() const =0
Retrieve the name of the instance.
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:117
StatusCode createService(const std::string &name, const InterfaceID &iid, void **ppSvc) const
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Update the transient object from the other representation.
Definition: Converter.cpp:25