The Gaudi Framework  v39r1 (adb068b2)
GaudiHandleArray< T > Class Template Reference

T is the concrete handle type, e.g. More...

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

Inheritance diagram for GaudiHandleArray< T >:
Collaboration diagram for GaudiHandleArray< T >:

Public Types

typedef std::vector< T > HandleVector
 
typedef HandleVector::value_type value_type
 
typedef HandleVector::size_type size_type
 
typedef HandleVector::reference reference
 
typedef HandleVector::const_reference const_reference
 
typedef HandleVector::iterator iterator
 
typedef HandleVector::const_iterator const_iterator
 
typedef HandleVector::reverse_iterator reverse_iterator
 
typedef HandleVector::const_reverse_iterator const_reverse_iterator
 
- Public Types inherited from GaudiHandleArrayBase
using PropertyType = GaudiHandleArrayProperty
 
typedef std::vector< GaudiHandleBase * > BaseHandleArray
 
typedef std::vector< const GaudiHandleBase * > ConstBaseHandleArray
 

Public Member Functions

GaudiHandleArrayoperator= (const std::vector< std::string > &myTypesAndNamesList)
 Set the array of GaudiHandles from typeAndNames given in vector of strings. More...
 
GaudiHandleArrayBase::BaseHandleArray getBaseArray () override
 Get a read-write vector of GaudiHandleBase* pointing to the real handles. More...
 
GaudiHandleArrayBase::ConstBaseHandleArray getBaseArray () const override
 Get a read-only vector of const GaudiHandleBase* pointing to the real handles. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator rbegin () const
 
const_iterator rend () const
 
size_type size () const
 
void clear () override
 Clear the list of handles. More...
 
bool empty () const override
 Return whether the list of tools is empty. More...
 
T & operator[] (int index)
 
const T & operator[] (int index) const
 
T * operator[] (std::string_view name)
 Get pointer (!) to ToolHandle by instance name. More...
 
const T * operator[] (std::string_view name) const
 Get const pointer (!) to ToolHandle by instance name. More...
 
virtual bool push_back (const T &myHandle)
 
StatusCode retrieve ()
 Retrieve all tools. More...
 
StatusCode release ()
 Release all tools. More...
 
virtual bool retrieved () const override
 has Array been retreived? More...
 
virtual bool push_back (const std::string &myHandleTypeAndName)=0
 Add a handle with given type and name. More...
 
- Public Member Functions inherited from GaudiHandleArrayBase
bool setTypesAndNames (const std::vector< std::string > &myTypesAndNamesList)
 Set the array of handles from list of "type/name" strings in <myTypesAndNamesList>. More...
 
const std::vector< std::stringtypesAndNames () const
 Return a vector with "type/name" strings of all handles in the array. More...
 
const std::vector< std::stringtypes () const
 Return a vector with "type" strings of all handles in the array. More...
 
const std::vector< std::stringnames () const
 Return a vector with "type/name" strings of all handles in the array. More...
 
const std::vector< std::stringgetBaseInfos (std::string(GaudiHandleBase::*pMemFunc)() const) const
 Helper function to get a vector of strings filled with the return value of each tool of a member function if GaudiHandleBase. More...
 
std::string pythonPropertyClassName () const override
 Name of the componentType with "HandleArray" appended. More...
 
std::string pythonRepr () const override
 Python representation of array of handles, i.e. More...
 
virtual bool push_back (const std::string &myHandleTypeAndName)=0
 Add a handle to the array with "type/name" given in <myHandleTypeAndName>. More...
 
- Public Member Functions inherited from GaudiHandleInfo
virtual ~GaudiHandleInfo ()
 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...
 

Protected Member Functions

 GaudiHandleArray (const std::vector< std::string > &myTypesAndNamesList, std::string myComponentType, std::string myParentName)
 Generic constructor. More...
 
 GaudiHandleArray (const std::string &myComponentType, const std::string &myParentName)
 Constructor creating an empty array. More...
 
- Protected Member Functions inherited from GaudiHandleArrayBase
 GaudiHandleArrayBase (std::string myComponentType, std::string myParentName)
 
- 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...
 

Private Attributes

HandleVector m_handleArray
 
bool m_retrieved { false }
 

Detailed Description

template<class T>
class GaudiHandleArray< T >

T is the concrete handle type, e.g.

ToolHandle<IMyTool>

Definition at line 412 of file GaudiHandle.h.

Member Typedef Documentation

◆ const_iterator

template<class T >
typedef HandleVector::const_iterator GaudiHandleArray< T >::const_iterator

Definition at line 423 of file GaudiHandle.h.

◆ const_reference

template<class T >
typedef HandleVector::const_reference GaudiHandleArray< T >::const_reference

Definition at line 421 of file GaudiHandle.h.

◆ const_reverse_iterator

template<class T >
typedef HandleVector::const_reverse_iterator GaudiHandleArray< T >::const_reverse_iterator

Definition at line 425 of file GaudiHandle.h.

◆ HandleVector

template<class T >
typedef std::vector<T> GaudiHandleArray< T >::HandleVector

Definition at line 417 of file GaudiHandle.h.

◆ iterator

template<class T >
typedef HandleVector::iterator GaudiHandleArray< T >::iterator

Definition at line 422 of file GaudiHandle.h.

◆ reference

template<class T >
typedef HandleVector::reference GaudiHandleArray< T >::reference

Definition at line 420 of file GaudiHandle.h.

◆ reverse_iterator

template<class T >
typedef HandleVector::reverse_iterator GaudiHandleArray< T >::reverse_iterator

Definition at line 424 of file GaudiHandle.h.

◆ size_type

template<class T >
typedef HandleVector::size_type GaudiHandleArray< T >::size_type

Definition at line 419 of file GaudiHandle.h.

◆ value_type

template<class T >
typedef HandleVector::value_type GaudiHandleArray< T >::value_type

Definition at line 418 of file GaudiHandle.h.

Constructor & Destructor Documentation

◆ GaudiHandleArray() [1/2]

template<class T >
GaudiHandleArray< T >::GaudiHandleArray ( const std::vector< std::string > &  myTypesAndNamesList,
std::string  myComponentType,
std::string  myParentName 
)
inlineprotected

Generic constructor.

Probably not very useful...

Parameters
typesAndNamesList: a vector of strings with the concrete "type/name" strings for the list of tools

Definition at line 435 of file GaudiHandle.h.

437  : GaudiHandleArrayBase( std::move( myComponentType ), std::move( myParentName ) ) {
438  setTypesAndNames( myTypesAndNamesList );
439  }

◆ GaudiHandleArray() [2/2]

template<class T >
GaudiHandleArray< T >::GaudiHandleArray ( const std::string myComponentType,
const std::string myParentName 
)
inlineprotected

Constructor creating an empty array.

Parameters
typesAndNamesList: a vector of strings with the concrete "type/name" strings for the list of tools

Definition at line 445 of file GaudiHandle.h.

446  : GaudiHandleArrayBase( myComponentType, myParentName ) {}

Member Function Documentation

◆ begin() [1/2]

template<class T >
iterator GaudiHandleArray< T >::begin ( )
inline

Definition at line 470 of file GaudiHandle.h.

470 { return m_handleArray.begin(); }

◆ begin() [2/2]

template<class T >
const_iterator GaudiHandleArray< T >::begin ( ) const
inline

Definition at line 474 of file GaudiHandle.h.

474 { return m_handleArray.begin(); }

◆ clear()

template<class T >
void GaudiHandleArray< T >::clear ( )
inlineoverridevirtual

Clear the list of handles.

Implemented in GaudiHandleArray

Implements GaudiHandleArrayBase.

Definition at line 484 of file GaudiHandle.h.

484 { m_handleArray.clear(); }

◆ empty()

template<class T >
bool GaudiHandleArray< T >::empty ( ) const
inlineoverridevirtual

Return whether the list of tools is empty.

Implements GaudiHandleArrayBase.

Definition at line 486 of file GaudiHandle.h.

486 { return m_handleArray.empty(); }

◆ end() [1/2]

template<class T >
iterator GaudiHandleArray< T >::end ( )
inline

Definition at line 472 of file GaudiHandle.h.

472 { return m_handleArray.end(); }

◆ end() [2/2]

template<class T >
const_iterator GaudiHandleArray< T >::end ( ) const
inline

Definition at line 476 of file GaudiHandle.h.

476 { return m_handleArray.end(); }

◆ getBaseArray() [1/2]

template<class T >
GaudiHandleArrayBase::ConstBaseHandleArray GaudiHandleArray< T >::getBaseArray ( ) const
inlineoverridevirtual

Get a read-only vector of const GaudiHandleBase* pointing to the real handles.

Implemented in GaudiHandleArray.

Implements GaudiHandleArrayBase.

Definition at line 461 of file GaudiHandle.h.

461  {
463  for ( auto& h : m_handleArray ) baseArray.push_back( &h );
464  return baseArray;
465  }

◆ getBaseArray() [2/2]

template<class T >
GaudiHandleArrayBase::BaseHandleArray GaudiHandleArray< T >::getBaseArray ( )
inlineoverridevirtual

Get a read-write vector of GaudiHandleBase* pointing to the real handles.

Implemented in GaudiHandleArray.

Implements GaudiHandleArrayBase.

Definition at line 455 of file GaudiHandle.h.

455  {
457  for ( auto& h : m_handleArray ) baseArray.push_back( &h );
458  return baseArray;
459  }

◆ operator=()

template<class T >
GaudiHandleArray& GaudiHandleArray< T >::operator= ( const std::vector< std::string > &  myTypesAndNamesList)
inline

Set the array of GaudiHandles from typeAndNames given in vector of strings.

Definition at line 450 of file GaudiHandle.h.

450  {
451  setTypesAndNames( myTypesAndNamesList );
452  return *this;
453  }

◆ operator[]() [1/4]

template<class T >
T& GaudiHandleArray< T >::operator[] ( int  index)
inline

Definition at line 488 of file GaudiHandle.h.

488 { return m_handleArray[index]; }

◆ operator[]() [2/4]

template<class T >
const T& GaudiHandleArray< T >::operator[] ( int  index) const
inline

Definition at line 490 of file GaudiHandle.h.

490 { return m_handleArray[index]; }

◆ operator[]() [3/4]

template<class T >
T* GaudiHandleArray< T >::operator[] ( std::string_view  name)
inline

Get pointer (!) to ToolHandle by instance name.

Returns zero pointer if not found

Definition at line 493 of file GaudiHandle.h.

493  {
494  auto it = std::find_if( begin(), end(), [&]( const_reference r ) { return r.name() == name; } );
495  return it != end() ? &*it : nullptr;
496  }

◆ operator[]() [4/4]

template<class T >
const T* GaudiHandleArray< T >::operator[] ( std::string_view  name) const
inline

Get const pointer (!) to ToolHandle by instance name.

Returns zero pointer if not found

Definition at line 499 of file GaudiHandle.h.

499  {
500  auto it = std::find_if( begin(), end(), [&]( const_reference r ) { return r.name() == name; } );
501  return it != end() ? &*it : nullptr;
502  }

◆ push_back() [1/2]

template<class T >
virtual bool GaudiHandleArrayBase::push_back

Add a handle with given type and name.

Can be overridden in derived class. Return whether addition was successful or not.

◆ push_back() [2/2]

template<class T >
virtual bool GaudiHandleArray< T >::push_back ( const T &  myHandle)
inlinevirtual

Reimplemented in ToolHandleArray< T >, ToolHandleArray< IThreadInitTool >, ToolHandleArray< IMyTool >, and ServiceHandleArray< T >.

Definition at line 507 of file GaudiHandle.h.

507  {
508  m_handleArray.push_back( myHandle );
509  return true;
510  }

◆ rbegin()

template<class T >
const_iterator GaudiHandleArray< T >::rbegin ( ) const
inline

Definition at line 478 of file GaudiHandle.h.

478 { return m_handleArray.rbegin(); }

◆ release()

template<class T >
StatusCode GaudiHandleArray< T >::release ( )
inline

Release all tools.

Definition at line 527 of file GaudiHandle.h.

527  {
529  for ( auto& i : *this ) {
530  // continue trying to release other tools even if we fail...
531  if ( i.release().isFailure() ) sc = StatusCode::FAILURE;
532  }
533  return sc;
534  }

◆ rend()

template<class T >
const_iterator GaudiHandleArray< T >::rend ( ) const
inline

Definition at line 480 of file GaudiHandle.h.

480 { return m_handleArray.rend(); }

◆ retrieve()

template<class T >
StatusCode GaudiHandleArray< T >::retrieve ( )
inline

Retrieve all tools.

Definition at line 513 of file GaudiHandle.h.

513  {
515  for ( auto& i : *this ) {
516  // stop at first failure
517  if ( i.retrieve().isFailure() ) {
518  sc = StatusCode::FAILURE;
519  break;
520  }
521  }
522  if ( sc ) { m_retrieved = true; }
523  return sc;
524  }

◆ retrieved()

template<class T >
virtual bool GaudiHandleArray< T >::retrieved ( ) const
inlineoverridevirtual

has Array been retreived?

Implements GaudiHandleArrayBase.

Definition at line 537 of file GaudiHandle.h.

537 { return m_retrieved; }

◆ size()

template<class T >
size_type GaudiHandleArray< T >::size ( ) const
inline

Definition at line 482 of file GaudiHandle.h.

482 { return m_handleArray.size(); }

Member Data Documentation

◆ m_handleArray

template<class T >
HandleVector GaudiHandleArray< T >::m_handleArray
private

Definition at line 543 of file GaudiHandle.h.

◆ m_retrieved

template<class T >
bool GaudiHandleArray< T >::m_retrieved { false }
private

Definition at line 544 of file GaudiHandle.h.


The documentation for this class was generated from the following file:
std::move
T move(T... args)
GaudiHandleArray::m_retrieved
bool m_retrieved
Definition: GaudiHandle.h:544
std::vector
STL class.
std::find_if
T find_if(T... args)
std::vector::size
T size(T... args)
GaudiHandleArray::end
iterator end()
Definition: GaudiHandle.h:472
std::vector::clear
T clear(T... args)
std::vector::push_back
T push_back(T... args)
StatusCode
Definition: StatusCode.h:65
AlgSequencer.h
h
Definition: AlgSequencer.py:31
std::vector::rend
T rend(T... args)
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
GaudiHandleArray::const_reference
HandleVector::const_reference const_reference
Definition: GaudiHandle.h:421
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
GaudiHandleArray::m_handleArray
HandleVector m_handleArray
Definition: GaudiHandle.h:543
std::vector::begin
T begin(T... args)
std::vector::empty
T empty(T... args)
GaudiHandleArrayBase::GaudiHandleArrayBase
GaudiHandleArrayBase(std::string myComponentType, std::string myParentName)
Definition: GaudiHandle.h:351
GaudiHandleArray::begin
iterator begin()
Definition: GaudiHandle.h:470
std::vector::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
std::vector::rbegin
T rbegin(T... args)
Gaudi::ParticleProperties::index
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...
Definition: IParticlePropertySvc.cpp:39