The Gaudi Framework  v29r0 (ff2e7097)
PublicToolHandle< T > Class Template Reference

Helper class to construct ToolHandle instances for public tools via the auto registering constructor. More...

#include <GaudiKernel/ToolHandle.h>

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

Public Member Functions

 PublicToolHandle (bool createIf=true)
 
 PublicToolHandle (const char *toolTypeAndName, bool createIf=true)
 
 PublicToolHandle (const std::string &toolTypeAndName, bool createIf=true)
 
template<typename CT = T, typename NCT = typename std::remove_const<T>::type>
 PublicToolHandle (const PublicToolHandle< NCT > &other, typename std::enable_if< std::is_const< CT >::value &&!std::is_same< CT, NCT >::value >::type *=nullptr)
 Copy constructor from a non const T to const T tool handle. More...
 
template<class OWNER , typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type>
 PublicToolHandle (OWNER *owner, std::string name, std::string toolType, std::string doc="")
 Autodeclaring constructor with property name, tool type/name and documentation. More...
 
- Public Member Functions inherited from ToolHandle< T >
 ToolHandle (const IInterface *parent=nullptr, bool createIf=true)
 Constructor for a tool with default tool type and name. More...
 
template<typename CT = T, typename NCT = typename std::remove_const<T>::type>
 ToolHandle (const ToolHandle< NCT > &other, typename std::enable_if< std::is_const< CT >::value &&!std::is_same< CT, NCT >::value >::type *=nullptr)
 Copy constructor from a non const T to const T tool handle. More...
 
 ToolHandle (const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
 Create a handle ('smart pointer') to a tool. More...
 
template<class OWNER , typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type>
 ToolHandle (OWNER *owner, std::string name, std::string toolType, std::string doc="")
 Autodeclaring constructor with property name, tool type/name and documentation. More...
 
StatusCode initialize (const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
 
StatusCode retrieve () const
 Retrieve the AlgTool. More...
 
StatusCode release () const
 Release the AlgTool. More...
 
StatusCode retrieve (T *&algTool) const override
 Do the real retrieval of the AlgTool. More...
 
StatusCode release (T *algTool) const override
 Do the real release of the AlgTool. More...
 
std::string typeAndName () const override
 
std::add_const< T >::typeget () const
 
T * get ()
 
- Public Member Functions inherited from BaseToolHandle
StatusCode retrieve (IAlgTool *&tool) const
 
const IAlgToolget () const
 
IAlgToolget ()
 
- Public Member Functions inherited from ToolHandleInfo
virtual ~ToolHandleInfo ()=default
 
bool isPublic () const noexcept
 
bool createIf () const noexcept
 
const IInterfaceparent () const noexcept
 
- Public Member Functions inherited from GaudiHandle< T >
template<typename CT = T, typename NCT = typename std::remove_const<T>::type>
 GaudiHandle (const GaudiHandle< NCT > &other, typename std::enable_if< std::is_const< CT >::value &&!std::is_same< CT, NCT >::value >::type *=nullptr)
 Copy constructor needed for correct ref-counting. More...
 
 GaudiHandle (const GaudiHandle &other)
 Copy constructor needed for correct ref-counting. More...
 
template<typename CT = T, typename NCT = typename std::remove_const<T>::type>
std::enable_if< std::is_const< CT >::value &&!std::is_same< CT, NCT >::value, GaudiHandle & >::type operator= (const GaudiHandle< NCT > &other)
 Assignment operator 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 ()
 Return the wrapped pointer, not calling retrieve() if null. More...
 
std::add_const< T >::typeget () 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-> ()
 
std::add_const< T >::typeoperator* () const
 
std::add_const< T >::typeoperator-> () 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 (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...
 
std::string pythonPropertyClassName () const override
 Name of the componentType with "Handle" appended. More...
 
std::string messageName () const
 name used for printing messages More...
 
std::string pythonRepr () const override
 Python representation of handle, i.e. More...
 
- Public Member Functions inherited from GaudiHandleInfo
virtual ~GaudiHandleInfo ()=default
 virtual destructor so that derived class destructor is called. More...
 
const std::stringcomponentType () const
 
const std::stringpropertyName () const
 name as used in declareProperty(name,gaudiHandle) More...
 
void setPropertyName (std::string propName)
 set name as used in declareProperty(name,gaudiHandle). More...
 
const std::stringparentName () const
 The name of the parent. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ToolHandleInfo
static std::string toolComponentType (const IInterface *parent)
 
static std::string toolParentName (const IInterface *parent)
 
- Protected Member Functions inherited from ToolHandle< T >
const IAlgToolgetAsIAlgTool () const override
 
IAlgToolgetAsIAlgTool () override
 
StatusCode i_retrieve (IAlgTool *&algTool) const override
 
- Protected Member Functions inherited from BaseToolHandle
 BaseToolHandle (const IInterface *parent=nullptr, bool createIf=true)
 
- Protected Member Functions inherited from ToolHandleInfo
 ToolHandleInfo (const IInterface *parent=nullptr, bool createIf=true)
 
- Protected Member Functions inherited from GaudiHandle< T >
 GaudiHandle (std::string myTypeAndName, std::string myComponentType, std::string myParentName)
 
template<class CLASS >
std::remove_const< CLASS >::typenonConst (CLASS *p) const
 Cast a pointer to a non const type. More...
 
- Protected Member Functions inherited from GaudiHandleBase
 GaudiHandleBase (std::string myTypeAndName, std::string myComponentType, std::string myParentName)
 Create a handle ('smart pointer') to a gaudi component. More...
 
- Protected Member Functions inherited from GaudiHandleInfo
 GaudiHandleInfo (std::string myComponentType, std::string myParentName)
 Some basic information and helper functions shared between various handles/arrays. More...
 
void setComponentType (const std::string &componentType)
 The component type. More...
 
void setParentName (const std::string &parent)
 The name of the parent. More...
 
- Protected Attributes inherited from ToolHandleInfo
const IInterfacem_parent = nullptr
 
bool m_createIf {true}
 

Detailed Description

template<class T>
class PublicToolHandle< T >

Helper class to construct ToolHandle instances for public tools via the auto registering constructor.

Definition at line 275 of file ToolHandle.h.

Constructor & Destructor Documentation

template<class T>
PublicToolHandle< T >::PublicToolHandle ( bool  createIf = true)
inline

Definition at line 278 of file ToolHandle.h.

278 : ToolHandle<T>( nullptr, createIf ) {}
Handle to be used in lieu of naked pointers to tools.
bool createIf() const noexcept
Definition: ToolHandle.h:39
template<class T>
PublicToolHandle< T >::PublicToolHandle ( const char *  toolTypeAndName,
bool  createIf = true 
)
inline

Definition at line 279 of file ToolHandle.h.

280  : PublicToolHandle{std::string{toolTypeAndName}, createIf}
281  {
282  }
STL class.
Helper class to construct ToolHandle instances for public tools via the auto registering constructor...
Definition: ToolHandle.h:275
bool createIf() const noexcept
Definition: ToolHandle.h:39
template<class T>
PublicToolHandle< T >::PublicToolHandle ( const std::string toolTypeAndName,
bool  createIf = true 
)
inline

Definition at line 283 of file ToolHandle.h.

284  : ToolHandle<T>( toolTypeAndName, nullptr, createIf )
285  {
286  }
Handle to be used in lieu of naked pointers to tools.
bool createIf() const noexcept
Definition: ToolHandle.h:39
template<class T>
template<typename CT = T, typename NCT = typename std::remove_const<T>::type>
PublicToolHandle< T >::PublicToolHandle ( const PublicToolHandle< NCT > &  other,
typename std::enable_if< std::is_const< CT >::value &&!std::is_same< CT, NCT >::value >::type = nullptr 
)
inline

Copy constructor from a non const T to const T tool handle.

Definition at line 290 of file ToolHandle.h.

293  : ToolHandle<T>( static_cast<const ToolHandle<NCT>&>( other ) )
294  {
295  }
Handle to be used in lieu of naked pointers to tools.
template<class T>
template<class OWNER , typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type>
PublicToolHandle< T >::PublicToolHandle ( OWNER *  owner,
std::string  name,
std::string  toolType,
std::string  doc = "" 
)
inline

Autodeclaring constructor with property name, tool type/name and documentation.

Note
the use std::enable_if is required to avoid ambiguities

Definition at line 300 of file ToolHandle.h.

301  : PublicToolHandle()
302  {
303  // convert name and type to a valid type/name string
304  // - if type does not contain '/' use type/name
305  // - otherwise type is already a type/name string
306  if ( !toolType.empty() and toolType.find( '/' ) == std::string::npos ) {
307  toolType += '/';
308  toolType += name;
309  }
310  owner->declareTool( *this, std::move( toolType ) ).ignore();
311  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( name ), *this, std::move( doc ) );
312  p->template setOwnerType<OWNER>();
313  }
T empty(T...args)
T move(T...args)
PublicToolHandle(bool createIf=true)
Definition: ToolHandle.h:278
T find(T...args)
std::string name() const
The instance name: the part after the &#39;/&#39;.
Definition: GaudiHandle.cpp:23

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