The Gaudi Framework  v33r0 (d5ea422b)
Converter.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 // Include Files
12 #include "GaudiKernel/Converter.h"
21 
23 const CLID& Converter::objType() const { return m_classType; }
24 
26 long Converter::i_repSvcType() const { return m_storageType; }
27 
30 
33 
36 
39 
42 
45 
48 
51 
54  // Get a reference to the Message Service
55  if ( !msgSvc() ) { return StatusCode::FAILURE; }
56  return StatusCode::SUCCESS;
57 }
58 
61  // release services
62  m_messageSvc = nullptr;
63  m_dataManager = nullptr;
64  m_dataProvider = nullptr;
65  m_conversionSvc = nullptr;
66  m_addressCreator = nullptr;
67  return StatusCode::SUCCESS;
68 }
69 
72  m_dataProvider = svc;
73  m_dataManager = svc;
74  return StatusCode::SUCCESS;
75 }
76 
79 
82 
85  m_conversionSvc = svc;
86  return StatusCode::SUCCESS;
87 }
88 
91 
94  m_addressCreator = creator;
95  return StatusCode::SUCCESS;
96 }
97 
100 
103 
106  if ( !m_messageSvc ) {
108  if ( !m_messageSvc ) { throw GaudiException( "Service [MessageSvc] not found", "Converter", StatusCode::FAILURE ); }
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 StatusCode Converter::service_i( const std::string& svcName, bool createIf, const InterfaceID& iid,
118  void** ppSvc ) const {
119  // Check for name of conversion service
121  if ( cnvsvc ) {
122  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
123  return helper.getService( svcName, createIf, iid, ppSvc );
124  }
125  return StatusCode::FAILURE;
126 }
127 
128 StatusCode Converter::service_i( const std::string& svcType, const std::string& svcName, const InterfaceID& iid,
129  void** ppSvc ) const {
130  // Check for name of conversion service
132  if ( cnvsvc ) {
133  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
134  return helper.createService( svcType, svcName, iid, ppSvc );
135  }
136  return StatusCode::FAILURE;
137 }
138 
139 SmartIF<IService> Converter::service( const std::string& name, const bool createIf ) const {
141  SmartIF<IService> svc;
142  if ( cnvsvc ) {
143  const ServiceLocatorHelper helper( *serviceLocator(), "Converter", cnvsvc->name() );
144  svc = helper.service( name, false, createIf );
145  }
146  return svc;
147 }
SmartIF< IAddressCreator > m_addressCreator
Pointer to the address creation service interface.
Definition: Converter.h:125
SmartIF< ISvcLocator > m_svcLocator
Service Locator reference.
Definition: Converter.h:133
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
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Definition: Converter.cpp:90
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:35
StatusCode createService(const std::string &name, const InterfaceID &iid, void **ppSvc) const
StatusCode service_i(const std::string &svcName, bool createIf, const InterfaceID &iid, void **ppSvc) const
implementation of service method
Definition: Converter.cpp:117
virtual long i_repSvcType() const
Retrieve the class type of the data store the converter uses.
Definition: Converter.cpp:26
StatusCode getService(const std::string &name, bool createIf, const InterfaceID &iid, void **ppSvc) const
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
Definition: Converter.cpp:84
SmartIF< IDataManagerSvc > m_dataManager
Pointer to data manager service.
Definition: Converter.h:129
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:98
StatusCode initialize() override
Initialize the converter.
Definition: Converter.cpp:53
IAddressCreator interface definition.
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an already converted object.
Definition: Converter.cpp:50
SmartIF< IMessageSvc > m_messageSvc
MessageSvc reference.
Definition: Converter.h:135
StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject) override
Create the transient representation of an object.
Definition: Converter.cpp:29
Data provider interface definition.
virtual const std::string & name() const =0
Retrieve the name of the instance.
STL class.
SmartIF< IConversionSvc > m_conversionSvc
Pointer to the connected conversion service.
Definition: Converter.h:131
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:105
StatusCode finalize() override
Initialize the converter.
Definition: Converter.cpp:60
Interface ID class.
Definition: IInterface.h:39
StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the converted representation of a transient object.
Definition: Converter.cpp:47
long m_storageType
Storage type.
Definition: Converter.h:121
StatusCode fillObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the created transient object.
Definition: Converter.cpp:32
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
const CLID m_classType
Class type the converter can handle.
Definition: Converter.h:123
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Convert the transient object to the requested representation.
Definition: Converter.cpp:41
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Update the references of an updated transient object.
Definition: Converter.cpp:38
SmartIF< IDataProviderSvc > & dataProvider() const override
Get Data provider service.
Definition: Converter.cpp:78
StatusCode setAddressCreator(IAddressCreator *creator) override
Set address creator facility.
Definition: Converter.cpp:93
StatusCode setDataProvider(IDataProviderSvc *svc) override
Set Data provider service.
Definition: Converter.cpp:71
SmartIF< IAddressCreator > & addressCreator() const override
Retrieve address creator facility.
Definition: Converter.cpp:99
constexpr static const auto FAILURE
Definition: StatusCode.h:97
Opaque address interface definition.
StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject) override
Resolve the references of the converted object.
Definition: Converter.cpp:44
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Converter.cpp:102
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:23
SmartIF< IDataProviderSvc > m_dataProvider
Pointer to data provider service.
Definition: Converter.h:127
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition: Converter.cpp:81
StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject) override
Update the transient object from the other representation.
Definition: Converter.cpp:35