The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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.
 
GaudiHandleArrayBase::BaseHandleArray getBaseArray () override
 Get a read-write vector of GaudiHandleBase* pointing to the real handles.
 
GaudiHandleArrayBase::ConstBaseHandleArray getBaseArray () const override
 Get a read-only vector of const GaudiHandleBase* pointing to the real handles.
 
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.
 
bool empty () const override
 Return whether the list of tools is empty.
 
T & operator[] (int index)
 
const T & operator[] (int index) const
 
T * operator[] (std::string_view name)
 Get pointer (!) to ToolHandle by instance name.
 
const T * operator[] (std::string_view name) const
 Get const pointer (!) to ToolHandle by instance name.
 
virtual bool push_back (const T &myHandle)
 
StatusCode retrieve () override
 Retrieve all tools.
 
StatusCode release () override
 Release all tools.
 
virtual bool retrieved () const override
 has Array been retreived?
 
virtual bool push_back (const std::string &myHandleTypeAndName)=0
 Add a handle with given type and name.
 
- 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>.
 
const std::vector< std::string > typesAndNames () const
 Return a vector with "type/name" strings of all handles in the array.
 
const std::vector< std::string > types () const
 Return a vector with "type" strings of all handles in the array.
 
const std::vector< std::string > names () const
 Return a vector with "type/name" strings of all handles in the array.
 
const std::vector< std::string > getBaseInfos (auto(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.
 
std::string pythonPropertyClassName () const override
 Name of the componentType with "HandleArray" appended.
 
std::string pythonRepr () const override
 Python representation of array of handles, i.e.
 
- 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.
 

Protected Member Functions

 GaudiHandleArray (const std::vector< std::string > &myTypesAndNamesList, std::string myComponentType, std::string myParentName)
 Generic constructor.
 
 GaudiHandleArray (const std::string &myComponentType, const std::string &myParentName)
 Constructor creating an empty array.
 
- 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.
 
void setComponentType (std::string componentType)
 The component type.
 
void setParentName (std::string parent)
 The name of the parent.
 

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 403 of file GaudiHandle.h.

Member Typedef Documentation

◆ const_iterator

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

Definition at line 414 of file GaudiHandle.h.

◆ const_reference

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

Definition at line 412 of file GaudiHandle.h.

◆ const_reverse_iterator

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

Definition at line 416 of file GaudiHandle.h.

◆ HandleVector

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

Definition at line 408 of file GaudiHandle.h.

◆ iterator

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

Definition at line 413 of file GaudiHandle.h.

◆ reference

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

Definition at line 411 of file GaudiHandle.h.

◆ reverse_iterator

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

Definition at line 415 of file GaudiHandle.h.

◆ size_type

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

Definition at line 410 of file GaudiHandle.h.

◆ value_type

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

Definition at line 409 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 426 of file GaudiHandle.h.

430 }
GaudiHandleArrayBase(std::string myComponentType, std::string myParentName)
bool setTypesAndNames(const std::vector< std::string > &myTypesAndNamesList)
Set the array of handles from list of "type/name" strings in <myTypesAndNamesList>.
T is the concrete handle type, e.g.

◆ 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 436 of file GaudiHandle.h.

Member Function Documentation

◆ begin() [1/2]

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

Definition at line 461 of file GaudiHandle.h.

461{ return m_handleArray.begin(); }
HandleVector m_handleArray

◆ begin() [2/2]

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

Definition at line 465 of file GaudiHandle.h.

465{ 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 475 of file GaudiHandle.h.

475{ 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 477 of file GaudiHandle.h.

477{ return m_handleArray.empty(); }

◆ end() [1/2]

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

Definition at line 463 of file GaudiHandle.h.

463{ return m_handleArray.end(); }

◆ end() [2/2]

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

Definition at line 467 of file GaudiHandle.h.

467{ 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 452 of file GaudiHandle.h.

452 {
454 for ( auto& h : m_handleArray ) baseArray.push_back( &h );
455 return baseArray;
456 }
virtual bool push_back(const T &myHandle)

◆ 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 446 of file GaudiHandle.h.

446 {
448 for ( auto& h : m_handleArray ) baseArray.push_back( &h );
449 return baseArray;
450 }

◆ 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 441 of file GaudiHandle.h.

441 {
443 return *this;
444 }

◆ operator[]() [1/4]

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

Definition at line 479 of file GaudiHandle.h.

479{ return m_handleArray[index]; }

◆ operator[]() [2/4]

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

Definition at line 481 of file GaudiHandle.h.

481{ 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 484 of file GaudiHandle.h.

484 {
485 auto it = std::find_if( begin(), end(), [&]( const_reference r ) { return r.name() == name; } );
486 return it != end() ? &*it : nullptr;
487 }
iterator begin()
HandleVector::const_reference const_reference

◆ 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 490 of file GaudiHandle.h.

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

◆ push_back() [1/2]

template<class T>
virtual bool GaudiHandleArrayBase::push_back ( const std::string & myHandleTypeAndName)
virtual

Add a handle with given type and name.

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

Implements GaudiHandleArrayBase.

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

◆ push_back() [2/2]

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

Definition at line 498 of file GaudiHandle.h.

498 {
499 m_handleArray.push_back( myHandle );
500 return true;
501 }

◆ rbegin()

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

Definition at line 469 of file GaudiHandle.h.

469{ return m_handleArray.rbegin(); }

◆ release()

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

Release all tools.

Implements GaudiHandleArrayBase.

Definition at line 518 of file GaudiHandle.h.

518 {
520 for ( auto& i : *this ) {
521 // continue trying to release other tools even if we fail...
523 }
524 return sc;
525 }
StatusCode release() override
Release all tools.
bool isFailure() const
Definition StatusCode.h:129

◆ rend()

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

Definition at line 471 of file GaudiHandle.h.

471{ return m_handleArray.rend(); }

◆ retrieve()

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

Retrieve all tools.

Implements GaudiHandleArrayBase.

Definition at line 504 of file GaudiHandle.h.

504 {
506 for ( auto& i : *this ) {
507 // stop at first failure
508 if ( i.retrieve().isFailure() ) {
510 break;
511 }
512 }
513 if ( sc ) { m_retrieved = true; }
514 return sc;
515 }
StatusCode retrieve() override
Retrieve all tools.

◆ retrieved()

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

has Array been retreived?

Implements GaudiHandleArrayBase.

Definition at line 528 of file GaudiHandle.h.

528{ return m_retrieved; }

◆ size()

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

Definition at line 473 of file GaudiHandle.h.

473{ return m_handleArray.size(); }

Member Data Documentation

◆ m_handleArray

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

Definition at line 534 of file GaudiHandle.h.

◆ m_retrieved

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

Definition at line 535 of file GaudiHandle.h.

535{ false };

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