ToolHandle< T > Class Template Reference

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

#include <GaudiKernel/ToolHandle.h>

Inheritance diagram for ToolHandle< T >:
Collaboration diagram for ToolHandle< T >:

Public Member Functions

 ToolHandle (int)=delete
 Constructor for a tool with default tool type and name. More...
 
 ToolHandle (std::nullptr_t)=delete
 
 ToolHandle (const IInterface *parent=0, bool createIf=true)
 
 ToolHandle (const std::string &toolTypeAndName, const IInterface *parent=0, bool createIf=true)
 Create a handle ('smart pointer') to a tool. More...
 
StatusCode retrieve () const
 Retrieve the AlgTool. More...
 
StatusCode release () const
 Release the AlgTool. More...
 
virtual StatusCode retrieve (T *&algTool) const
 Do the real retrieval of the AlgTool. More...
 
virtual StatusCode release (T *algTool) const
 Do the real release of the AlgTool. More...
 
 ToolHandle (int)=delete
 Constructor for a tool with default tool type and name. More...
 
 ToolHandle (std::nullptr_t)=delete
 
 ToolHandle (const IInterface *parent=0, bool createIf=true)
 
 ToolHandle (const std::string &toolTypeAndName, const IInterface *parent=0, bool createIf=true)
 Create a handle ('smart pointer') to a tool. More...
 
StatusCode retrieve () const
 Retrieve the AlgTool. More...
 
StatusCode release () const
 Release the AlgTool. More...
 
virtual StatusCode retrieve (T *&algTool) const
 Do the real retrieval of the AlgTool. More...
 
virtual StatusCode release (T *algTool) const
 Do the real release of the AlgTool. More...
 
- Public Member Functions inherited from ToolHandleInfo
virtual ~ToolHandleInfo ()
 
bool isPublic () const
 
bool createIf () const
 
const IInterfaceparent () const
 
const std::string toolComponentType (const IInterface *parent) const
 
const std::string toolParentName (const IInterface *parent) const
 
virtual ~ToolHandleInfo ()
 
bool isPublic () const
 
bool createIf () const
 
const IInterfaceparent () const
 
const std::string toolComponentType (const IInterface *parent) const
 
const std::string toolParentName (const IInterface *parent) const
 
- Public Member Functions inherited from GaudiHandle< T >
 GaudiHandle (const GaudiHandle &other)
 Copy constructor needed for correct ref-counting. More...
 
GaudiHandleoperator= (const GaudiHandle &other)
 Assignment operator for correct ref-counting. More...
 
StatusCode retrieve () const
 Retrieve the component. More...
 
StatusCode release () const
 Release the component. More...
 
bool isValid () const
 Check if the handle is valid (try to retrive the object is not done yet). More...
 
 operator bool () const
 For testing if handle has component. More...
 
T * get () const
 Return the wrapped pointer, not calling retrieve() if null. More...
 
bool isSet () const
 True if the wrapped pointer is not null. More...
 
T & operator* ()
 
T * operator-> ()
 
T & operator* () const
 
T * operator-> () const
 
std::string getDefaultType ()
 Helper function to get default type string from the class type. More...
 
std::string getDefaultName ()
 
 GaudiHandle (const GaudiHandle &other)
 Copy constructor needed for correct ref-counting. More...
 
GaudiHandleoperator= (const GaudiHandle &other)
 Assignment operator for correct ref-counting. More...
 
StatusCode retrieve () const
 Retrieve the component. More...
 
StatusCode release () const
 Release the component. More...
 
bool isValid () const
 Check if the handle is valid (try to retrive the object is not done yet). More...
 
 operator bool () const
 For testing if handle has component. More...
 
T * get () const
 Return the wrapped pointer, not calling retrieve() if null. More...
 
bool isSet () const
 True if the wrapped pointer is not null. More...
 
T & operator* ()
 
T * operator-> ()
 
T & operator* () const
 
T * operator-> () const
 
std::string getDefaultType ()
 Helper function to get default type string from the class type. More...
 
std::string getDefaultName ()
 
- Public Member Functions inherited from GaudiHandleBase
std::string typeAndName () const
 The full type and name: "type/name". More...
 
std::string type () const
 The concrete component class name: the part before the '/'. More...
 
std::string name () const
 The instance name: the part after the '/'. More...
 
bool empty () const
 Check if the handle has been set to empty string (i.e. More...
 
void setTypeAndName (const std::string &myTypeAndName)
 The component "type/name" string. More...
 
void setName (const std::string &myName)
 Set the instance name (part after the '/') without changing the class type. More...
 
const std::string pythonPropertyClassName () const
 Name of the componentType with "Handle" appended. More...
 
const std::string messageName () const
 name used for printing messages More...
 
virtual const std::string pythonRepr () const
 Python representation of handle, i.e. More...
 
std::string typeAndName () const
 The full type and name: "type/name". More...
 
std::string type () const
 The concrete component class name: the part before the '/'. More...
 
std::string name () const
 The instance name: the part after the '/'. More...
 
bool empty () const
 Check if the handle has been set to empty string (i.e. More...
 
void setTypeAndName (const std::string &myTypeAndName)
 The component "type/name" string. More...
 
void setName (const std::string &myName)
 Set the instance name (part after the '/') without changing the class type. More...
 
const std::string pythonPropertyClassName () const
 Name of the componentType with "Handle" appended. More...
 
const std::string messageName () const
 name used for printing messages More...
 
virtual const std::string pythonRepr () const
 Python representation of handle, i.e. More...
 
- Public Member Functions inherited from GaudiHandleInfo
virtual ~GaudiHandleInfo ()
 virtual destructor so that derived class destructor is called. More...
 
const std::string & componentType () const
 
const std::string & propertyName () const
 name as used in declareProperty(name,gaudiHandle) More...
 
void setPropertyName (const std::string &propName)
 set name as used in declareProperty(name,gaudiHandle). More...
 
const std::string & parentName () const
 The name of the parent. More...
 
virtual ~GaudiHandleInfo ()
 virtual destructor so that derived class destructor is called. More...
 
const std::string & componentType () const
 
const std::string & propertyName () const
 name as used in declareProperty(name,gaudiHandle) More...
 
void setPropertyName (const std::string &propName)
 set name as used in declareProperty(name,gaudiHandle). More...
 
const std::string & parentName () const
 The name of the parent. More...
 

Private Attributes

ServiceHandle< IToolSvcm_pToolSvc
 

Additional Inherited Members

- Protected Member Functions inherited from ToolHandleInfo
 ToolHandleInfo (const IInterface *parent=0, bool createIf=true)
 
 ToolHandleInfo (const IInterface *parent=0, bool createIf=true)
 
- Protected Member Functions inherited from GaudiHandle< T >
 GaudiHandle (const std::string &myTypeAndName, const std::string &myComponentType, const std::string &myParentName)
 
 GaudiHandle (const std::string &myTypeAndName, const std::string &myComponentType, const std::string &myParentName)
 
- 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. More...
 
 GaudiHandleBase (const std::string &myTypeAndName, const std::string &myComponentType, const std::string &myParentName)
 Create a handle ('smart pointer') to a gaudi component. More...
 
- 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. More...
 
 GaudiHandleInfo (const std::string &myComponentType, const std::string &myParentName)
 Some basic information and helper functions shared between various handles/arrays. More...
 

Detailed Description

template<class T>
class ToolHandle< T >

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

This allows better control through the framework of tool loading and usage. T is the AlgTool interface class (or concrete class) of the tool to use, and must derive from IAlgTool.

Author
Wim Lavrijsen WLavr.nosp@m.ijse.nosp@m.n@lbl.nosp@m..gov
Marti.nosp@m.n.Wo.nosp@m.udstr.nosp@m.a@ce.nosp@m.rn.ch

Definition at line 20 of file PropertyMgr.h.

Constructor & Destructor Documentation

template<class T>
ToolHandle< T >::ToolHandle ( int  )
delete

Constructor for a tool with default tool type and name.

Can be called only if the type T is a concrete tool type (not an interface), and you want to use the default name.

template<class T>
ToolHandle< T >::ToolHandle ( std::nullptr_t  )
delete
template<class T>
ToolHandle< T >::ToolHandle ( const IInterface parent = 0,
bool  createIf = true 
)
inlineexplicit

Definition at line 91 of file ToolHandle.h.

92  : ToolHandleInfo(parent,createIf),
97  {}
Handle to be used in lieu of naked pointers to gaudis.
Definition: GaudiHandle.h:158
std::string getDefaultType()
Helper function to get default type string from the class type.
Definition: GaudiHandle.h:249
const std::string toolParentName(const IInterface *parent) const
Definition: ToolHandle.h:49
const std::string & parentName() const
The name of the parent.
Definition: GaudiHandle.h:48
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:152
const std::string toolComponentType(const IInterface *parent) const
Definition: ToolHandle.h:45
bool createIf() const
Definition: ToolHandle.h:34
ToolHandleInfo(const IInterface *parent=0, bool createIf=true)
Definition: ToolHandle.h:23
template<class T>
ToolHandle< T >::ToolHandle ( const std::string &  toolTypeAndName,
const IInterface parent = 0,
bool  createIf = true 
)
inline

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

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

StatusCode ToolSvc::retrieveTool ( const std::string& type ,
T*& tool ,
const IInterface* parent = 0 ,
bool createIf = true )
Parameters
toolType"MyToolType/MyToolName" "MyToolType" is short for "MyToolType/MyToolType" 'MyToolType' is the name of the class of the concrete tool 'MyToolName' is to distinguish several tool instances of the same class
parentthe parent Algorithm,Tool or Service of which this tool is a member. If non-zero, the the tool is a private tool of the parent, otherwise it is a public (shared) tool.
createIfif true, create tool if not yet existing.

Definition at line 116 of file ToolHandle.h.

117  : ToolHandleInfo(parent,createIf),
118  GaudiHandle<T>( toolTypeAndName,
122  {}
Handle to be used in lieu of naked pointers to gaudis.
Definition: GaudiHandle.h:158
const std::string toolParentName(const IInterface *parent) const
Definition: ToolHandle.h:49
const std::string & parentName() const
The name of the parent.
Definition: GaudiHandle.h:48
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:152
const std::string toolComponentType(const IInterface *parent) const
Definition: ToolHandle.h:45
bool createIf() const
Definition: ToolHandle.h:34
ToolHandleInfo(const IInterface *parent=0, bool createIf=true)
Definition: ToolHandle.h:23
template<class T>
ToolHandle< T >::ToolHandle ( int  )
delete

Constructor for a tool with default tool type and name.

Can be called only if the type T is a concrete tool type (not an interface), and you want to use the default name.

template<class T>
ToolHandle< T >::ToolHandle ( std::nullptr_t  )
delete
template<class T>
ToolHandle< T >::ToolHandle ( const IInterface parent = 0,
bool  createIf = true 
)
inlineexplicit

Definition at line 91 of file ToolHandle.h.

92  : ToolHandleInfo(parent,createIf),
97  {}
Handle to be used in lieu of naked pointers to gaudis.
Definition: GaudiHandle.h:158
std::string getDefaultType()
Helper function to get default type string from the class type.
Definition: GaudiHandle.h:249
const std::string toolParentName(const IInterface *parent) const
Definition: ToolHandle.h:49
const std::string & parentName() const
The name of the parent.
Definition: GaudiHandle.h:48
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:152
const std::string toolComponentType(const IInterface *parent) const
Definition: ToolHandle.h:45
bool createIf() const
Definition: ToolHandle.h:34
ToolHandleInfo(const IInterface *parent=0, bool createIf=true)
Definition: ToolHandle.h:23
template<class T>
ToolHandle< T >::ToolHandle ( const std::string &  toolTypeAndName,
const IInterface parent = 0,
bool  createIf = true 
)
inline

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

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

StatusCode ToolSvc::retrieveTool ( const std::string& type ,
T*& tool ,
const IInterface* parent = 0 ,
bool createIf = true )
Parameters
toolType"MyToolType/MyToolName" "MyToolType" is short for "MyToolType/MyToolType" 'MyToolType' is the name of the class of the concrete tool 'MyToolName' is to distinguish several tool instances of the same class
parentthe parent Algorithm,Tool or Service of which this tool is a member. If non-zero, the the tool is a private tool of the parent, otherwise it is a public (shared) tool.
createIfif true, create tool if not yet existing.

Definition at line 116 of file ToolHandle.h.

117  : ToolHandleInfo(parent,createIf),
118  GaudiHandle<T>( toolTypeAndName,
122  {}
Handle to be used in lieu of naked pointers to gaudis.
Definition: GaudiHandle.h:158
const std::string toolParentName(const IInterface *parent) const
Definition: ToolHandle.h:49
const std::string & parentName() const
The name of the parent.
Definition: GaudiHandle.h:48
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:152
const std::string toolComponentType(const IInterface *parent) const
Definition: ToolHandle.h:45
bool createIf() const
Definition: ToolHandle.h:34
ToolHandleInfo(const IInterface *parent=0, bool createIf=true)
Definition: ToolHandle.h:23

Member Function Documentation

template<class T>
StatusCode ToolHandle< T >::release ( ) const
inline

Release the AlgTool.

Function must be repeated here to avoid hiding the function release( T*& )

Definition at line 132 of file ToolHandle.h.

132  { // not really const, because it updates m_pObject
133  return GaudiHandle<T>::release();
134  }
StatusCode release() const
Release the component.
Definition: GaudiHandle.h:198
template<class T>
StatusCode ToolHandle< T >::release ( ) const
inline

Release the AlgTool.

Function must be repeated here to avoid hiding the function release( T*& )

Definition at line 132 of file ToolHandle.h.

132  { // not really const, because it updates m_pObject
133  return GaudiHandle<T>::release();
134  }
StatusCode release() const
Release the component.
Definition: GaudiHandle.h:198
template<class T>
virtual StatusCode ToolHandle< T >::release ( T *  algTool) const
inlinevirtual

Do the real release of the AlgTool.

Reimplemented from GaudiHandle< T >.

Definition at line 144 of file ToolHandle.h.

144  {
145  return m_pToolSvc->releaseTool( algTool );
146  }
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:152
template<class T>
virtual StatusCode ToolHandle< T >::release ( T *  algTool) const
inlinevirtual

Do the real release of the AlgTool.

Reimplemented from GaudiHandle< T >.

Definition at line 144 of file ToolHandle.h.

144  {
145  return m_pToolSvc->releaseTool( algTool );
146  }
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:152
template<class T>
StatusCode ToolHandle< T >::retrieve ( ) const
inline

Retrieve the AlgTool.

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

Definition at line 126 of file ToolHandle.h.

126  { // not really const, because it updates m_pObject
127  return GaudiHandle<T>::retrieve();
128  }
StatusCode retrieve() const
Retrieve the component.
Definition: GaudiHandle.h:188
template<class T>
StatusCode ToolHandle< T >::retrieve ( ) const
inline

Retrieve the AlgTool.

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

Definition at line 126 of file ToolHandle.h.

126  { // not really const, because it updates m_pObject
127  return GaudiHandle<T>::retrieve();
128  }
StatusCode retrieve() const
Retrieve the component.
Definition: GaudiHandle.h:188
template<class T>
virtual StatusCode ToolHandle< T >::retrieve ( T *&  algTool) const
inlinevirtual

Do the real retrieval of the AlgTool.

Implements GaudiHandle< T >.

Definition at line 137 of file ToolHandle.h.

137  {
138  return m_pToolSvc->retrieve( GaudiHandleBase::typeAndName(), T::interfaceID(),
139  (IAlgTool*&)(algTool),
141  }
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:152
const IInterface * parent() const
Definition: ToolHandle.h:38
StatusCode retrieve() const
Retrieve the Service.
Definition: ServiceHandle.h:48
bool createIf() const
Definition: ToolHandle.h:34
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
std::string typeAndName() const
The full type and name: "type/name".
Definition: GaudiHandle.h:107
template<class T>
virtual StatusCode ToolHandle< T >::retrieve ( T *&  algTool) const
inlinevirtual

Do the real retrieval of the AlgTool.

Implements GaudiHandle< T >.

Definition at line 137 of file ToolHandle.h.

137  {
138  return m_pToolSvc->retrieve( GaudiHandleBase::typeAndName(), T::interfaceID(),
139  (IAlgTool*&)(algTool),
141  }
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:152
const IInterface * parent() const
Definition: ToolHandle.h:38
StatusCode retrieve() const
Retrieve the Service.
Definition: ServiceHandle.h:48
bool createIf() const
Definition: ToolHandle.h:34
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
std::string typeAndName() const
The full type and name: "type/name".
Definition: GaudiHandle.h:107

Member Data Documentation

template<class T>
ServiceHandle< IToolSvc > ToolHandle< T >::m_pToolSvc
mutableprivate

Definition at line 152 of file ToolHandle.h.


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