The Gaudi Framework  v36r3 (83a1ddab)
ToolHandle.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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( const bool flag ) {
112  auto old = m_enabled;
113  m_enabled = flag;
114  return old;
115  }
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  typename = std::enable_if_t<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 <class OWNER, typename = std::enable_if_t<std::is_base_of_v<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  return const_cast<IAlgTool*>( tool )
327  ->queryInterface( IFace::interfaceID(), &( self->m_ptr ) )
328  .andThen( [&] {
329  // TODO: what happens to the refCount?
330  self->m_bind = []( const void* ptr, const EventContext& ) {
331  return Gaudi::Interface::Bind::Box<IFace>( static_cast<IFace const*>( ptr ) );
332  };
333  } )
334  .orElse( [&]() {
335  return const_cast<IAlgTool*>( tool )
336  ->queryInterface( Gaudi::Interface::Bind::IBinder<IFace>::interfaceID(), &( self->m_ptr ) )
337  .andThen( [&] {
338  // TODO: what happens to the refCount?
339  self->m_bind = []( const void* ptr, const EventContext& ctx ) {
340  return static_cast<Gaudi::Interface::Bind::IBinder<IFace> const*>( ptr )->bind( ctx );
341  };
342  } );
343  } );
344  } );
345  }
346 
347  auto bind( const EventContext& ctx ) const { return ( *m_bind )( m_ptr, ctx ); }
348 };
349 
353 template <class T>
354 class PublicToolHandle : public ToolHandle<T> {
355 public:
357  PublicToolHandle( const char* toolTypeAndName, bool createIf = true )
358  : PublicToolHandle{ std::string{ toolTypeAndName }, createIf } {}
359  PublicToolHandle( const std::string& toolTypeAndName, bool createIf = true )
360  : ToolHandle<T>( toolTypeAndName, nullptr, createIf ) {}
361 
363  template <typename CT = T, typename NCT = std::remove_const_t<T>>
365  std::enable_if_t<std::is_const_v<CT> && !std::is_same_v<CT, NCT>>* = nullptr )
366  : ToolHandle<T>( static_cast<const ToolHandle<NCT>&>( other ) ) {}
367 
370  template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
371  inline PublicToolHandle( OWNER* owner, std::string propName, std::string toolType, std::string doc = "" )
372  : PublicToolHandle() {
373  // convert name and type to a valid type/name string
374  // - if type does not contain '/' use type/type
375  // - otherwise type is already a type/name string
376  if ( !toolType.empty() and toolType.find( '/' ) == std::string::npos ) { toolType += '/' + toolType; }
377  owner->declareTool( *this, std::move( toolType ) ).ignore();
378  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( propName ), *this, std::move( doc ) );
379  p->template setOwnerType<OWNER>();
380  }
381 };
382 
383 //-------------------------------------------------------------------------//
384 
395 template <class T>
396 class ToolHandleArray : public ToolHandleInfo, public GaudiHandleArray<ToolHandle<T>> {
397 public:
398  //
399  // Constructors
400  //
407  ToolHandleArray( const std::vector<std::string>& myTypesAndNames, const IInterface* parent = nullptr,
408  bool createIf = true )
412 
417  ToolHandleArray( const IInterface* parent = nullptr, bool createIf = true )
421 
426  bool push_back( const std::string& toolTypeAndName ) override {
427  ToolHandle<T> handle( toolTypeAndName, ToolHandleInfo::parent(), ToolHandleInfo::createIf() );
429  return true;
430  }
431 
433  bool push_back( const ToolHandle<T>& myHandle ) override { return push_back( myHandle.typeAndName() ); }
434 
437  template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
439  std::string doc = "" )
440  : ToolHandleArray( owner ) {
441  owner->addToolsArray( *this );
443  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( name ), *this, std::move( doc ) );
444  p->template setOwnerType<OWNER>();
445  }
446 
447  friend std::ostream& operator<<( std::ostream& os, const ToolHandleArray<T>& handle ) {
448  return os << static_cast<const GaudiHandleInfo&>( handle );
449  }
450 };
451 
455 template <class T>
457 public:
461 
464  template <class OWNER, typename = std::enable_if_t<std::is_base_of_v<IProperty, OWNER>>>
466  std::string doc = "" )
468  owner->addToolsArray( *this );
470  auto p = owner->OWNER::PropertyHolderImpl::declareProperty( std::move( name ), *this, std::move( doc ) );
471  p->template setOwnerType<OWNER>();
472  }
473 };
474 
475 #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:63
PublicToolHandle::PublicToolHandle
PublicToolHandle(const std::string &toolTypeAndName, bool createIf=true)
Definition: ToolHandle.h:359
GaudiHandle.h
std::string
STL class.
IAlgTool
Definition: IAlgTool.h:33
BaseToolHandle::setEnabled
bool setEnabled(const bool flag)
Definition: ToolHandle.h:111
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:181
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:371
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:203
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:433
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:308
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:158
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:81
ToolHandle::ToolHandle
ToolHandle(std::tuple< Args... > &&args)
Definition: ToolHandle.h:214
Service
Definition: Service.h:46
GaudiHandleBase
Definition: GaudiHandle.h:99
PublicToolHandle::PublicToolHandle
PublicToolHandle(bool createIf=true)
Definition: ToolHandle.h:356
GaudiHandle
Definition: GaudiHandle.h:173
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:417
PublicToolHandleArray::PublicToolHandleArray
PublicToolHandleArray(const std::vector< std::string > &typesAndNames, bool createIf=true)
Definition: ToolHandle.h:459
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
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:438
GaudiHandle::get
T * get()
Return the wrapped pointer, not calling retrieve() if null.
Definition: GaudiHandle.h:260
bug_34121.tool
tool
Definition: bug_34121.py:17
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:30
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:465
TimingHistograms.name
name
Definition: TimingHistograms.py:25
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:588
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:246
PublicToolHandle::PublicToolHandle
PublicToolHandle(const char *toolTypeAndName, bool createIf=true)
Definition: ToolHandle.h:357
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: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:396
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:456
BaseToolHandle::retrieve
StatusCode retrieve(IAlgTool *&tool) const
Definition: ToolHandle.h:88
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:354
GaudiHandleBase::typeAndName
std::string typeAndName() const
The full type and name: "type/name".
Definition: GaudiHandle.h:125
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:93
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
Header file for std:chrono::duration-based Counters.
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:407
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
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ToolHandle::retrieve
StatusCode retrieve(DisableTool sd) override
Definition: ToolHandle.h:236
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:237
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:245
GaudiHandleInfo::setComponentType
void setComponentType(std::string componentType)
The component type.
Definition: GaudiHandle.h:78
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:458
ToolHandle::initialize
StatusCode initialize(const std::string &toolTypeAndName, const IInterface *parent=nullptr, bool createIf=true)
Definition: ToolHandle.h:217
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:364
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:78
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:347
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:447
GaudiHandleArray
T is the concrete handle type, e.g.
Definition: GaudiHandle.h:405
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:222
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:426
GaudiHandle::release
StatusCode release() const
Release the component.
Definition: GaudiHandle.h:236
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