The Gaudi Framework  v30r3 (a5ef0a68)
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 {
45  // Get a reference to the Message Service
46  if ( !msgSvc() ) {
47  return StatusCode::FAILURE;
48  }
49  return StatusCode::SUCCESS;
50 }
51 
54 {
55  // release services
56  m_messageSvc = nullptr;
57  m_dataManager = nullptr;
58  m_dataProvider = nullptr;
59  m_conversionSvc = nullptr;
60  m_addressCreator = nullptr;
61  return StatusCode::SUCCESS;
62 }
63 
66 {
67  m_dataProvider = svc;
68  m_dataManager = svc;
69  return StatusCode::SUCCESS;
70 }
71 
74 
77 
80 {
81  m_conversionSvc = svc;
82  return StatusCode::SUCCESS;
83 }
84 
87 
90 {
91  m_addressCreator = creator;
92  return StatusCode::SUCCESS;
93 }
94 
97 
100 
103 {
104  if ( !m_messageSvc ) {
106  if ( !m_messageSvc ) {
107  throw GaudiException( "Service [MessageSvc] not found", "Converter", StatusCode::FAILURE );
108  }
109  }
110  return m_messageSvc;
111 }
112 
114 Converter::Converter( long storage_type, const CLID& class_type, ISvcLocator* svc )
115  : m_storageType( storage_type ), m_classType( class_type ), m_svcLocator( svc )
116 {
117 }
118 
119 StatusCode Converter::service_i( const std::string& svcName, bool createIf, const InterfaceID& iid, void** ppSvc ) const
120 {
121  // Check for name of conversion service
123  if ( cnvsvc ) {
124  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
125  return helper.getService( svcName, createIf, iid, ppSvc );
126  }
127  return StatusCode::FAILURE;
128 }
129 
130 StatusCode Converter::service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
131  void** ppSvc ) const
132 {
133  // Check for name of conversion service
135  if ( cnvsvc ) {
136  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
137  return helper.createService( svcType, svcName, iid, ppSvc );
138  }
139  return StatusCode::FAILURE;
140 }
141 
142 SmartIF<IService> Converter::service( const std::string& name, const bool createIf ) const
143 {
145  SmartIF<IService> svc;
146  if ( cnvsvc ) {
147  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
148  svc = helper.service( name, false, createIf );
149  }
150  return svc;
151 }
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:118
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:126
constexpr static const auto FAILURE
Definition: StatusCode.h:88
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:114
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:79
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:122
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:43
IAddressCreator interface definition.
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:102
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:128
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:86
Data provider interface definition.
STL class.
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:124
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:53
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:114
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:51
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:89
StatusCode service_i(const std::string &svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of service method
Definition: Converter.cpp:119
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:116
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
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
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:99
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: Converter.cpp:89
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:73
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:96
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition: Converter.cpp:76
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition: Converter.cpp:65
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:120
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