UTIL::LCIterator< T > Class Template Reference

Simple convenient iterator class for LCCollections that saves some boiler plate code. More...

#include <UTIL/LCIterator.h>

List of all members.

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.
 LCIterator (EVENT::LCCollection *col)
 Constructor for the given collection.
T * next ()
 Returns the next element as long as there is one, otherwise 0 is returned.
int size ()
 Size of the collection.
EVENT::LCCollectionoperator-> ()
 Serves as a handle to the LCCollection itself, to provide access to the collection parameters etc.
EVENT::LCCollectionoperator() ()
 Return pointer to LCCollection, e.g.

Detailed Description

template<class T>
class UTIL::LCIterator< T >

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  ;
   }
  
Author:
F.Gaede, DESY
Version:
$Id:$

Member Function Documentation

template<class T>
EVENT::LCCollection* UTIL::LCIterator< T >::operator() (  )  [inline]

Return pointer to LCCollection, e.g.

for testing whether the collections was in the event.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Friends

Generated on 6 Mar 2020 for LCIO by  doxygen 1.6.1