Gaudi Framework, version v25r0

Home   Generated: Mon Feb 17 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ServiceHandle< T > Class Template Reference

Handle to be used in lieu of naked pointers to services. More...

#include <GaudiKernel/ServiceHandle.h>

Inheritance diagram for ServiceHandle< T >:
Inheritance graph
[legend]
Collaboration diagram for ServiceHandle< T >:
Collaboration graph
[legend]

Public Member Functions

 ServiceHandle (const std::string &serviceName, const std::string &theParentName)
 Create a handle ('smart pointer') to a service.
 
StatusCode retrieve () const
 Retrieve the Service.
 
- Public Member Functions inherited from GaudiHandle< T >
 GaudiHandle (const GaudiHandle &other)
 Copy constructor needed for correct ref-counting.
 
GaudiHandleoperator= (const GaudiHandle &other)
 Assignment operator for correct ref-counting.
 
StatusCode retrieve () const
 Retrieve the component.
 
StatusCode release () const
 Release the component.
 
 operator bool () const
 For testing if handle has component.
 
T & operator* ()
 
T * operator-> ()
 
T & operator* () const
 
T * operator-> () const
 
std::string getDefaultType ()
 Helper function to get default type string from the class type.
 
std::string getDefaultName ()
 
- Public Member Functions inherited from GaudiHandleBase
std::string typeAndName () const
 The full type and name: "type/name".
 
std::string type () const
 The concrete component class name: the part before the '/'.
 
std::string name () const
 The instance name: the part after the '/'.
 
bool empty () const
 Check if the handle has been set to empty string (i.e.
 
void setTypeAndName (const std::string &myTypeAndName)
 The component "type/name" string.
 
void setName (const std::string &myName)
 Set the instance name (part after the '/') without changing the class type.
 
const std::string pythonPropertyClassName () const
 Name of the componentType with "Handle" appended.
 
const std::string messageName () const
 name used for printing messages
 
virtual const std::string pythonRepr () const
 Python representation of handle, i.e.
 
- Public Member Functions inherited from GaudiHandleInfo
virtual ~GaudiHandleInfo ()
 virtual destructor so that derived class destructor is called.
 
const std::stringcomponentType () const
 
const std::stringpropertyName () const
 name as used in declareProperty(name,gaudiHandle)
 
void setPropertyName (const std::string &propName)
 set name as used in declareProperty(name,gaudiHandle).
 
const std::stringparentName () const
 The name of the parent.
 

Protected Member Functions

StatusCode retrieve (T *&service) const
 Release the Service.
 
- Protected Member Functions inherited from GaudiHandle< T >
 GaudiHandle (const std::string &myTypeAndName, const std::string &myComponentType, const std::string &myParentName)
 
virtual StatusCode release (T *comp) const
 Release the component.
 
- Protected Member Functions inherited from GaudiHandleBase
 GaudiHandleBase (const std::string &myTypeAndName, const std::string &myComponentType, const std::string &myParentName)
 Create a handle ('smart pointer') to a gaudi component.
 
- Protected Member Functions inherited from GaudiHandleInfo
 GaudiHandleInfo (const std::string &myComponentType, const std::string &myParentName)
 Some basic information and helper functions shared between various handles/arrays.
 

Private Member Functions

SmartIF< ISvcLocator > & serviceLocator () const
 Do the real release of the Service.
 
SmartIF< IMessageSvc > & messageSvc () const
 

Private Attributes

SmartIF< ISvcLocatorm_pSvcLocator
 
SmartIF< IMessageSvcm_pMessageSvc
 

Detailed Description

template<class T>
class ServiceHandle< T >

Handle to be used in lieu of naked pointers to services.

This allows better control through the framework of service loading and usage.

Author
Marti.nosp@m.n.Wo.nosp@m.udstr.nosp@m.a@ce.nosp@m.rn.ch

Definition at line 25 of file PropertyMgr.h.

Constructor & Destructor Documentation

template<class T>
ServiceHandle< T >::ServiceHandle ( const std::string serviceName,
const std::string theParentName 
)
inline

Create a handle ('smart pointer') to a service.

The arguments are passed on to ServiceSvc, and have the same meaning:

Parameters
serviceNamename of the service
parentNamename of the parent Algorithm, AlgTool or Service. It is used for log printout at retrieve(), and for retrieving a thread-dependent service (if applicable)

Definition at line 42 of file ServiceHandle.h.

: GaudiHandle<T>(serviceName, "Service", theParentName)
{}

Member Function Documentation

template<class T>
SmartIF<IMessageSvc>& ServiceHandle< T >::messageSvc ( ) const
inlineprivate

Definition at line 84 of file ServiceHandle.h.

{ // not really const, because it may change m_pMessageSvc
if ( !m_pMessageSvc.isValid() ) {
m_pMessageSvc = serviceLocator(); // default message service
throw GaudiException("Service [MessageSvc] not found",
}
}
return m_pMessageSvc;
}
template<class T>
StatusCode ServiceHandle< T >::retrieve ( ) const
inline

Retrieve the Service.

Release existing Service if needed. Function must be repeated here to avoid hiding the function retrieve( T*& )

Definition at line 48 of file ServiceHandle.h.

{ // not really const, because it updates m_pObject
}
template<class T>
StatusCode ServiceHandle< T >::retrieve ( T *&  service) const
inlineprotectedvirtual

Release the Service.

Function must be repeated here to avoid hiding the function release( T*& ) Do the real retrieval of the Service.

Implements GaudiHandle< T >.

Definition at line 60 of file ServiceHandle.h.

{
return helper.getService(GaudiHandleBase::typeAndName(), true, T::interfaceID(), (void**)&service);
}
template<class T>
SmartIF<ISvcLocator>& ServiceHandle< T >::serviceLocator ( ) const
inlineprivate

Do the real release of the Service.

Definition at line 74 of file ServiceHandle.h.

{ // not really const, because it may change m_pSvcLocator
if ( !m_pSvcLocator.isValid() ) {
if ( !m_pSvcLocator.isValid() ) {
throw GaudiException("SvcLocator not found", "Core component not found", StatusCode::FAILURE);
}
}
return m_pSvcLocator;
}

Member Data Documentation

template<class T>
SmartIF<IMessageSvc> ServiceHandle< T >::m_pMessageSvc
mutableprivate

Definition at line 98 of file ServiceHandle.h.

template<class T>
SmartIF<ISvcLocator> ServiceHandle< T >::m_pSvcLocator
mutableprivate

Definition at line 97 of file ServiceHandle.h.


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

Generated at Mon Feb 17 2014 14:38:10 for Gaudi Framework, version v25r0 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004