an helper to share the implementation of service() among the various kernel base classes
More...
#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/ServiceLocatorHelper.h>
|
| ServiceLocatorHelper (ISvcLocator &svcLoc, const INamedInterface &requester) |
|
| ServiceLocatorHelper (ISvcLocator &svcLoc, std::string loggedName, std::string requesterName) |
|
| ServiceLocatorHelper (ISvcLocator &svcLoc, std::string requesterName) |
|
StatusCode | getService (std::string_view name, bool createIf, const InterfaceID &iid, void **ppSvc) const |
|
StatusCode | locateService (std::string_view name, const InterfaceID &iid, void **ppSvc, bool quiet=false) const |
|
StatusCode | createService (std::string_view name, const InterfaceID &iid, void **ppSvc) const |
|
StatusCode | createService (std::string_view type, std::string_view name, const InterfaceID &iid, void **ppSvc) const |
|
SmartIF< IService > | service (std::string_view name, const bool quiet=false, const bool createIf=true) const |
|
template<typename T> |
SmartIF< T > | service (std::string_view name, const bool quiet=false, const bool createIf=true) const |
|
an helper to share the implementation of service() among the various kernel base classes
Definition at line 26 of file ServiceLocatorHelper.h.
◆ ServiceLocatorHelper() [1/3]
Definition at line 28 of file ServiceLocatorHelper.h.
30 ,
m_msgLog( SmartIF<IMessageSvc>( &svcLoc ), requester.
name() )
31 ,
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string m_requesterName
◆ ServiceLocatorHelper() [2/3]
ServiceLocatorHelper::ServiceLocatorHelper |
( |
ISvcLocator & | svcLoc, |
|
|
std::string | loggedName, |
|
|
std::string | requesterName ) |
|
inline |
Definition at line 33 of file ServiceLocatorHelper.h.
35 ,
m_msgLog( SmartIF<IMessageSvc>( &svcLoc ), std::move( loggedName ) )
36 ,
const std::string & requesterName() const
◆ ServiceLocatorHelper() [3/3]
ServiceLocatorHelper::ServiceLocatorHelper |
( |
ISvcLocator & | svcLoc, |
|
|
std::string | requesterName ) |
|
inline |
◆ createService() [1/2]
StatusCode ServiceLocatorHelper::createService |
( |
std::string_view | name, |
|
|
const InterfaceID & | iid, |
|
|
void ** | ppSvc ) const |
Definition at line 33 of file ServiceLocatorHelper.cpp.
33 {
34 auto theSvc =
service( name,
false,
true );
36 StatusCode sc = theSvc->queryInterface( iid, ppSvc );
38 *ppSvc = nullptr;
39 log() <<
MSG::ERROR <<
"ServiceLocatorHelper::createService: wrong interface id " << iid <<
" for service " <<
name
41 }
42 return sc;
43}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
SmartIF< IService > service(std::string_view name, const bool quiet=false, const bool createIf=true) const
constexpr static const auto FAILURE
◆ createService() [2/2]
StatusCode ServiceLocatorHelper::createService |
( |
std::string_view | type, |
|
|
std::string_view | name, |
|
|
const InterfaceID & | iid, |
|
|
void ** | ppSvc ) const |
Definition at line 45 of file ServiceLocatorHelper.cpp.
46 {
47 return createService( fmt::format(
"{}/{}", type, name ), iid, ppSvc );
48}
StatusCode createService(std::string_view name, const InterfaceID &iid, void **ppSvc) const
◆ getService()
StatusCode ServiceLocatorHelper::getService |
( |
std::string_view | name, |
|
|
bool | createIf, |
|
|
const InterfaceID & | iid, |
|
|
void ** | ppSvc ) const |
|
inline |
Definition at line 44 of file ServiceLocatorHelper.h.
44 {
46 }
StatusCode locateService(std::string_view name, const InterfaceID &iid, void **ppSvc, bool quiet=false) const
◆ locateService()
StatusCode ServiceLocatorHelper::locateService |
( |
std::string_view | name, |
|
|
const InterfaceID & | iid, |
|
|
void ** | ppSvc, |
|
|
bool | quiet = false ) const |
Definition at line 19 of file ServiceLocatorHelper.cpp.
20 {
21 auto theSvc =
service( name, quiet,
false );
23 StatusCode sc = theSvc->queryInterface( iid, ppSvc );
25 *ppSvc = nullptr;
26 if ( !quiet )
27 log() <<
MSG::ERROR <<
"ServiceLocatorHelper::locateService: wrong interface id " << iid <<
" for service "
29 }
30 return sc;
31}
◆ log()
MsgStream & ServiceLocatorHelper::log |
( |
| ) |
const |
|
inlineprivate |
◆ requesterName()
const std::string & ServiceLocatorHelper::requesterName |
( |
| ) |
const |
|
inlineprivate |
◆ service() [1/2]
SmartIF< IService > ServiceLocatorHelper::service |
( |
std::string_view | name, |
|
|
const bool | quiet = false, |
|
|
const bool | createIf = true ) const |
Definition at line 50 of file ServiceLocatorHelper.cpp.
50 {
52
53 if ( theSvc ) {
54 if ( !quiet ) {
57 }
58 } else {
59
60 if ( !quiet ) {
log() <<
MSG::ERROR <<
"ServiceLocatorHelper::service: can not locate service " <<
name <<
endmsg; }
61 }
62 return theSvc;
63}
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
ISvcLocator * serviceLocator() const
◆ service() [2/2]
template<typename T>
SmartIF< T > ServiceLocatorHelper::service |
( |
std::string_view | name, |
|
|
const bool | quiet = false, |
|
|
const bool | createIf = true ) const |
|
inline |
Definition at line 57 of file ServiceLocatorHelper.h.
57 {
58 return service( name, quiet, createIf ).
as<T>();
59 }
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
◆ serviceLocator()
ISvcLocator * ServiceLocatorHelper::serviceLocator |
( |
| ) |
const |
|
inlineprivate |
◆ m_msgLog
◆ m_requesterName
std::string ServiceLocatorHelper::m_requesterName |
|
private |
◆ m_svcLoc
The documentation for this class was generated from the following files: