The Gaudi Framework  v37r0 (b608885e)
ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > > Class Template Reference

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/ToolHandle.h>

Inheritance diagram for ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >:
Collaboration diagram for ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >:

Public Member Functions

StatusCode retrieve () const override
 
auto bind (const EventContext &ctx) const
 
- Public Member Functions inherited from ToolHandle< IAlgTool >
 ToolHandle (const IInterface *parent=nullptr, bool createIf=true)
 Constructor for a tool with default tool type and name. More...
 
 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...
 
 ToolHandle (OWNER *owner, std::string propName, std::string toolType, std::string doc="")
 Autodeclaring constructor with property propName, tool type/name and documentation. More...
 
 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 retrieve (IAlgTool *&algTool) const override
 Do the real retrieval of the AlgTool. More...
 
StatusCode release () const
 Release the AlgTool. More...
 
StatusCode release (IAlgTool *algTool) const override
 Do the real release of the AlgTool. More...
 
std::string typeAndName () const override
 
std::add_const_t< IAlgTool > * get () const
 
IAlgToolget ()
 
- Public Member Functions inherited from BaseToolHandle
StatusCode retrieve (IAlgTool *&tool) const
 
const IAlgToolget () const
 
IAlgToolget ()
 
virtual std::string typeAndName () const =0
 
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< IAlgTool >
 GaudiHandle (const GaudiHandle< NCT > &other, std::enable_if_t< std::is_const_v< CT > &&!std::is_same_v< CT, NCT >> *=nullptr)
 Copy constructor needed for correct ref-counting. More...
 
 GaudiHandle (const GaudiHandle &other)
 Copy constructor needed for correct ref-counting. More...
 
std::enable_if_t< std::is_const_v< CT > &&!std::is_same_v< CT, NCT >, GaudiHandle & > 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...
 
IAlgToolget ()
 Return the wrapped pointer, not calling retrieve() if null. More...
 
std::add_const_t< IAlgTool > * get () const
 Return the wrapped pointer, not calling retrieve() if null. More...
 
bool isSet () const
 True if the wrapped pointer is not null. More...
 
IAlgTooloperator* ()
 
std::add_const_t< IAlgTool > & operator* () const
 
IAlgTooloperator-> ()
 
std::add_const_t< IAlgTool > * 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 (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 ()=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...
 

Private Attributes

void * m_ptr = nullptr
 
Gaudi::Interface::Bind::Box< IFace >(* m_bind )(void const *, const EventContext &) = nullptr
 

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< IAlgTool >
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)
 
virtual const IAlgToolgetAsIAlgTool () const =0
 
- Protected Member Functions inherited from ToolHandleInfo
 ToolHandleInfo (const IInterface *parent=nullptr, bool createIf=true)
 
- Protected Member Functions inherited from GaudiHandle< IAlgTool >
 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<typename IFace>
class ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >

Definition at line 308 of file ToolHandle.h.

Member Function Documentation

◆ bind()

template<typename IFace >
auto ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::bind ( const EventContext ctx) const
inline

Definition at line 344 of file ToolHandle.h.

344  {
345  if ( !m_bind || !m_ptr ) {
346  throw GaudiException{ "request bind on toolhandle which was not (successfully) 'retrieved'", __PRETTY_FUNCTION__,
348  }
349  return ( *m_bind )( m_ptr, ctx );
350  }

◆ retrieve()

template<typename IFace >
StatusCode ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::retrieve ( ) const
inlineoverridevirtual

Implements BaseToolHandle.

Definition at line 316 of file ToolHandle.h.

316  {
317  // FIXME: why is `retrieve` const????
318  auto self = const_cast<ToolHandle<Gaudi::Interface::Bind::IBinder<IFace>>*>( this );
319 
321  const IAlgTool* tool = get();
322  assert( tool != nullptr ); // retrieve was succesfull, so get() better return something valid!
323  return const_cast<IAlgTool*>( tool )
324  ->queryInterface( IFace::interfaceID(), &( self->m_ptr ) )
325  .andThen( [&] {
326  // TODO: what happens to the refCount?
327  self->m_bind = []( const void* ptr, const EventContext& ) {
328  return Gaudi::Interface::Bind::Box<IFace>( static_cast<IFace const*>( ptr ) );
329  };
330  } )
331  .orElse( [&]() {
332  return const_cast<IAlgTool*>( tool )
333  ->queryInterface( Gaudi::Interface::Bind::IBinder<IFace>::interfaceID(), &( self->m_ptr ) )
334  .andThen( [&] {
335  // TODO: what happens to the refCount?
336  self->m_bind = []( const void* ptr, const EventContext& ctx ) {
337  return static_cast<Gaudi::Interface::Bind::IBinder<IFace> const*>( ptr )->bind( ctx );
338  };
339  } );
340  } );
341  } );
342  }

Member Data Documentation

◆ m_bind

template<typename IFace >
Gaudi::Interface::Bind::Box<IFace>( * ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::m_bind) (void const *, const EventContext &) = nullptr
private

Definition at line 310 of file ToolHandle.h.

◆ m_ptr

template<typename IFace >
void* ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::m_ptr = nullptr
private

Definition at line 310 of file ToolHandle.h.


The documentation for this class was generated from the following file:
ToolHandle::retrieve
StatusCode retrieve() const override
Retrieve the AlgTool.
Definition: ToolHandle.h:228
IAlgTool
Definition: IAlgTool.h:33
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:163
GaudiException
Definition: GaudiException.h:31
Gaudi::Interface::Bind::Box
Definition: IBinder.h:23
ToolHandle
Definition: ToolHandle.h:132
bug_34121.tool
tool
Definition: bug_34121.py:17
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:588
ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::m_bind
Gaudi::Interface::Bind::Box< IFace >(* m_bind)(void const *, const EventContext &)
Definition: ToolHandle.h:311
EventContext
Definition: EventContext.h:34
ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::bind
auto bind(const EventContext &ctx) const
Definition: ToolHandle.h:344
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::m_ptr
void * m_ptr
Definition: ToolHandle.h:310
Gaudi::Interface::Bind::IBinder
Definition: IBinder.h:56
ToolHandle< IAlgTool >::get
std::add_const_t< IAlgTool > * get() const
Definition: ToolHandle.h:275