LCIO
02.17
|
Simple convenient iterator class for LCCollections that saves some boiler plate code. More...
#include <LCIterator.h>
Public Member Functions | |
LCIterator (EVENT::LCEvent *evt, const std::string &name) | |
Constructor that reads the collection with the given name from the event - note: no exception is thrown if the collection is not in the event, this will behave the same as an empty collection - use operator() to test, if the collection exists. More... | |
LCIterator (const EVENT::LCCollection *col) | |
Constructor for the given collection. More... | |
T * | next () |
Returns the next element as long as there is one, otherwise 0 is returned. More... | |
int | size () |
Size of the collection. More... | |
const EVENT::LCCollection * | operator-> () |
Serves as a handle to the LCCollection itself, to provide access to the collection parameters etc. More... | |
const EVENT::LCCollection * | operator() () |
Return pointer to LCCollection, e.g. More... | |
Private Member Functions | |
LCIterator () | |
Private Attributes | |
int | _n {0} |
int | _i |
const EVENT::LCCollection * | _col |
Simple convenient iterator class for LCCollections that saves some boiler plate code.
LCIterators can be constructed either form an LCCollection or from the LCEvent and and a collection name.
Examples:
// ------ use with while(): LCIterator<TrackerHit> it( evt, "VXDCollection" ) ; while( TrackerHit* hit = it.next() ){
hitMap[ hit->getCellID0() ] = hit ; }
// --- with for() : for( LCIterator<Track> it( col ) ; Track* trk = it.next() ; ) {
std::cout << trk->getTrackState( TrackState::AtIP ) << std::endl ; }
Definition at line 39 of file LCIterator.h.
|
inlineprivate |
Definition at line 41 of file LCIterator.h.
|
inline |
Constructor that reads the collection with the given name from the event - note: no exception is thrown if the collection is not in the event, this will behave the same as an empty collection - use operator() to test, if the collection exists.
Definition at line 50 of file LCIterator.h.
References UTIL::LCIterator< T >::_col, UTIL::LCIterator< T >::_n, std::endl(), EVENT::LCCollection::getElementAt(), EVENT::LCCollection::getNumberOfElements(), and std::stringstream::str().
|
inline |
Constructor for the given collection.
Definition at line 77 of file LCIterator.h.
References UTIL::LCIterator< T >::_col, UTIL::LCIterator< T >::_n, std::endl(), EVENT::LCCollection::getElementAt(), EVENT::LCCollection::getNumberOfElements(), and std::stringstream::str().
|
inline |
Returns the next element as long as there is one, otherwise 0 is returned.
Definition at line 96 of file LCIterator.h.
References UTIL::LCIterator< T >::_col, UTIL::LCIterator< T >::_i, UTIL::LCIterator< T >::_n, and EVENT::LCCollection::getElementAt().
|
inline |
Return pointer to LCCollection, e.g.
for testing whether the collections was in the event.
Definition at line 116 of file LCIterator.h.
References UTIL::LCIterator< T >::_col.
|
inline |
Serves as a handle to the LCCollection itself, to provide access to the collection parameters etc.
Definition at line 112 of file LCIterator.h.
References UTIL::LCIterator< T >::_col.
|
inline |
Size of the collection.
Definition at line 107 of file LCIterator.h.
References UTIL::LCIterator< T >::_n.
|
private |
Definition at line 120 of file LCIterator.h.
Referenced by UTIL::LCIterator< T >::LCIterator(), UTIL::LCIterator< T >::next(), UTIL::LCIterator< T >::operator()(), and UTIL::LCIterator< T >::operator->().
|
private |
Definition at line 119 of file LCIterator.h.
Referenced by UTIL::LCIterator< T >::next().
|
private |
Definition at line 119 of file LCIterator.h.
Referenced by UTIL::LCIterator< T >::LCIterator(), UTIL::LCIterator< T >::next(), and UTIL::LCIterator< T >::size().