| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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.
virtual StatusCode | getService (const Gaudi::Utils::TypeNameString &typeName, IService *&svc, const bool createIf=true)
| Get a reference to the service given a service name.
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.
virtual const std::list < IService * > & | getServices () const =0
| Get a reference to a service and create it if it does not exists.
virtual bool | existsService (const std::string &name) const =0
| Check the existence of a service given a service name.
template<class T >
StatusCode | service (const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
| Templated method to access a service by name.
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.
virtual SmartIF< IService > & | service (const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
| Returns a smart pointer to a service.
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.
Public Member Functions inherited from IInterface
virtual void * | i_cast (const InterfaceID &) const =0
| main cast function
virtual std::vector< std::string > | getInterfaceNames () const =0
| Returns a vector of strings containing the names of all the implemented interfaces.
virtual unsigned long | addRef ()=0
| Increment the reference count of Interface instance.
virtual unsigned long | release ()=0
| Release Interface instance.
virtual unsigned long | refCount () const =0
| Current reference count.
virtual StatusCode | queryInterface (const InterfaceID &ti, void **pp)=0
| Set the void** to the pointer to the requested interface of the instance.
virtual | ~IInterface ()
| Virtual destructor.

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

## 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 26 of file ISvcLocator.h.

## Member Function Documentation

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.

Implemented in Gaudi::BootSvcLocator.

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

Reimplemented in Gaudi::BootSvcLocator.

Definition at line 36 of file ISvcLocator.h.

{
SmartIF<IService> &s = service(typeName, createIf);
svc = s.get();
if (svc) {
svc->addRef(); // Needed to maintain the correct reference counting.
return StatusCode::SUCCESS;
}
return StatusCode::FAILURE;
}

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

Reimplemented in Gaudi::BootSvcLocator.

Definition at line 52 of file ISvcLocator.h.

{
SmartIF<IService> svc = service(typeName, false);
if (svc.isValid()) {
// Service found. So now get the right interface
return svc->queryInterface(iid, (void**)&pinterface);
}
return StatusCode::FAILURE;
}

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

Implemented in Gaudi::BootSvcLocator.

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 82 of file ISvcLocator.h.

{
if( createIf ) {
IService* s;
StatusCode sc = getService( name, s, true);
if ( !sc.isSuccess() ) return sc; // Must check if initialization was OK!
}
return getService( name, T::interfaceID(), (IInterface*&)svc );
}
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 93 of file ISvcLocator.h.

{
return service(type + "/" + name, svc, createIf);
}

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

Returns a smart pointer to a service.

Implemented in Gaudi::BootSvcLocator.

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 104 of file ISvcLocator.h.

{
return SmartIF<T>(service(typeName, createIf));
}

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiKernel/GaudiKernel/ISvcLocator.h