The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
ServiceLocatorHelper.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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\***********************************************************************************/
13
14SmartIF<IService> ServiceLocatorHelper::service( std::string_view name, const bool quiet, const bool createIf ) const {
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
SmartIF< IService > service(std::string_view name, const bool quiet=false, const bool createIf=true) const
ISvcLocator * serviceLocator() const
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
@ ERROR
Definition IMessageSvc.h:22
@ VERBOSE
Definition IMessageSvc.h:22