The Gaudi Framework  master (37c0b60a)
ToolHandle.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_TOOLHANDLE_H
12 #define GAUDIKERNEL_TOOLHANDLE_H
13 
14 // Includes
16 #include <GaudiKernel/IAlgTool.h>
17 #include <GaudiKernel/IBinder.h>
19 #include <GaudiKernel/IToolSvc.h>
21 #include <GaudiKernel/TaggedBool.h>
22 
23 #include <stdexcept>
24 #include <string>
25 #include <type_traits>
26 #include <vector>
27 
28 // forward declarations
29 class IInterface;
30 class IToolSvc;
31 
32 namespace Gaudi {
33  class Algorithm;
34 }
35 class AlgTool;
36 class Service;
37 
40 
43 
44 protected:
45  ToolHandleInfo( const IInterface* parent = nullptr, bool createIf = true )
47 
48 public:
49  virtual ~ToolHandleInfo() = default;
50 
51  bool isPublic() const noexcept { return !m_parent; }
52 
53  bool createIf() const noexcept { return m_createIf; }
54 
55  const IInterface* parent() const noexcept { return m_parent; }
56 
57  //
58  // Some helper functions
59  //
60 
61  static std::string toolComponentType( const IInterface* parent ) { return parent ? "PrivateTool" : "PublicTool"; }
62 
64  auto* pNamed = ( parent ? dynamic_cast<const INamedInterface*>( parent ) : nullptr );
65  return ( !parent ? "ToolSvc" : ( pNamed ? pNamed->name() : "" ) );
66  }
67 
68 protected:
69  const IInterface* m_parent = nullptr;
70  bool m_createIf{ true };
71 };
72 
81 
82 protected:
83  BaseToolHandle( const IInterface* parent = nullptr, bool createIf = true ) : ToolHandleInfo( parent, createIf ) {}
84 
85  virtual StatusCode i_retrieve( IAlgTool*& ) const = 0;
86 
87 public:
88  StatusCode retrieve( IAlgTool*& tool ) const { return i_retrieve( tool ); }
89 
90  virtual StatusCode retrieve() const = 0;
91  virtual StatusCode retrieve( DisableTool sd ) = 0;
92  virtual StatusCode retrieve( EnableTool sd ) = 0;
93 
94  const IAlgTool* get() const { return getAsIAlgTool(); }
95 
96  IAlgTool* get() { return getAsIAlgTool(); }
97 
98  virtual std::string typeAndName() const = 0;
99 
101  bool isEnabled() const {
102  // the handle is considered enabled if the type/name is valid and the
103  // enabled flag was set to true, or it was already retrieved
104  return ( m_enabled && !typeAndName().empty() ) || get();
105  }
106 
107  void enable() { m_enabled = true; }
108 
109  void disable() { m_enabled = false; }
110 
111  bool setEnabled( bool flag ) { return std::exchange( m_enabled, flag ); }
112 
113 protected:
114  virtual const IAlgTool* getAsIAlgTool() const = 0;
115 
116  virtual IAlgTool* getAsIAlgTool() = 0;
117 
118  bool m_enabled = true;
119 };
120 
131 template <class T>
132 class ToolHandle : public BaseToolHandle, public GaudiHandle<T> {
133 
134  friend class Gaudi::Algorithm;
135  friend class AlgTool;
136  friend class Service;
137 
138  template <typename... Args, std::size_t... Is>
139  ToolHandle( std::tuple<Args...>&& args, std::index_sequence<Is...> )
140  : ToolHandle( std::get<Is>( std::move( args ) )... ) {}
141 
142 public:
146  ToolHandle( const IInterface* parent = nullptr, bool createIf = true )
149  , m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) {}
150 
152  template <typename CT = T, typename NCT = std::remove_const_t<T>,
153  typename = std::enable_if_t<std::is_const_v<CT> && !std::is_same_v<CT, NCT>>>
154  ToolHandle( const ToolHandle<NCT>& other )
155  : BaseToolHandle( other.parent(), other.createIf() )
156  , GaudiHandle<CT>( other )
157  , m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) {}
158 
159 public:
160  //
161  // Constructors etc.
162  //
163 
183 #if defined( TOOLHANDLE_DEPR_WARN )
184 // warn about using deprecated explicit ToolHandle construction
185 # pragma message( "Untracked ToolHandle: Migrate explicit DataHandle constructor to declareTool Algorithm Property" )
186 
187  __attribute__( ( deprecated ) )
188 
189 #endif
190  ToolHandle( const std::string& toolTypeAndName, const IInterface* parent = nullptr, bool createIf = true )
192  , GaudiHandle<T>( toolTypeAndName, toolComponentType( parent ), toolParentName( parent ) )
193  , m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) {
194  }
195 
198  template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
199  ToolHandle( OWNER* owner, std::string propName, std::string toolType, std::string doc = "" ) : ToolHandle( owner ) {
200  // convert name and type to a valid type/name string
201  // - if type does not contain '/' use type/type
202  // - otherwise type is already a type/name string
203  if ( !toolType.empty() and toolType.find( '/' ) == std::string::npos ) { toolType += '/' + toolType; }
204  owner->declareTool( *this, std::move( toolType ) ).ignore();
205  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( propName ), *this, std::move( doc ) );
206  p->template setOwnerType<OWNER>();
207  }
208 
209  template <typename... Args>
210  ToolHandle( std::tuple<Args...>&& args ) : ToolHandle( std::move( args ), std::index_sequence_for<Args...>{} ) {}
211 
212 public:
213  StatusCode initialize( const std::string& toolTypeAndName, const IInterface* parent = nullptr,
214  bool createIf = true ) {
215 
216  GaudiHandleBase::setTypeAndName( toolTypeAndName );
219 
220  m_parent = parent;
222 
223  return m_pToolSvc.initialize( "ToolSvc", GaudiHandleBase::parentName() );
224  }
225 
228  StatusCode retrieve() const override { // not really const, because it updates m_pObject
229  return GaudiHandle<T>::retrieve();
230  }
231 
232  StatusCode retrieve( DisableTool sd ) override {
233  if ( isEnabled() && sd == DisableTool{ false } ) {
234  return GaudiHandle<T>::retrieve();
235  } else {
236  disable();
237  return StatusCode::SUCCESS;
238  }
239  }
240 
241  StatusCode retrieve( EnableTool sd ) override {
242  if ( isEnabled() && sd == EnableTool{ true } ) {
243  return GaudiHandle<T>::retrieve();
244  } else {
245  disable();
246  return StatusCode::SUCCESS;
247  }
248  }
249 
252  StatusCode release() const { // not really const, because it updates m_pObject
253  return GaudiHandle<T>::release();
254  }
255 
257  StatusCode retrieve( T*& algTool ) const override {
258  IAlgTool* iface = nullptr;
259  if ( i_retrieve( iface ).isFailure() ) { return StatusCode::FAILURE; }
260 
261  algTool = dynamic_cast<T*>( iface );
262  if ( !algTool ) {
263  throw GaudiException( "unable to dcast AlgTool " + typeAndName() + " to interface " +
264  System::typeinfoName( typeid( T ) ),
265  typeAndName() + " retrieve", StatusCode::FAILURE );
266  }
267  return StatusCode::SUCCESS;
268  }
269 
271  StatusCode release( T* algTool ) const override { return m_pToolSvc->releaseTool( ::details::nonConst( algTool ) ); }
272 
273  std::string typeAndName() const override { return GaudiHandleBase::typeAndName(); }
274 
275  std::add_const_t<T>* get() const { return GaudiHandle<T>::get(); }
276 
277  T* get() { return GaudiHandle<T>::get(); }
278 
279  friend std::ostream& operator<<( std::ostream& os, const ToolHandle<T>& handle ) {
280  return os << static_cast<const GaudiHandleInfo&>( handle );
281  }
282 
283 protected:
284  const IAlgTool* getAsIAlgTool() const override {
285  // const cast to support T being const
286  return GaudiHandle<T>::get();
287  }
288 
289  IAlgTool* getAsIAlgTool() override {
290  // const cast to support T being const
292  }
293 
294  StatusCode i_retrieve( IAlgTool*& algTool ) const override {
297  }
298 
299 private:
300  //
301  // Private data members
302  //
304 };
305 
306 // explicit specialization for IBinder<IFace>
307 template <typename IFace>
308 class ToolHandle<Gaudi::Interface::Bind::IBinder<IFace>> : public ToolHandle<IAlgTool> {
309 
310  void* m_ptr = nullptr;
311  Gaudi::Interface::Bind::Box<IFace> ( *m_bind )( void const*, const EventContext& ) = nullptr;
312 
313 public:
316  StatusCode retrieve() const override {
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  }
343 
344  auto bind( const EventContext& ctx ) const {
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  }
351 };
352 
356 template <class T>
357 class PublicToolHandle : public ToolHandle<T> {
358 public:
360  PublicToolHandle( const char* toolTypeAndName, bool createIf = true )
361  : PublicToolHandle{ std::string{ toolTypeAndName }, createIf } {}
362  PublicToolHandle( const std::string& toolTypeAndName, bool createIf = true )
363  : ToolHandle<T>( toolTypeAndName, nullptr, createIf ) {}
364 
366  template <typename CT = T, typename NCT = std::remove_const_t<T>>
368  std::enable_if_t<std::is_const_v<CT> && !std::is_same_v<CT, NCT>>* = nullptr )
369  : ToolHandle<T>( static_cast<const ToolHandle<NCT>&>( other ) ) {}
370 
373  template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
374  inline PublicToolHandle( OWNER* owner, std::string propName, std::string toolType, std::string doc = "" )
375  : PublicToolHandle() {
376  // convert name and type to a valid type/name string
377  // - if type does not contain '/' use type/type
378  // - otherwise type is already a type/name string
379  if ( !toolType.empty() and toolType.find( '/' ) == std::string::npos ) { toolType += '/' + toolType; }
380  owner->declareTool( *this, std::move( toolType ) ).ignore();
381  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( propName ), *this, std::move( doc ) );
382  p->template setOwnerType<OWNER>();
383  }
384 };
385 
386 //-------------------------------------------------------------------------//
387 
398 template <class T>
399 class ToolHandleArray : public ToolHandleInfo, public GaudiHandleArray<ToolHandle<T>> {
400 public:
401  //
402  // Constructors
403  //
410  ToolHandleArray( const std::vector<std::string>& myTypesAndNames, const IInterface* parent = nullptr,
411  bool createIf = true )
415 
420  ToolHandleArray( const IInterface* parent = nullptr, bool createIf = true )
424 
429  bool push_back( const std::string& toolTypeAndName ) override {
430  ToolHandle<T> handle( toolTypeAndName, ToolHandleInfo::parent(), ToolHandleInfo::createIf() );
432  return true;
433  }
434 
436  bool push_back( const ToolHandle<T>& myHandle ) override { return push_back( myHandle.typeAndName() ); }
437 
440  template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
442  std::string doc = "" )
443  : ToolHandleArray( owner ) {
444  owner->addToolsArray( *this );
446  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( name ), *this, std::move( doc ) );
447  p->template setOwnerType<OWNER>();
448  }
449 
450  friend std::ostream& operator<<( std::ostream& os, const ToolHandleArray<T>& handle ) {
451  return os << static_cast<const GaudiHandleInfo&>( handle );
452  }
453 };
454 
458 template <class T>
460 public:
464 
467  template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
469  std::string doc = "" )
471  owner->addToolsArray( *this );
473  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( name ), *this, std::move( doc ) );
474  p->template setOwnerType<OWNER>();
475  }
476 };
477 
478 #endif // ! GAUDIKERNEL_TOOLHANDLE_H
ToolHandle::retrieve
StatusCode retrieve() const override
Retrieve the AlgTool.
Definition: ToolHandle.h:228
GaudiHandleInfo::parentName
const std::string & parentName() const
The name of the parent.
Definition: GaudiHandle.h:65
PublicToolHandle::PublicToolHandle
PublicToolHandle(const std::string &toolTypeAndName, bool createIf=true)
Definition: ToolHandle.h:362
GaudiHandle.h
std::string
STL class.
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
std::move
T move(T... args)
BaseToolHandle::disable
void disable()
Definition: ToolHandle.h:109
BaseToolHandle::BaseToolHandle
BaseToolHandle(const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:83
GaudiHandleArray< ToolHandle< T > >::push_back
virtual bool push_back(const std::string &myHandleTypeAndName)=0
Add a handle with given type and name.
ServiceHandle< IToolSvc >
PublicToolHandle::PublicToolHandle
PublicToolHandle(OWNER *owner, std::string propName, std::string toolType, std::string doc="")
Autodeclaring constructor with property propName, tool type/name and documentation.
Definition: ToolHandle.h:374
BaseToolHandle::typeAndName
virtual std::string typeAndName() const =0
ToolHandle::ToolHandle
ToolHandle(OWNER *owner, std::string propName, std::string toolType, std::string doc="")
Autodeclaring constructor with property propName, tool type/name and documentation.
Definition: ToolHandle.h:199
std::vector< std::string >
std::string::find
T find(T... args)
GaudiException
Definition: GaudiException.h:31
Algorithm
Alias for backward compatibility.
Definition: Algorithm.h:58
ServiceHandle::initialize
StatusCode initialize(const std::string &serviceName, const std::string &theParentName)
Definition: ServiceHandle.h:70
Gaudi::Interface::Bind::Box
Definition: IBinder.h:23
ToolHandleArray::push_back
bool push_back(const ToolHandle< T > &myHandle) override
Ensure that for added handles the parent and creatIf are taken from this array.
Definition: ToolHandle.h:436
std::tuple
ToolHandleInfo::toolComponentType
static std::string toolComponentType(const IInterface *parent)
Definition: ToolHandle.h:61
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:315
ServiceHandle.h
BaseToolHandle::i_retrieve
virtual StatusCode i_retrieve(IAlgTool *&) const =0
ToolHandle::ToolHandle
ToolHandle(const ToolHandle< NCT > &other)
Copy constructor from a non const T to const T tool handle.
Definition: ToolHandle.h:154
BaseToolHandle::isEnabled
bool isEnabled() const
Helper to check if the ToolHandle should be retrieved.
Definition: ToolHandle.h:101
GaudiHandleInfo::setParentName
void setParentName(std::string parent)
The name of the parent.
Definition: GaudiHandle.h:87
ToolHandle::ToolHandle
ToolHandle(std::tuple< Args... > &&args)
Definition: ToolHandle.h:210
Service
Definition: Service.h:46
GaudiHandleBase
Definition: GaudiHandle.h:105
PublicToolHandle::PublicToolHandle
PublicToolHandle(bool createIf=true)
Definition: ToolHandle.h:359
GaudiHandle
Definition: GaudiHandle.h:179
ToolHandleInfo::toolParentName
static std::string toolParentName(const IInterface *parent)
Definition: ToolHandle.h:63
ToolHandleArray::ToolHandleArray
ToolHandleArray(const IInterface *parent=nullptr, bool createIf=true)
Constructor which creates and empty list.
Definition: ToolHandle.h:420
PublicToolHandleArray::PublicToolHandleArray
PublicToolHandleArray(const std::vector< std::string > &typesAndNames, bool createIf=true)
Definition: ToolHandle.h:462
ToolHandle::retrieve
StatusCode retrieve(T *&algTool) const override
Do the real retrieval of the AlgTool.
Definition: ToolHandle.h:257
IToolSvc.h
ToolHandle
Definition: ToolHandle.h:132
INamedInterface.h
ToolHandleArray::ToolHandleArray
ToolHandleArray(OWNER *owner, std::string name, const std::vector< std::string > &typesAndNames={}, std::string doc="")
Autodeclaring constructor with property name, tool type/name and documentation.
Definition: ToolHandle.h:441
GaudiHandle::get
T * get()
Return the wrapped pointer, not calling retrieve() if null.
Definition: GaudiHandle.h:266
bug_34121.tool
tool
Definition: bug_34121.py:18
BaseToolHandle::retrieve
virtual StatusCode retrieve(DisableTool sd)=0
details::nonConst
std::remove_const_t< T > * nonConst(T *p)
Cast a pointer to a non const type.
Definition: GaudiHandle.h:29
PublicToolHandleArray::PublicToolHandleArray
PublicToolHandleArray(OWNER *owner, std::string name, const std::vector< std::string > &typesAndNames={}, std::string doc="")
Autodeclaring constructor with property name, tool type/name and documentation.
Definition: ToolHandle.h:468
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:578
StatusCode
Definition: StatusCode.h:65
Gaudi::tagged_bool_ns::tagged_bool
Definition: TaggedBool.h:16
ToolHandle::ToolHandle
ToolHandle(const IInterface *parent=nullptr, bool createIf=true)
Constructor for a tool with default tool type and name.
Definition: ToolHandle.h:146
TaggedBool.h
IInterface::interfaceID
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition: IInterface.h:248
PublicToolHandle::PublicToolHandle
PublicToolHandle(const char *toolTypeAndName, bool createIf=true)
Definition: ToolHandle.h:360
std::ostream
STL class.
ToolHandleInfo
General info and helper functions for toolhandles and arrays.
Definition: ToolHandle.h:42
ToolHandle::get
T * get()
Definition: ToolHandle.h:277
IAlgTool.h
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
ToolHandle::ToolHandle
ToolHandle(std::tuple< Args... > &&args, std::index_sequence< Is... >)
Definition: ToolHandle.h:139
ToolHandleArray
Definition: ToolHandle.h:399
ToolHandle::ToolHandle
ToolHandle(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Create a handle ('smart pointer') to a tool.
Definition: ToolHandle.h:190
PublicToolHandleArray
Helper class to construct ToolHandle instances for public tools via the auto registering constructor.
Definition: ToolHandle.h:459
BaseToolHandle::retrieve
StatusCode retrieve(IAlgTool *&tool) const
Definition: ToolHandle.h:88
ToolHandle::i_retrieve
StatusCode i_retrieve(IAlgTool *&algTool) const override
Definition: ToolHandle.h:294
PublicToolHandle
Helper class to construct ToolHandle instances for public tools via the auto registering constructor.
Definition: ToolHandle.h:357
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:87
IToolSvc::retrieve
virtual StatusCode retrieve(std::string_view type, const InterfaceID &iid, IAlgTool *&tool, const IInterface *parent=0, bool createIf=true)=0
Retrieve tool with tool dependent part of the name automatically assigned.
ToolHandle::release
StatusCode release() const
Release the AlgTool.
Definition: ToolHandle.h:252
BaseToolHandle::retrieve
virtual StatusCode retrieve(EnableTool sd)=0
ToolHandle::operator<<
friend std::ostream & operator<<(std::ostream &os, const ToolHandle< T > &handle)
Definition: ToolHandle.h:279
ToolHandle::getAsIAlgTool
const IAlgTool * getAsIAlgTool() const override
Definition: ToolHandle.h:284
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
ToolHandle::m_pToolSvc
ServiceHandle< IToolSvc > m_pToolSvc
Definition: ToolHandle.h:303
IBinder.h
ToolHandleArray::ToolHandleArray
ToolHandleArray(const std::vector< std::string > &myTypesAndNames, const IInterface *parent=nullptr, bool createIf=true)
Generic constructor.
Definition: ToolHandle.h:410
BaseToolHandle::enable
void enable()
Definition: ToolHandle.h:107
ToolHandleInfo::isPublic
bool isPublic() const noexcept
Definition: ToolHandle.h:51
GaudiHandleArrayBase::setTypesAndNames
bool setTypesAndNames(const std::vector< std::string > &myTypesAndNamesList)
Set the array of handles from list of "type/name" strings in <myTypesAndNamesList>.
Definition: GaudiHandle.cpp:63
BaseToolHandle::get
IAlgTool * get()
Definition: ToolHandle.h:96
INamedInterface
Definition: INamedInterface.h:25
BaseToolHandle::retrieve
virtual StatusCode retrieve() const =0
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ToolHandle::retrieve
StatusCode retrieve(DisableTool sd) override
Definition: ToolHandle.h:232
AlgTool
Definition: AlgTool.h:62
BaseToolHandle
Definition: ToolHandle.h:80
gaudirun.args
args
Definition: gaudirun.py:336
ToolHandleInfo::m_parent
const IInterface * m_parent
Definition: ToolHandle.h:69
std
STL namespace.
ToolHandleInfo::~ToolHandleInfo
virtual ~ToolHandleInfo()=default
IInterface
Definition: IInterface.h:239
BaseToolHandle::get
const IAlgTool * get() const
Definition: ToolHandle.h:94
EventContext
Definition: EventContext.h:34
IToolSvc::releaseTool
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
ToolHandleInfo::m_createIf
bool m_createIf
Definition: ToolHandle.h:70
ToolHandle::retrieve
StatusCode retrieve(EnableTool sd) override
Definition: ToolHandle.h:241
GaudiHandleInfo::setComponentType
void setComponentType(std::string componentType)
The component type.
Definition: GaudiHandle.h:84
ToolHandle::getAsIAlgTool
IAlgTool * getAsIAlgTool() override
Definition: ToolHandle.h:289
std::string::empty
T empty(T... args)
PublicToolHandleArray::PublicToolHandleArray
PublicToolHandleArray(bool createIf=true)
Definition: ToolHandle.h:461
GaudiHandleBase::typeAndName
const std::string & typeAndName() const
The full type and name: "type/name".
Definition: GaudiHandle.h:131
ToolHandle::initialize
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:213
std::size_t
PublicToolHandle::PublicToolHandle
PublicToolHandle(const PublicToolHandle< NCT > &other, std::enable_if_t< std::is_const_v< CT > &&!std::is_same_v< CT, NCT >> *=nullptr)
Copy constructor from a non const T to const T tool handle.
Definition: ToolHandle.h:367
ToolHandleInfo::ToolHandleInfo
ToolHandleInfo(const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:45
GaudiHandleArrayBase::typesAndNames
const std::vector< std::string > typesAndNames() const
Return a vector with "type/name" strings of all handles in the array.
Definition: GaudiHandle.cpp:77
ToolHandle::typeAndName
std::string typeAndName() const override
Definition: ToolHandle.h:273
ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::bind
auto bind(const EventContext &ctx) const
Definition: ToolHandle.h:344
BaseToolHandle::setEnabled
bool setEnabled(bool flag)
Definition: ToolHandle.h:111
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::retrieve
StatusCode retrieve() const override
Definition: ToolHandle.h:316
BaseToolHandle::m_enabled
bool m_enabled
Definition: ToolHandle.h:118
IToolSvc
Definition: IToolSvc.h:29
ToolHandleArray::operator<<
friend std::ostream & operator<<(std::ostream &os, const ToolHandleArray< T > &handle)
Definition: ToolHandle.h:450
GaudiHandleArray
T is the concrete handle type, e.g.
Definition: GaudiHandle.h:411
Gaudi::Interface::Bind::IBinder
Definition: IBinder.h:56
BaseToolHandle::getAsIAlgTool
virtual IAlgTool * getAsIAlgTool()=0
BaseToolHandle::getAsIAlgTool
virtual const IAlgTool * getAsIAlgTool() const =0
ToolHandleInfo::parent
const IInterface * parent() const noexcept
Definition: ToolHandle.h:55
GaudiHandle::retrieve
StatusCode retrieve() const
Retrieve the component.
Definition: GaudiHandle.h:228
ToolHandleInfo::createIf
bool createIf() const noexcept
Definition: ToolHandle.h:53
ToolHandleArray::push_back
bool push_back(const std::string &toolTypeAndName) override
Add a handle to the array with given tool type and name.
Definition: ToolHandle.h:429
GaudiHandle::release
StatusCode release() const
Release the component.
Definition: GaudiHandle.h:242
ToolHandle::release
StatusCode release(T *algTool) const override
Do the real release of the AlgTool.
Definition: ToolHandle.h:271
ToolHandle::get
std::add_const_t< T > * get() const
Definition: ToolHandle.h:275
GaudiHandleBase::setTypeAndName
void setTypeAndName(std::string myTypeAndName)
The component "type/name" string.
Definition: GaudiHandle.cpp:19