The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
ServiceLocatorHelper Class Reference

an helper to share the implementation of service() among the various kernel base classes More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/ServiceLocatorHelper.h>

Collaboration diagram for ServiceLocatorHelper:

Public Member Functions

 ServiceLocatorHelper (ISvcLocator &svcLoc, const INamedInterface &requester)
 
 ServiceLocatorHelper (ISvcLocator &svcLoc, std::string loggedName, std::string requesterName)
 
 ServiceLocatorHelper (ISvcLocator &svcLoc, std::string requesterName)
 
SmartIF< IServiceservice (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
 

Private Member Functions

ISvcLocatorserviceLocator () const
 
MsgStreamlog () const
 
const std::string & requesterName () const
 

Private Attributes

ISvcLocatorm_svcLoc
 
MsgStream m_msgLog
 
std::string m_requesterName
 

Detailed Description

an helper to share the implementation of service() among the various kernel base classes

Definition at line 26 of file ServiceLocatorHelper.h.

Constructor & Destructor Documentation

◆ ServiceLocatorHelper() [1/3]

ServiceLocatorHelper::ServiceLocatorHelper ( ISvcLocator & svcLoc,
const INamedInterface & requester )
inline

Definition at line 28 of file ServiceLocatorHelper.h.

29 : m_svcLoc( svcLoc )
30 , m_msgLog( SmartIF<IMessageSvc>( &svcLoc ), requester.name() )
31 , // use requester msg level
32 m_requesterName( requester.name() ) {}
virtual const std::string & name() const =0
Retrieve the name of the instance.

◆ ServiceLocatorHelper() [2/3]

ServiceLocatorHelper::ServiceLocatorHelper ( ISvcLocator & svcLoc,
std::string loggedName,
std::string requesterName )
inline

Definition at line 33 of file ServiceLocatorHelper.h.

34 : m_svcLoc( svcLoc )
35 , m_msgLog( SmartIF<IMessageSvc>( &svcLoc ), std::move( loggedName ) )
36 , // use requester msg level
37 m_requesterName( std::move( requesterName ) ) {}
const std::string & requesterName() const

◆ ServiceLocatorHelper() [3/3]

ServiceLocatorHelper::ServiceLocatorHelper ( ISvcLocator & svcLoc,
std::string requesterName )
inline

Definition at line 38 of file ServiceLocatorHelper.h.

39 : m_svcLoc( svcLoc )
40 , m_msgLog( SmartIF<IMessageSvc>( &svcLoc ), requesterName )
41 , // use requester msg level
42 m_requesterName( std::move( requesterName ) ) {}

Member Function Documentation

◆ log()

MsgStream & ServiceLocatorHelper::log ( ) const
inlineprivate

Definition at line 53 of file ServiceLocatorHelper.h.

53{ return m_msgLog; }

◆ requesterName()

const std::string & ServiceLocatorHelper::requesterName ( ) const
inlineprivate

Definition at line 54 of file ServiceLocatorHelper.h.

54{ return m_requesterName; }

◆ service() [1/2]

SmartIF< IService > ServiceLocatorHelper::service ( std::string_view name,
const bool quiet = false,
const bool createIf = true ) const

Definition at line 14 of file ServiceLocatorHelper.cpp.

14 {
15 SmartIF<IService> theSvc = serviceLocator()->service( name, createIf );
16
17 if ( theSvc ) {
18 if ( !quiet ) {
19 if ( log().level() <= MSG::VERBOSE )
20 log() << MSG::VERBOSE << "ServiceLocatorHelper::service: found service " << name << endmsg;
21 }
22 } else {
23 // if not return an error
24 if ( !quiet ) { log() << MSG::ERROR << "ServiceLocatorHelper::service: can not locate service " << name << endmsg; }
25 }
26 return theSvc;
27}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
MsgStream & log() const
ISvcLocator * serviceLocator() const
@ ERROR
Definition IMessageSvc.h:22
@ VERBOSE
Definition IMessageSvc.h:22

◆ 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 47 of file ServiceLocatorHelper.h.

47 {
48 return service( name, quiet, createIf ).as<T>();
49 }
SmartIF< IService > service(std::string_view name, const bool quiet=false, const bool createIf=true) const
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
Definition SmartIF.h:110

◆ serviceLocator()

ISvcLocator * ServiceLocatorHelper::serviceLocator ( ) const
inlineprivate

Definition at line 52 of file ServiceLocatorHelper.h.

52{ return &m_svcLoc; }

Member Data Documentation

◆ m_msgLog

MsgStream ServiceLocatorHelper::m_msgLog
mutableprivate

Definition at line 56 of file ServiceLocatorHelper.h.

◆ m_requesterName

std::string ServiceLocatorHelper::m_requesterName
private

Definition at line 57 of file ServiceLocatorHelper.h.

◆ m_svcLoc

ISvcLocator& ServiceLocatorHelper::m_svcLoc
private

Definition at line 55 of file ServiceLocatorHelper.h.


The documentation for this class was generated from the following files: