The Gaudi Framework  master (42b00024)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ISvcLocator.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 #ifndef GAUDIKERNEL_ISVCLOCATOR_H
12 #define GAUDIKERNEL_ISVCLOCATOR_H 1
13 
14 // Include files
15 #include <GaudiKernel/IInterface.h>
17 #include <GaudiKernel/SmartIF.h>
19 
20 #include <list>
21 #include <string>
22 
23 // Forward class declaration
24 class IService;
25 namespace Gaudi::Monitoring {
26  struct Hub;
27 }
28 
29 namespace Gaudi {
30  namespace Interfaces {
31  struct IOptionsSvc;
32  }
33 } // namespace Gaudi
34 #define GAUDI_HAS_IOPTIONS_SVC
35 
46 class GAUDI_API ISvcLocator : virtual public IInterface {
47 public:
50 
52  virtual const std::list<IService*>& getServices() const = 0;
53 
55  virtual bool existsService( std::string_view name ) const = 0;
56 
58  virtual SmartIF<IService>& service( const Gaudi::Utils::TypeNameString& typeName, const bool createIf = true ) = 0;
59 
61  template <typename T>
62  inline SmartIF<T> service( const Gaudi::Utils::TypeNameString& typeName, const bool createIf = true ) {
63  return SmartIF<T>{ service( typeName, createIf ) };
64  }
65 
66  // try to access a different interface of the _current_ serviceLocator...
67  template <typename IFace>
69  return SmartIF<IFace>{ this };
70  }
71 
73  Gaudi::Interfaces::IOptionsSvc& getOptsSvc();
74 
75  Gaudi::Monitoring::Hub& monitoringHub();
76 };
77 
78 #endif // GAUDI_ISVCLOCATOR_H
IService
Definition: IService.h:28
ISvcLocator::getServices
virtual const std::list< IService * > & getServices() const =0
Return the list of Services.
ISvcLocator::DeclareInterfaceID
DeclareInterfaceID(ISvcLocator, 3, 0)
InterfaceID.
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::Monitoring
Definition: JSONSink.cpp:19
ISvcLocator::service
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
SmartIF.h
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:20
IInterface.h
SmartIF< IService >
TypeNameString.h
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
GaudiDict::typeName
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:31
ISvcLocator::as
SmartIF< IFace > as()
Definition: ISvcLocator.h:68
IInterface
Definition: IInterface.h:226
Gaudi::Monitoring::Hub
Central entity in a Gaudi application that manages monitoring objects (i.e.
Definition: MonitoringHub.h:47
Gaudi::Interfaces::IOptionsSvc
Interface for a component that manages application configuration options.
Definition: IOptionsSvc.h:46
ISvcLocator::service
SmartIF< T > service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)
Returns a smart pointer to the requested interface of a service.
Definition: ISvcLocator.h:62
ISvcLocator::existsService
virtual bool existsService(std::string_view name) const =0
Check the existence of a service given a service name.
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:84
ISvcManager.h