#include <GaudiKernel/ToolHandle.h>
Inheritance diagram for ToolHandle< T >:
Public Member Functions | |
ToolHandle (const IInterface *parent=0, bool createIf=true) | |
Constructor for a tool with default tool type and name. | |
ToolHandle (const std::string &toolTypeAndName, const IInterface *parent=0, bool createIf=true) | |
Create a handle ('smart pointer') to a tool. | |
StatusCode | retrieve () const |
Retrieve the AlgTool. | |
StatusCode | release () const |
Release the AlgTool. | |
virtual StatusCode | retrieve (T *&algTool) const |
Do the real retrieval of the AlgTool. | |
virtual StatusCode | release (T *algTool) const |
Do the real release of the AlgTool. | |
bool | isPublic () const |
bool | createIf () const |
const IInterface * | parent () const |
const std::string | toolComponentType (const IInterface *parent) const |
const std::string | toolParentName (const IInterface *parent) const |
operator bool () const | |
For testing if handle has component. | |
T & | operator * () |
T & | operator * () const |
T * | operator-> () |
T * | operator-> () const |
std::string | getDefaultType () |
Helper function to get default type string from the class type. | |
std::string | getDefaultName () |
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. | |
const std::string & | componentType () const |
const std::string & | propertyName () const |
name as used in declareProperty(name,gaudiHandle) | |
void | setPropertyName (const std::string &propName) |
set name as used in declareProperty(name,gaudiHandle). | |
const std::string & | parentName () const |
The name of the parent. | |
Private Attributes | |
ServiceHandle< IToolSvc > | m_pToolSvc |
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.
Definition at line 77 of file ToolHandle.h.
ToolHandle< T >::ToolHandle | ( | const IInterface * | parent = 0 , |
|
bool | createIf = true | |||
) | [inline] |
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.
Definition at line 85 of file ToolHandle.h.
00086 : ToolHandleInfo(parent,createIf), 00087 GaudiHandle<T>( GaudiHandle<T>::getDefaultType(), 00088 ToolHandleInfo::toolComponentType(parent), 00089 ToolHandleInfo::toolParentName(parent) ), 00090 m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) 00091 {}
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 )
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 | |
parent,: | the 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. | |
createIf,: | if true, create tool if not yet existing. |
Definition at line 110 of file ToolHandle.h.
00111 : ToolHandleInfo(parent,createIf), 00112 GaudiHandle<T>( toolTypeAndName, 00113 ToolHandleInfo::toolComponentType(parent), 00114 ToolHandleInfo::toolParentName(parent) ), 00115 m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) 00116 {}
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*& )
Reimplemented from GaudiHandle< T >.
Definition at line 120 of file ToolHandle.h.
00120 { // not really const, because it updates m_pObject 00121 return GaudiHandle<T>::retrieve(); 00122 }
StatusCode ToolHandle< T >::release | ( | ) | const [inline] |
Release the AlgTool.
Function must be repeated here to avoid hiding the function release( T*& )
Reimplemented from GaudiHandle< T >.
Definition at line 126 of file ToolHandle.h.
00126 { // not really const, because it updates m_pObject 00127 return GaudiHandle<T>::release(); 00128 }
virtual StatusCode ToolHandle< T >::retrieve | ( | T *& | algTool | ) | const [inline, virtual] |
Do the real retrieval of the AlgTool.
Implements GaudiHandle< T >.
Definition at line 131 of file ToolHandle.h.
00131 { 00132 return m_pToolSvc->retrieve( GaudiHandleBase::typeAndName(), T::interfaceID(), 00133 (IAlgTool*&)(algTool), 00134 ToolHandleInfo::parent(), ToolHandleInfo::createIf() ); 00135 }
virtual StatusCode ToolHandle< T >::release | ( | T * | algTool | ) | const [inline, virtual] |
Do the real release of the AlgTool.
Reimplemented from GaudiHandle< T >.
Definition at line 138 of file ToolHandle.h.
00138 { 00139 return m_pToolSvc->releaseTool( algTool ); 00140 }
bool ToolHandleInfo::isPublic | ( | ) | const [inline, inherited] |
bool ToolHandleInfo::createIf | ( | ) | const [inline, inherited] |
const IInterface* ToolHandleInfo::parent | ( | ) | const [inline, inherited] |
const std::string ToolHandleInfo::toolComponentType | ( | const IInterface * | parent | ) | const [inline, inherited] |
Definition at line 44 of file ToolHandle.h.
00044 { 00045 return parent ? "PrivateTool" : "PublicTool"; 00046 }
const std::string ToolHandleInfo::toolParentName | ( | const IInterface * | parent | ) | const [inline, inherited] |
Definition at line 48 of file ToolHandle.h.
00048 { 00049 if (parent) { 00050 const INamedInterface* pNamed = dynamic_cast<const INamedInterface*>(parent); 00051 if (pNamed) { 00052 return pNamed->name(); 00053 } else { 00054 return ""; 00055 } 00056 } else { 00057 return "ToolSvc"; 00058 } 00059 }
GaudiHandle< T >::operator bool | ( | ) | const [inline, inherited] |
For testing if handle has component.
Does retrieve() if needed. If this returns false, the component could not be retrieved.
Definition at line 209 of file GaudiHandle.h.
00209 { // not really const, because it may update m_pObject 00210 return getObject(); 00211 }
T& GaudiHandle< T >::operator * | ( | ) | [inline, inherited] |
Definition at line 213 of file GaudiHandle.h.
00213 { 00214 assertObject(); 00215 return *m_pObject; 00216 }
T& GaudiHandle< T >::operator * | ( | ) | const [inline, inherited] |
Definition at line 223 of file GaudiHandle.h.
00223 { // not really const, because it may update m_pObject 00224 assertObject(); 00225 return *m_pObject; 00226 }
T* GaudiHandle< T >::operator-> | ( | ) | [inline, inherited] |
Definition at line 218 of file GaudiHandle.h.
00218 { 00219 assertObject(); 00220 return m_pObject; 00221 }
T* GaudiHandle< T >::operator-> | ( | ) | const [inline, inherited] |
Definition at line 228 of file GaudiHandle.h.
00228 { // not really const, because it may update m_pObject 00229 assertObject(); 00230 return m_pObject; 00231 }
std::string GaudiHandle< T >::getDefaultType | ( | ) | [inline, inherited] |
Helper function to get default type string from the class type.
Definition at line 234 of file GaudiHandle.h.
00234 { 00235 return System::typeinfoName( typeid(T) ); 00236 }
std::string GaudiHandle< T >::getDefaultName | ( | ) | [inline, inherited] |
Definition at line 238 of file GaudiHandle.h.
00238 { 00239 std::string defName = GaudiHandleBase::type(); 00240 if ( defName.empty() ) defName = getDefaultType(); 00241 return defName; 00242 }
std::string GaudiHandleBase::typeAndName | ( | ) | const [inline, inherited] |
The full type and name: "type/name".
Definition at line 107 of file GaudiHandle.h.
00107 { 00108 return m_typeAndName; 00109 }
std::string GaudiHandleBase::type | ( | ) | const [inherited] |
The concrete component class name: the part before the '/'.
std::string GaudiHandleBase::name | ( | ) | const [inherited] |
The instance name: the part after the '/'.
bool GaudiHandleBase::empty | ( | ) | const [inline, inherited] |
Check if the handle has been set to empty string (i.e.
typeAndName string is empty).
Definition at line 118 of file GaudiHandle.h.
00118 { 00119 return m_typeAndName.empty(); 00120 }
void GaudiHandleBase::setTypeAndName | ( | const std::string & | myTypeAndName | ) | [inherited] |
The component "type/name" string.
void GaudiHandleBase::setName | ( | const std::string & | myName | ) | [inherited] |
Set the instance name (part after the '/') without changing the class type.
const std::string GaudiHandleBase::pythonPropertyClassName | ( | ) | const [virtual, inherited] |
Name of the componentType with "Handle" appended.
Used as the python class name for the property in the genconf-generated configurables. The python class is defined in GaudiPython/python/GaudiHandles.py.
Implements GaudiHandleInfo.
const std::string GaudiHandleBase::messageName | ( | ) | const [inherited] |
name used for printing messages
virtual const std::string GaudiHandleBase::pythonRepr | ( | ) | const [virtual, inherited] |
Python representation of handle, i.e.
python class name and argument. Can be used in the genconf-generated configurables. The corresponding python classes are defined in GaudiPython/GaudiHandles.py
Implements GaudiHandleInfo.
const std::string& GaudiHandleInfo::componentType | ( | ) | const [inline, inherited] |
const std::string& GaudiHandleInfo::propertyName | ( | ) | const [inline, inherited] |
name as used in declareProperty(name,gaudiHandle)
Definition at line 38 of file GaudiHandle.h.
00038 { 00039 return m_propertyName; 00040 }
void GaudiHandleInfo::setPropertyName | ( | const std::string & | propName | ) | [inline, inherited] |
set name as used in declareProperty(name,gaudiHandle).
Used in printout.
Definition at line 43 of file GaudiHandle.h.
00043 { 00044 m_propertyName = propName; 00045 }
const std::string& GaudiHandleInfo::parentName | ( | ) | const [inline, inherited] |
The name of the parent.
Definition at line 48 of file GaudiHandle.h.
00048 { 00049 return m_parentName; 00050 }
ServiceHandle<IToolSvc> ToolHandle< T >::m_pToolSvc [mutable, private] |
Definition at line 146 of file ToolHandle.h.