| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
ISvcLocator Class Referenceabstract

The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to locate services in the framework. More...

`#include <GaudiKernel/ISvcLocator.h>`

Inheritance diagram for ISvcLocator:
[legend]
Collaboration diagram for ISvcLocator:
[legend]

## Public Member Functions
| DeclareInterfaceID (ISvcLocator, 3, 0)
| InterfaceID. More...
virtual StatusCode | getService (const Gaudi::Utils::TypeNameString &typeName, IService *&svc, const bool createIf=true)
| Get a reference to the service given a service name. More...
virtual StatusCode | getService (const Gaudi::Utils::TypeNameString &typeName, const InterfaceID &iid, IInterface *&pinterface)
| Get a specific interface pointer given a service name and interface id. More...
virtual const std::list< IService * > & | getServices () const =0
| Get a reference to a service and create it if it does not exists. More...
virtual bool | existsService (const std::string &name) const =0
| Check the existence of a service given a service name. More...
template<class T >
StatusCode | service (const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
| Templated method to access a service by name. More...
template<class T >
StatusCode | service (const std::string &type, const std::string &name, T *&svc, bool createIf=true)
| Templated method to access a service by type and name. More...
virtual SmartIF< IService > & | service (const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
| Returns a smart pointer to a service. More...
template<typename T >
SmartIF< T > | service (const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)
| Returns a smart pointer to the requested interface of a service. More...
template<typename IFace >
SmartIF< IFace > | as ()
Public Member Functions inherited from IInterface
virtual void * | i_cast (const InterfaceID &) const =0
| main cast function More...
virtual std::vector< std::string > | getInterfaceNames () const =0
| Returns a vector of strings containing the names of all the implemented interfaces. More...
virtual unsigned long | addRef ()=0
| Increment the reference count of Interface instance. More...
virtual unsigned long | release ()=0
| Release Interface instance. More...
virtual unsigned long | refCount () const =0
| Current reference count. More...
virtual StatusCode | queryInterface (const InterfaceID &ti, void **pp)=0
| Set the void** to the pointer to the requested interface of the instance. More...
virtual | ~IInterface ()=default
| Virtual destructor. More...

## Additional Inherited Members
Public Types inherited from IInterface
enum | Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
| Return status. More...
using | iid = Gaudi::InterfaceId< IInterface, 0, 0 >
| Interface ID. More...
using | ext_iids = Gaudi::interface_list< iid >
| Extra interfaces. More...
Static Public Member Functions inherited from IInterface
static const InterfaceID & | interfaceID ()
| Return an instance of InterfaceID identifying the interface. More...

## Detailed Description

The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to locate services in the framework.

Clients use this interface to locate references to interfaces of services existing in the application. This operation needs to be done before the service can be used by the client. Typically "locating the services" is done at the initialization phase of the clients.

Author
  Pere Mato

Definition at line 25 of file ISvcLocator.h.

## Member Function Documentation

template<typename IFace >

SmartIF<IFace> ISvcLocator::as | ( |  | ) |
| inline

Definition at line 106 of file ISvcLocator.h.

106 { return SmartIF<IFace>{ this }; }
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14

ISvcLocator::DeclareInterfaceID | ( | ISvcLocator | ,
|  | 3 | ,
|  | 0 |
| ) |  |

InterfaceID.

virtual bool ISvcLocator::existsService | ( | const std::string & | name | ) | const
| pure virtual

Check the existence of a service given a service name.

virtual StatusCode ISvcLocator::getService | ( | const Gaudi::Utils::TypeNameString & | typeName,
|  | IService *& | svc,
|  | const bool | createIf = `true`
| ) |  |
| inline virtual

Get a reference to the service given a service name.

Parameters

  name | Service name
  svc | Returned service pointer

Definition at line 35 of file ISvcLocator.h.

36 {
37 SmartIF<IService> &s = service(typeName, createIf);
38 svc = s.get();
39 if (svc) {
40 svc->addRef(); // Needed to maintain the correct reference counting.
41 return StatusCode::SUCCESS;
42 }
43 return StatusCode::FAILURE;
44 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
SmartIF< IService >
StatusCode::FAILURE
Definition: StatusCode.h:29
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
gaudirun.s
string s
Definition: gaudirun.py:245

virtual StatusCode ISvcLocator::getService | ( | const Gaudi::Utils::TypeNameString & | typeName,
|  | const InterfaceID & | iid,
|  | IInterface *& | pinterface
| ) |  |
| inline virtual

Get a specific interface pointer given a service name and interface id.

Parameters

  name | Service name
  iid | Interface ID
  pinterface | Returned pointer to the requested interface

Definition at line 51 of file ISvcLocator.h.

53 {
54 auto svc = service(typeName, false);
55 return svc ? svc->queryInterface(iid, (void**)&pinterface)
56 : StatusCode::FAILURE;
57 }
StatusCode::FAILURE
Definition: StatusCode.h:29
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78

virtual const std::list<IService*>& ISvcLocator::getServices | ( |  | ) | const
| pure virtual

Get a reference to a service and create it if it does not exists.

Parameters

  name | Service name
  svc | Returned service pointer
  createIf | flag to control the creationReturn the list of Services

template<class T >

StatusCode ISvcLocator::service | ( | const Gaudi::Utils::TypeNameString & | name,
|  | T *& | svc,
|  | bool | createIf = `true`
| ) |  |
| inline

Templated method to access a service by name.

Definition at line 78 of file ISvcLocator.h.

78 {
79 if( createIf ) {
80 IService* s;
81 StatusCode sc = getService( name, s, true);
82 if ( !sc.isSuccess() ) return sc; // Must check if initialization was OK!
83 }
84 return getService( name, T::interfaceID(), (IInterface*&)svc );
85 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
IService
General service interface definition.
Definition: IService.h:18
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IInterface
Definition of the basic interface.
Definition: IInterface.h:234
ISvcLocator::getService
virtual StatusCode getService(const Gaudi::Utils::TypeNameString &typeName, IService *&svc, const bool createIf=true)
Get a reference to the service given a service name.
Definition: ISvcLocator.h:35
gaudirun.s
string s
Definition: gaudirun.py:245
template<class T >

StatusCode ISvcLocator::service | ( | const std::string & | type,
|  | const std::string & | name,
|  | T *& | svc,
|  | bool | createIf = `true`
| ) |  |
| inline

Templated method to access a service by type and name.

Definition at line 89 of file ISvcLocator.h.

90 {
91 return service(type + "/" + name, svc, createIf);
92 }
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78

virtual SmartIF<IService>& ISvcLocator::service | ( | const Gaudi::Utils::TypeNameString & | typeName,
|  | const bool | createIf = `true`
| ) |  |
| pure virtual

Returns a smart pointer to a service.

template<typename T >

SmartIF<T> ISvcLocator::service | ( | const Gaudi::Utils::TypeNameString & | typeName,
|  | const bool | createIf = `true`
| ) |  |
| inline

Returns a smart pointer to the requested interface of a service.

Definition at line 100 of file ISvcLocator.h.

100 {
101 return SmartIF<T>{ service(typeName, createIf) };
102 }
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition: IConverter.h:14
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78

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

- GaudiKernel/GaudiKernel/ISvcLocator.h