The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
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
GaudiHandleBase & operator= (const std::string &typeAndName)
 assignment operator from base class
GaudiHandleBase & operator= (std::string &&typeAndName)
 assignment operator from base class
StatusCode initialize (const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
StatusCode release () const override
 Release the AlgTool.
std::string typeAndName () const override
std::add_const_t< Gaudi::Interface::Bind::IBinder< IFace > > * get () const
Public Member Functions inherited from BaseToolHandle
StatusCode retrieve (IAlgTool *&tool) const
virtual StatusCode retrieve (DisableTool sd)=0
virtual StatusCode retrieve (EnableTool sd)=0
const IAlgTool * get () const
IAlgTool * get ()
bool isEnabled () const
 Helper to check if the ToolHandle should be retrieved.
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 IInterface * parent () const noexcept
Public Member Functions inherited from GaudiHandle< T >
template<typename CT = T, typename NCT = std::remove_const_t<T>>
requires ( std::is_const_v<CT> && !std::is_same_v<CT, NCT> )
 GaudiHandle (const GaudiHandle< NCT > &other)
 Copy constructor needed for correct ref-counting.
 GaudiHandle (const GaudiHandle &other)
 Copy constructor needed for correct ref-counting.
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= (const GaudiHandle< NCT > &other)
 Assignment operator for correct ref-counting.
GaudiHandle & operator= (const GaudiHandle &other)
 Assignment operator for correct ref-counting.
StatusCode retrieve () const
 Retrieve the component.
StatusCode release () const
 Release the component.
bool isValid () const
 Check if the handle is valid (try to retrive the object is not done yet).
 operator bool () const
 For testing if handle has component.
T * get ()
 Return the wrapped pointer, not calling retrieve() if null.
std::add_const_t< T > * get () const
 Return the wrapped pointer, not calling retrieve() if null.
bool isSet () const
 True if the wrapped pointer is not null.
T & operator* ()
T * operator-> ()
std::add_const_t< T > & operator* () const
std::add_const_t< T > * operator-> () const
std::string getDefaultType ()
 Helper function to get default type string from the class type.
std::string getDefaultName ()
Public Member Functions inherited from GaudiHandleBase
const 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 (std::string myTypeAndName)
 The component "type/name" string.
void setName (std::string_view myName)
 Set the instance name (part after the '/') without changing the class type.
std::string pythonPropertyClassName () const override
 Name of the componentType with "Handle" appended.
std::string messageName () const
 name used for printing messages
std::string pythonRepr () const override
 Python representation of handle, i.e.
GaudiHandleBase & operator= (const std::string &typeAndName)
 Set "type/name" from string.
GaudiHandleBase & operator= (std::string &&typeAndName)
 Set "type/name" from string.
Public Member Functions inherited from GaudiHandleInfo
virtual ~GaudiHandleInfo ()
 virtual destructor so that derived class destructor is called.
const std::string & componentType () const
const std::string & propertyName () const
 name as used in declareProperty(name,gaudiHandle)
void setPropertyName (std::string propName)
 set name as used in declareProperty(name,gaudiHandle).
const std::string & parentName () const
 The name of the parent.
Public Member Functions inherited from ToolHandle< IAlgTool >
GaudiHandleBase & operator= (const std::string &typeAndName)
 assignment operator from base class
GaudiHandleBase & operator= (std::string &&typeAndName)
 assignment operator from base class
StatusCode initialize (const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
StatusCode retrieve () const override
 Retrieve the AlgTool.
StatusCode release () const override
 Release the AlgTool.
std::string typeAndName () const override
std::add_const_t< IAlgTool > * get () const
Public Member Functions inherited from GaudiHandle< IAlgTool >
GaudiHandle & operator= (const GaudiHandle< NCT > &other)
 Assignment operator for correct ref-counting.
StatusCode retrieve () const
 Retrieve the component.
StatusCode release () const
 Release the component.
bool isValid () const
 Check if the handle is valid (try to retrive the object is not done yet).
 operator bool () const
 For testing if handle has component.
IAlgTool * get ()
 Return the wrapped pointer, not calling retrieve() if null.
bool isSet () const
 True if the wrapped pointer is not null.
IAlgTool & operator* ()
IAlgTool * operator-> ()
std::string getDefaultType ()
 Helper function to get default type string from the class type.
std::string getDefaultName ()

Protected Member Functions

const IAlgTool * getAsIAlgTool () const override
StatusCode i_retrieve (IAlgTool *&algTool) const override
Protected Member Functions inherited from BaseToolHandle
 BaseToolHandle (const IInterface *parent=nullptr, bool createIf=true)
virtual IAlgTool * getAsIAlgTool ()=0
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)
virtual StatusCode retrieve (T *&) const =0
 Retrieve the component.
virtual StatusCode release (T *comp) const
 Release the component.
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.
Protected Member Functions inherited from GaudiHandleInfo
 GaudiHandleInfo (std::string myComponentType, std::string myParentName)
 Some basic information and helper functions shared between various handles/arrays.
void setComponentType (std::string componentType)
 The component type.
void setParentName (std::string parent)
 The name of the parent.
Protected Member Functions inherited from ToolHandle< IAlgTool >
const IAlgTool * getAsIAlgTool () const override
StatusCode i_retrieve (IAlgTool *&algTool) const override
Protected Member Functions inherited from GaudiHandle< IAlgTool >
 GaudiHandle (std::string myTypeAndName, std::string myComponentType, std::string myParentName)

Private Member Functions

 ToolHandle (std::tuple< Args... > &&args, std::index_sequence< Is... >)

Private Attributes

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

Friends

class Gaudi::Algorithm
class AlgTool
class Service
std::ostream & operator<< (std::ostream &os, const ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > > &handle)

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 Attributes inherited from BaseToolHandle
bool m_enabled = true
Protected Attributes inherited from ToolHandleInfo
const IInterface * m_parent = nullptr
bool m_createIf { true }

Detailed Description

template<typename IFace>
class ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >

Definition at line 311 of file ToolHandle.h.

Constructor & Destructor Documentation

◆ ToolHandle()

ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::ToolHandle ( std::tuple< Args... > && args,
std::index_sequence< Is... >  )
inlineprivate

Definition at line 139 of file ToolHandle.h.

140 : ToolHandle( std::get<Is>( std::move( args ) )... ) {}
Handle to be used in lieu of naked pointers to tools.
Definition ToolHandle.h:132
ToolHandle(std::tuple< Args... > &&args, std::index_sequence< Is... >)
Definition ToolHandle.h:139

Member Function Documentation

◆ bind()

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

Definition at line 341 of file ToolHandle.h.

341 {
342 if ( !m_bind || !m_ptr ) {
343 throw GaudiException{ "request bind on toolhandle which was not (successfully) 'retrieved'", __PRETTY_FUNCTION__,
345 }
346 return ( *m_bind )( m_ptr, ctx );
347 }
Gaudi::Interface::Bind::Box< IFace >(* m_bind)(void const *, const EventContext &)
Definition ToolHandle.h:314

◆ get()

std::add_const_t< Gaudi::Interface::Bind::IBinder< IFace > > * ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::get ( ) const
inline

Definition at line 278 of file ToolHandle.h.

278{ return GaudiHandle<T>::get(); }
T * get()
Return the wrapped pointer, not calling retrieve() if null.

◆ getAsIAlgTool()

const IAlgTool * ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::getAsIAlgTool ( ) const
inlineoverrideprotectedvirtual

Implements BaseToolHandle.

Definition at line 287 of file ToolHandle.h.

287 {
288 // const cast to support T being const
289 return GaudiHandle<T>::get();
290 }

◆ i_retrieve()

StatusCode ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::i_retrieve ( IAlgTool *& algTool) const
inlineoverrideprotectedvirtual

Implements BaseToolHandle.

Definition at line 297 of file ToolHandle.h.

◆ initialize()

StatusCode ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::initialize ( const std::string & toolTypeAndName,
const IInterface * parent = nullptr,
bool createIf = true )
inline

Definition at line 216 of file ToolHandle.h.

217 {
218
222
225
226 return m_pToolSvc.initialize( "ToolSvc", GaudiHandleBase::parentName() );
227 }
void setTypeAndName(std::string myTypeAndName)
The component "type/name" string.
void setParentName(std::string parent)
The name of the parent.
Definition GaudiHandle.h:84
void setComponentType(std::string componentType)
The component type.
Definition GaudiHandle.h:81
bool createIf() const noexcept
Definition ToolHandle.h:51
const IInterface * parent() const noexcept
Definition ToolHandle.h:53
const IInterface * m_parent
Definition ToolHandle.h:67
static std::string toolParentName(const IInterface *parent)
Definition ToolHandle.h:61
static std::string toolComponentType(const IInterface *parent)
Definition ToolHandle.h:59

◆ operator=() [1/2]

( const std::string & typeAndName)

assignment operator from base class

◆ operator=() [2/2]

( std::string && typeAndName)

assignment operator from base class

◆ release()

StatusCode ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::release ( ) const
inlineoverridevirtual

Release the AlgTool.

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

Implements BaseToolHandle.

Definition at line 255 of file ToolHandle.h.

255 { // not really const, because it updates m_pObject
257 }
StatusCode release() const
Release the component.

◆ retrieve()

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

Implements BaseToolHandle.

Definition at line 319 of file ToolHandle.h.

319 {
320 // FIXME: why is `retrieve` const????
322
324 IAlgTool* tool = self->get();
325 assert( tool != nullptr ); // retrieve was succesfull, so get() better return something valid!
326 if ( ( self->m_ptr = tool->template cast<IFace>() ) ) {
327 self->m_bind = []( const void* ptr, const EventContext& ) {
328 return Gaudi::Interface::Bind::Box<IFace>( static_cast<IFace const*>( ptr ) );
329 };
330 } else if ( ( self->m_ptr = tool->template cast<Gaudi::Interface::Bind::IBinder<IFace>>() ) ) {
331 self->m_bind = []( const void* ptr, const EventContext& ctx ) {
332 return static_cast<Gaudi::Interface::Bind::IBinder<IFace> const*>( ptr )->bind( ctx );
333 };
334 } else {
335 return StatusCode::FAILURE;
336 }
337 return StatusCode::SUCCESS;
338 } );
339 }
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition StatusCode.h:151
auto bind(const EventContext &ctx) const
Definition ToolHandle.h:341
std::add_const_t< T > * get() const
Definition ToolHandle.h:278
StatusCode retrieve() const override
Retrieve the AlgTool.
Definition ToolHandle.h:231

◆ typeAndName()

std::string ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::typeAndName ( ) const
inlineoverridevirtual

Implements BaseToolHandle.

Definition at line 276 of file ToolHandle.h.

const std::string & typeAndName() const
The full type and name: "type/name".

◆ AlgTool

friend class AlgTool
friend

Definition at line 135 of file ToolHandle.h.

◆ Gaudi::Algorithm

friend class Gaudi::Algorithm
friend

Definition at line 134 of file ToolHandle.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > > & handle )
friend

Definition at line 282 of file ToolHandle.h.

◆ Service

friend class Service
friend

Definition at line 136 of file ToolHandle.h.

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 313 of file ToolHandle.h.

◆ m_pToolSvc

ServiceHandle<IToolSvc> ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::m_pToolSvc
mutableprivate

Definition at line 306 of file ToolHandle.h.

◆ m_ptr

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

Definition at line 313 of file ToolHandle.h.


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