The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
ServiceLocatorHelper.h
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
\***********************************************************************************/
11
#pragma once
12
13
#include <
GaudiKernel/IService.h
>
14
#include <
GaudiKernel/ISvcLocator.h
>
15
#include <
GaudiKernel/SmartIF.h
>
16
#include <
GaudiKernel/StatusCode.h
>
17
#include <string>
18
19
class
InterfaceID
;
20
class
MsgStream
;
21
26
class
GAUDI_API
ServiceLocatorHelper
{
27
public
:
28
ServiceLocatorHelper
(
ISvcLocator
& svcLoc,
const
INamedInterface
& requester )
29
:
m_svcLoc
( svcLoc )
30
,
m_msgLog
(
SmartIF
<
IMessageSvc
>( &svcLoc ), requester.name() )
31
,
// use requester msg level
32
m_requesterName
( requester.name() ) {}
33
ServiceLocatorHelper
(
ISvcLocator
& svcLoc, std::string loggedName, std::string
requesterName
)
34
:
m_svcLoc
( svcLoc )
35
,
m_msgLog
(
SmartIF
<
IMessageSvc
>( &svcLoc ),
std
::move( loggedName ) )
36
,
// use requester msg level
37
m_requesterName
(
std
::move(
requesterName
) ) {}
38
ServiceLocatorHelper
(
ISvcLocator
& svcLoc, std::string
requesterName
)
39
:
m_svcLoc
( svcLoc )
40
,
m_msgLog
(
SmartIF
<
IMessageSvc
>( &svcLoc ),
requesterName
)
41
,
// use requester msg level
42
m_requesterName
(
std
::move(
requesterName
) ) {}
43
44
SmartIF<IService>
service( std::string_view name,
const
bool
quiet =
false
,
const
bool
createIf =
true
)
const
;
45
46
template
<
typename
T>
47
SmartIF<T>
service
( std::string_view name,
const
bool
quiet =
false
,
const
bool
createIf =
true
)
const
{
48
return
service
( name, quiet, createIf ).as<T>();
49
}
50
51
private
:
52
ISvcLocator
*
serviceLocator
()
const
{
return
&
m_svcLoc
; }
53
MsgStream
&
log
()
const
{
return
m_msgLog
; }
54
const
std::string&
requesterName
()
const
{
return
m_requesterName
; }
55
ISvcLocator
&
m_svcLoc
;
56
mutable
MsgStream
m_msgLog
;
57
std::string
m_requesterName
;
58
};
IService.h
ISvcLocator.h
GAUDI_API
#define GAUDI_API
Definition
Kernel.h:49
SmartIF.h
StatusCode.h
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition
IMessageSvc.h:34
INamedInterface
IInterface compliant class extending IInterface with the name() method.
Definition
INamedInterface.h:23
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition
ISvcLocator.h:42
InterfaceID
Interface ID class.
Definition
IInterface.h:38
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition
MsgStream.h:29
ServiceLocatorHelper::ServiceLocatorHelper
ServiceLocatorHelper(ISvcLocator &svcLoc, std::string loggedName, std::string requesterName)
Definition
ServiceLocatorHelper.h:33
ServiceLocatorHelper::m_svcLoc
ISvcLocator & m_svcLoc
Definition
ServiceLocatorHelper.h:55
ServiceLocatorHelper::log
MsgStream & log() const
Definition
ServiceLocatorHelper.h:53
ServiceLocatorHelper::m_msgLog
MsgStream m_msgLog
Definition
ServiceLocatorHelper.h:56
ServiceLocatorHelper::requesterName
const std::string & requesterName() const
Definition
ServiceLocatorHelper.h:54
ServiceLocatorHelper::ServiceLocatorHelper
ServiceLocatorHelper(ISvcLocator &svcLoc, const INamedInterface &requester)
Definition
ServiceLocatorHelper.h:28
ServiceLocatorHelper::service
SmartIF< IService > service(std::string_view name, const bool quiet=false, const bool createIf=true) const
Definition
ServiceLocatorHelper.cpp:14
ServiceLocatorHelper::serviceLocator
ISvcLocator * serviceLocator() const
Definition
ServiceLocatorHelper.h:52
ServiceLocatorHelper::m_requesterName
std::string m_requesterName
Definition
ServiceLocatorHelper.h:57
ServiceLocatorHelper::service
SmartIF< T > service(std::string_view name, const bool quiet=false, const bool createIf=true) const
Definition
ServiceLocatorHelper.h:47
ServiceLocatorHelper::ServiceLocatorHelper
ServiceLocatorHelper(ISvcLocator &svcLoc, std::string requesterName)
Definition
ServiceLocatorHelper.h:38
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition
SmartIF.h:28
std
STL namespace.
GaudiKernel
include
GaudiKernel
ServiceLocatorHelper.h
Generated on
for The Gaudi Framework by
1.17.0