Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (f31105fd)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ToolHandle.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 <cassert>
24 #include <concepts>
25 #include <ostream>
26 #include <string>
27 #include <tuple>
28 #include <type_traits>
29 #include <utility>
30 #include <vector>
31 
32 // forward declarations
33 class IInterface;
34 class IToolSvc;
35 
36 namespace Gaudi {
37  class Algorithm;
38 }
39 class AlgTool;
40 class Service;
41 
44 
47 
48 protected:
49  ToolHandleInfo( const IInterface* parent = nullptr, bool createIf = true )
51 
52 public:
53  virtual ~ToolHandleInfo() = default;
54 
55  bool isPublic() const noexcept { return !m_parent; }
56 
57  bool createIf() const noexcept { return m_createIf; }
58 
59  const IInterface* parent() const noexcept { return m_parent; }
60 
61  //
62  // Some helper functions
63  //
64 
65  static std::string toolComponentType( const IInterface* parent ) { return parent ? "PrivateTool" : "PublicTool"; }
66 
68  auto* pNamed = ( parent ? dynamic_cast<const INamedInterface*>( parent ) : nullptr );
69  return ( !parent ? "ToolSvc" : ( pNamed ? pNamed->name() : "" ) );
70  }
71 
72 protected:
73  const IInterface* m_parent = nullptr;
74  bool m_createIf{ true };
75 };
76 
85 
86 protected:
87  BaseToolHandle( const IInterface* parent = nullptr, bool createIf = true ) : ToolHandleInfo( parent, createIf ) {}
88 
89  virtual StatusCode i_retrieve( IAlgTool*& ) const = 0;
90 
91 public:
92  StatusCode retrieve( IAlgTool*& tool ) const { return i_retrieve( tool ); }
93 
94  virtual StatusCode retrieve() const = 0;
95  virtual StatusCode retrieve( DisableTool sd ) = 0;
96  virtual StatusCode retrieve( EnableTool sd ) = 0;
97 
98  const IAlgTool* get() const { return getAsIAlgTool(); }
99 
100  IAlgTool* get() { return getAsIAlgTool(); }
101 
102  virtual std::string typeAndName() const = 0;
103 
105  bool isEnabled() const {
106  // the handle is considered enabled if the type/name is valid and the
107  // enabled flag was set to true, or it was already retrieved
108  return ( m_enabled && !typeAndName().empty() ) || get();
109  }
110 
111  void enable() { m_enabled = true; }
112 
113  void disable() { m_enabled = false; }
114 
115  bool setEnabled( bool flag ) { return std::exchange( m_enabled, flag ); }
116 
117 protected:
118  virtual const IAlgTool* getAsIAlgTool() const = 0;
119 
120  virtual IAlgTool* getAsIAlgTool() = 0;
121 
122  bool m_enabled = true;
123 };
124 
135 template <class T>
136 class ToolHandle : public BaseToolHandle, public GaudiHandle<T> {
137 
138  friend class Gaudi::Algorithm;
139  friend class AlgTool;
140  friend class Service;
141 
142  template <typename... Args, std::size_t... Is>
143  ToolHandle( std::tuple<Args...>&& args, std::index_sequence<Is...> )
144  : ToolHandle( std::get<Is>( std::move( args ) )... ) {}
145 
146 public:
150  ToolHandle( const IInterface* parent = nullptr, bool createIf = true )
153  , m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) {}
154 
156  template <typename CT = T, typename NCT = std::remove_const_t<T>>
157  requires( std::is_const_v<CT> && !std::is_same_v<CT, NCT> )
158  ToolHandle( const ToolHandle<NCT>& other )
159  : BaseToolHandle( other.parent(), other.createIf() )
160  , GaudiHandle<CT>( other )
161  , m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) {}
162 
163 public:
164  //
165  // Constructors etc.
166  //
167 
187 #if defined( TOOLHANDLE_DEPR_WARN )
188 // warn about using deprecated explicit ToolHandle construction
189 # pragma message( "Untracked ToolHandle: Migrate explicit DataHandle constructor to declareTool Algorithm Property" )
190 
191  __attribute__( ( deprecated ) )
192 
193 #endif
194  ToolHandle( const std::string& toolTypeAndName, const IInterface* parent = nullptr, bool createIf = true )
196  , GaudiHandle<T>( toolTypeAndName, toolComponentType( parent ), toolParentName( parent ) )
197  , m_pToolSvc( "ToolSvc", GaudiHandleBase::parentName() ) {
198  }
199 
202  template <std::derived_from<IProperty> OWNER>
203  ToolHandle( OWNER* owner, std::string propName, std::string toolType, std::string doc = "" ) : ToolHandle( owner ) {
204  // convert name and type to a valid type/name string
205  // - if type does not contain '/' use type/type
206  // - otherwise type is already a type/name string
207  if ( !toolType.empty() and toolType.find( '/' ) == std::string::npos ) { toolType += '/' + toolType; }
208  owner->declareTool( *this, std::move( toolType ) ).ignore();
209  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( propName ), *this, std::move( doc ) );
210  p->template setOwnerType<OWNER>();
211  }
212 
213  template <typename... Args>
214  ToolHandle( std::tuple<Args...>&& args ) : ToolHandle( std::move( args ), std::index_sequence_for<Args...>{} ) {}
215 
216 public:
217  StatusCode initialize( const std::string& toolTypeAndName, const IInterface* parent = nullptr,
218  bool createIf = true ) {
219 
220  GaudiHandleBase::setTypeAndName( toolTypeAndName );
223 
224  m_parent = parent;
226 
227  return m_pToolSvc.initialize( "ToolSvc", GaudiHandleBase::parentName() );
228  }
229 
232  StatusCode retrieve() const override { // not really const, because it updates m_pObject
233  return GaudiHandle<T>::retrieve();
234  }
235 
236  StatusCode retrieve( DisableTool sd ) override {
237  if ( isEnabled() && sd == DisableTool{ false } ) {
238  return GaudiHandle<T>::retrieve();
239  } else {
240  disable();
241  return StatusCode::SUCCESS;
242  }
243  }
244 
245  StatusCode retrieve( EnableTool sd ) override {
246  if ( isEnabled() && sd == EnableTool{ true } ) {
247  return GaudiHandle<T>::retrieve();
248  } else {
249  disable();
250  return StatusCode::SUCCESS;
251  }
252  }
253 
256  StatusCode release() const { // not really const, because it updates m_pObject
257  return GaudiHandle<T>::release();
258  }
259 
261  StatusCode retrieve( T*& algTool ) const override {
262  IAlgTool* iface = nullptr;
263  if ( i_retrieve( iface ).isFailure() ) { return StatusCode::FAILURE; }
264 
265  algTool = dynamic_cast<T*>( iface );
266  if ( !algTool ) {
267  throw GaudiException( "unable to dcast AlgTool " + typeAndName() + " to interface " +
268  System::typeinfoName( typeid( T ) ),
269  typeAndName() + " retrieve", StatusCode::FAILURE );
270  }
271  return StatusCode::SUCCESS;
272  }
273 
275  StatusCode release( T* algTool ) const override { return m_pToolSvc->releaseTool( ::details::nonConst( algTool ) ); }
276 
277  std::string typeAndName() const override { return GaudiHandleBase::typeAndName(); }
278 
279  std::add_const_t<T>* get() const { return GaudiHandle<T>::get(); }
280 
281  T* get() { return GaudiHandle<T>::get(); }
282 
283  friend std::ostream& operator<<( std::ostream& os, const ToolHandle<T>& handle ) {
284  return os << static_cast<const GaudiHandleInfo&>( handle );
285  }
286 
287 protected:
288  const IAlgTool* getAsIAlgTool() const override {
289  // const cast to support T being const
290  return GaudiHandle<T>::get();
291  }
292 
293  IAlgTool* getAsIAlgTool() override {
294  // const cast to support T being const
296  }
297 
298  StatusCode i_retrieve( IAlgTool*& algTool ) const override {
301  }
302 
303 private:
304  //
305  // Private data members
306  //
308 };
309 
310 // explicit specialization for IBinder<IFace>
311 template <typename IFace>
312 class ToolHandle<Gaudi::Interface::Bind::IBinder<IFace>> : public ToolHandle<IAlgTool> {
313 
314  void* m_ptr = nullptr;
315  Gaudi::Interface::Bind::Box<IFace> ( *m_bind )( void const*, const EventContext& ) = nullptr;
316 
317 public:
320  StatusCode retrieve() const override {
321  // FIXME: why is `retrieve` const????
322  auto self = const_cast<ToolHandle<Gaudi::Interface::Bind::IBinder<IFace>>*>( this );
323 
325  const IAlgTool* tool = get();
326  assert( tool != nullptr ); // retrieve was succesfull, so get() better return something valid!
327  return const_cast<IAlgTool*>( tool )
328  ->queryInterface( IFace::interfaceID(), &( self->m_ptr ) )
329  .andThen( [&] {
330  // TODO: what happens to the refCount?
331  self->m_bind = []( const void* ptr, const EventContext& ) {
332  return Gaudi::Interface::Bind::Box<IFace>( static_cast<IFace const*>( ptr ) );
333  };
334  } )
335  .orElse( [&]() {
336  return const_cast<IAlgTool*>( tool )
337  ->queryInterface( Gaudi::Interface::Bind::IBinder<IFace>::interfaceID(), &( self->m_ptr ) )
338  .andThen( [&] {
339  // TODO: what happens to the refCount?
340  self->m_bind = []( const void* ptr, const EventContext& ctx ) {
341  return static_cast<Gaudi::Interface::Bind::IBinder<IFace> const*>( ptr )->bind( ctx );
342  };
343  } );
344  } );
345  } );
346  }
347 
348  auto bind( const EventContext& ctx ) const {
349  if ( !m_bind || !m_ptr ) {
350  throw GaudiException{ "request bind on toolhandle which was not (successfully) 'retrieved'", __PRETTY_FUNCTION__,
352  }
353  return ( *m_bind )( m_ptr, ctx );
354  }
355 };
356 
360 template <class T>
361 class PublicToolHandle : public ToolHandle<T> {
362 public:
364  PublicToolHandle( const char* toolTypeAndName, bool createIf = true )
365  : PublicToolHandle{ std::string{ toolTypeAndName }, createIf } {}
366  PublicToolHandle( const std::string& toolTypeAndName, bool createIf = true )
367  : ToolHandle<T>( toolTypeAndName, nullptr, createIf ) {}
368 
370  template <typename CT = T, typename NCT = std::remove_const_t<T>>
371  requires( std::is_const_v<CT> && !std::is_same_v<CT, NCT> )
373  : ToolHandle<T>( static_cast<const ToolHandle<NCT>&>( other ) ) {}
374 
377  template <std::derived_from<IProperty> OWNER>
378  inline PublicToolHandle( OWNER* owner, std::string propName, std::string toolType, std::string doc = "" )
379  : PublicToolHandle() {
380  // convert name and type to a valid type/name string
381  // - if type does not contain '/' use type/type
382  // - otherwise type is already a type/name string
383  if ( !toolType.empty() and toolType.find( '/' ) == std::string::npos ) { toolType += '/' + toolType; }
384  owner->declareTool( *this, std::move( toolType ) ).ignore();
385  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( propName ), *this, std::move( doc ) );
386  p->template setOwnerType<OWNER>();
387  }
388 };
389 
390 //-------------------------------------------------------------------------//
391 
402 template <class T>
403 class ToolHandleArray : public ToolHandleInfo, public GaudiHandleArray<ToolHandle<T>> {
404 public:
405  //
406  // Constructors
407  //
414  ToolHandleArray( const std::vector<std::string>& myTypesAndNames, const IInterface* parent = nullptr,
415  bool createIf = true )
419 
424  ToolHandleArray( const IInterface* parent = nullptr, bool createIf = true )
428 
433  bool push_back( const std::string& toolTypeAndName ) override {
434  ToolHandle<T> handle( toolTypeAndName, ToolHandleInfo::parent(), ToolHandleInfo::createIf() );
436  return true;
437  }
438 
440  bool push_back( const ToolHandle<T>& myHandle ) override { return push_back( myHandle.typeAndName() ); }
441 
444  template <std::derived_from<IProperty> OWNER>
446  std::string doc = "" )
447  : ToolHandleArray( owner ) {
448  owner->addToolsArray( *this );
450  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( name ), *this, std::move( doc ) );
451  p->template setOwnerType<OWNER>();
452  }
453 
454  friend std::ostream& operator<<( std::ostream& os, const ToolHandleArray<T>& handle ) {
455  return os << static_cast<const GaudiHandleInfo&>( handle );
456  }
457 };
458 
462 template <class T>
464 public:
468 
471  template <std::derived_from<IProperty> OWNER>
473  std::string doc = "" )
475  owner->addToolsArray( *this );
477  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( name ), *this, std::move( doc ) );
478  p->template setOwnerType<OWNER>();
479  }
480 };
481 
482 #endif // ! GAUDIKERNEL_TOOLHANDLE_H
ToolHandle::retrieve
StatusCode retrieve() const override
Retrieve the AlgTool.
Definition: ToolHandle.h:232
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:366
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:164
std::move
T move(T... args)
BaseToolHandle::disable
void disable()
Definition: ToolHandle.h:113
BaseToolHandle::BaseToolHandle
BaseToolHandle(const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:87
GaudiHandleArray< ToolHandle< T > >::push_back
virtual bool push_back(const std::string &myHandleTypeAndName)=0
Add a handle with given type and name.
ServiceHandle< IToolSvc >
BaseToolHandle::typeAndName
virtual std::string typeAndName() const =0
std::vector< std::string >
std::string::find
T find(T... args)
GaudiException
Definition: GaudiException.h:32
Algorithm
Alias for backward compatibility.
Definition: Algorithm.h:58
ServiceHandle::initialize
StatusCode initialize(const std::string &serviceName, const std::string &theParentName)
Definition: ServiceHandle.h:71
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:440
std::tuple
ToolHandleInfo::toolComponentType
static std::string toolComponentType(const IInterface *parent)
Definition: ToolHandle.h:65
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
PublicToolHandle::requires
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.
Definition: ToolHandle.h:371
BaseToolHandle::i_retrieve
virtual StatusCode i_retrieve(IAlgTool *&) const =0
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:472
BaseToolHandle::isEnabled
bool isEnabled() const
Helper to check if the ToolHandle should be retrieved.
Definition: ToolHandle.h:105
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:214
Service
Definition: Service.h:46
GaudiHandleBase
Definition: GaudiHandle.h:105
PublicToolHandle::PublicToolHandle
PublicToolHandle(bool createIf=true)
Definition: ToolHandle.h:363
GaudiHandle
Definition: GaudiHandle.h:179
ToolHandleInfo::toolParentName
static std::string toolParentName(const IInterface *parent)
Definition: ToolHandle.h:67
ToolHandleArray::ToolHandleArray
ToolHandleArray(const IInterface *parent=nullptr, bool createIf=true)
Constructor which creates and empty list.
Definition: ToolHandle.h:424
ToolHandle::requires
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.
Definition: ToolHandle.h:157
PublicToolHandleArray::PublicToolHandleArray
PublicToolHandleArray(const std::vector< std::string > &typesAndNames, bool createIf=true)
Definition: ToolHandle.h:466
ToolHandle::retrieve
StatusCode retrieve(T *&algTool) const override
Do the real retrieval of the AlgTool.
Definition: ToolHandle.h:261
IToolSvc.h
ToolHandle
Definition: ToolHandle.h:136
INamedInterface.h
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
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:150
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:364
std::ostream
STL class.
ToolHandleInfo
General info and helper functions for toolhandles and arrays.
Definition: ToolHandle.h:46
ToolHandle::get
T * get()
Definition: ToolHandle.h:281
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:143
ToolHandleArray
Definition: ToolHandle.h:403
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:194
PublicToolHandleArray
Helper class to construct ToolHandle instances for public tools via the auto registering constructor.
Definition: ToolHandle.h:463
BaseToolHandle::retrieve
StatusCode retrieve(IAlgTool *&tool) const
Definition: ToolHandle.h:92
ToolHandle::i_retrieve
StatusCode i_retrieve(IAlgTool *&algTool) const override
Definition: ToolHandle.h:298
PublicToolHandle
Helper class to construct ToolHandle instances for public tools via the auto registering constructor.
Definition: ToolHandle.h:361
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:256
BaseToolHandle::retrieve
virtual StatusCode retrieve(EnableTool sd)=0
ToolHandle::operator<<
friend std::ostream & operator<<(std::ostream &os, const ToolHandle< T > &handle)
Definition: ToolHandle.h:283
ToolHandle::getAsIAlgTool
const IAlgTool * getAsIAlgTool() const override
Definition: ToolHandle.h:288
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:307
IBinder.h
ToolHandleArray::ToolHandleArray
ToolHandleArray(const std::vector< std::string > &myTypesAndNames, const IInterface *parent=nullptr, bool createIf=true)
Generic constructor.
Definition: ToolHandle.h:414
BaseToolHandle::enable
void enable()
Definition: ToolHandle.h:111
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:445
ToolHandleInfo::isPublic
bool isPublic() const noexcept
Definition: ToolHandle.h:55
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:100
INamedInterface
Definition: INamedInterface.h:25
BaseToolHandle::retrieve
virtual StatusCode retrieve() const =0
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:378
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
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:203
ToolHandle::retrieve
StatusCode retrieve(DisableTool sd) override
Definition: ToolHandle.h:236
AlgTool
Definition: AlgTool.h:62
BaseToolHandle
Definition: ToolHandle.h:84
gaudirun.args
args
Definition: gaudirun.py:336
ToolHandleInfo::m_parent
const IInterface * m_parent
Definition: ToolHandle.h:73
std
STL namespace.
ToolHandleInfo::~ToolHandleInfo
virtual ~ToolHandleInfo()=default
IInterface
Definition: IInterface.h:239
BaseToolHandle::get
const IAlgTool * get() const
Definition: ToolHandle.h:98
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:74
ToolHandle::retrieve
StatusCode retrieve(EnableTool sd) override
Definition: ToolHandle.h:245
GaudiHandleInfo::setComponentType
void setComponentType(std::string componentType)
The component type.
Definition: GaudiHandle.h:84
ToolHandle::getAsIAlgTool
IAlgTool * getAsIAlgTool() override
Definition: ToolHandle.h:293
std::string::empty
T empty(T... args)
PublicToolHandleArray::PublicToolHandleArray
PublicToolHandleArray(bool createIf=true)
Definition: ToolHandle.h:465
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:217
std::size_t
ToolHandleInfo::ToolHandleInfo
ToolHandleInfo(const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:49
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:277
ToolHandle< Gaudi::Interface::Bind::IBinder< IFace > >::bind
auto bind(const EventContext &ctx) const
Definition: ToolHandle.h:348
BaseToolHandle::setEnabled
bool setEnabled(bool flag)
Definition: ToolHandle.h:115
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:320
BaseToolHandle::m_enabled
bool m_enabled
Definition: ToolHandle.h:122
IToolSvc
Definition: IToolSvc.h:29
ToolHandleArray::operator<<
friend std::ostream & operator<<(std::ostream &os, const ToolHandleArray< T > &handle)
Definition: ToolHandle.h:454
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:59
GaudiHandle::retrieve
StatusCode retrieve() const
Retrieve the component.
Definition: GaudiHandle.h:228
ToolHandleInfo::createIf
bool createIf() const noexcept
Definition: ToolHandle.h:57
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:433
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:275
ToolHandle::get
std::add_const_t< T > * get() const
Definition: ToolHandle.h:279
GaudiHandleBase::setTypeAndName
void setTypeAndName(std::string myTypeAndName)
The component "type/name" string.
Definition: GaudiHandle.cpp:19