The Gaudi Framework  master (d98a2936)
PublicToolHandle< T > Class Template Reference

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

#include </builds/gaudi/Gaudi/GaudiKernel/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 = std::remove_const_t<T>>
 requires (std::is_const_v< CT > &&!std::is_same_v< CT, NCT >) PublicToolHandle(const PublicToolHandle< NCT > &other)
 Copy constructor from a non const T to const T tool handle. More...
 
template<std::derived_from< IProperty > OWNER>
 PublicToolHandle (OWNER *owner, std::string propName, std::string toolType, std::string doc="")
 Autodeclaring constructor with property propName, 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 = std::remove_const_t<T>>
 requires (std::is_const_v< CT > &&!std::is_same_v< CT, NCT >) ToolHandle(const ToolHandle< NCT > &other)
 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<std::derived_from< IProperty > OWNER>
 ToolHandle (OWNER *owner, std::string propName, std::string toolType, std::string doc="")
 Autodeclaring constructor with property propName, tool type/name and documentation. More...
 
template<typename... Args>
 ToolHandle (std::tuple< Args... > &&args)
 
StatusCode initialize (const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
 
StatusCode retrieve () const override
 Retrieve the AlgTool. More...
 
StatusCode retrieve (DisableTool sd) override
 
StatusCode retrieve (EnableTool sd) override
 
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< T > * get () const
 
T * get ()
 
- Public Member Functions inherited from BaseToolHandle
StatusCode retrieve (IAlgTool *&tool) const
 
const IAlgToolget () const
 
IAlgToolget ()
 
bool isEnabled () const
 Helper to check if the ToolHandle should be retrieved. More...
 
void enable ()
 
void disable ()
 
bool setEnabled (bool flag)
 
- 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 = std::remove_const_t<T>>
 GaudiHandle (const GaudiHandle< NCT > &other) requires(std
 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 = std::remove_const_t<T>>
 requires (std::is_const_v< CT > &&!std::is_same_v< CT, NCT >) GaudiHandle &operator
 Assignment operator for correct ref-counting. More...
 
- Public Member Functions inherited from GaudiHandleBase
const 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 (std::string_view 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 ()
 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 (std::string propName)
 set name as used in declareProperty(name,gaudiHandle). More...
 
const std::string & parentName () const
 The name of the parent. More...
 

Additional Inherited Members

- Public Types inherited from GaudiHandleBase
using PropertyType = GaudiHandleProperty
 
- 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)
 
- 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 (std::string componentType)
 The component type. More...
 
void setParentName (std::string parent)
 The name of the parent. More...
 
- Protected Attributes inherited from BaseToolHandle
bool m_enabled = true
 
- 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 355 of file ToolHandle.h.

Constructor & Destructor Documentation

◆ PublicToolHandle() [1/4]

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

Definition at line 357 of file ToolHandle.h.

357 : ToolHandle<T>( nullptr, createIf ) {}

◆ PublicToolHandle() [2/4]

template<class T >
PublicToolHandle< T >::PublicToolHandle ( const char *  toolTypeAndName,
bool  createIf = true 
)
inline

Definition at line 358 of file ToolHandle.h.

359  : PublicToolHandle{ std::string{ toolTypeAndName }, createIf } {}

◆ PublicToolHandle() [3/4]

template<class T >
PublicToolHandle< T >::PublicToolHandle ( const std::string &  toolTypeAndName,
bool  createIf = true 
)
inline

Definition at line 360 of file ToolHandle.h.

361  : ToolHandle<T>( toolTypeAndName, nullptr, createIf ) {}

◆ PublicToolHandle() [4/4]

template<class T >
template<std::derived_from< IProperty > OWNER>
PublicToolHandle< T >::PublicToolHandle ( OWNER *  owner,
std::string  propName,
std::string  toolType,
std::string  doc = "" 
)
inline

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

Note
the use of requires is required to avoid ambiguities

Definition at line 372 of file ToolHandle.h.

373  : PublicToolHandle() {
374  // convert name and type to a valid type/name string
375  // - if type does not contain '/' use type/type
376  // - otherwise type is already a type/name string
377  if ( !toolType.empty() and toolType.find( '/' ) == std::string::npos ) { toolType += '/' + toolType; }
378  owner->declareTool( *this, std::move( toolType ) ).ignore();
379  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( propName ), *this, std::move( doc ) );
380  p->template setOwnerType<OWNER>();
381  }

Member Function Documentation

◆ requires()

template<class T >
template<typename CT = T, typename NCT = std::remove_const_t<T>>
PublicToolHandle< T >::requires ( std::is_const_v< CT > &&!std::is_same_v< CT, NCT >  ) const &
inline

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

Definition at line 365 of file ToolHandle.h.

367  : ToolHandle<T>( static_cast<const ToolHandle<NCT>&>( other ) ) {}

The documentation for this class was generated from the following file:
PublicToolHandle::PublicToolHandle
PublicToolHandle(bool createIf=true)
Definition: ToolHandle.h:357
ToolHandle
Definition: ToolHandle.h:130
PublicToolHandle
Helper class to construct ToolHandle instances for public tools via the auto registering constructor.
Definition: ToolHandle.h:355
ToolHandleInfo::createIf
bool createIf() const noexcept
Definition: ToolHandle.h:51