00001 #ifndef SIO_SIOREADER_H 00002 #define SIO_SIOREADER_H 1 00003 00004 #include <string> 00005 #include <set> 00006 #include <map> 00007 #include "IO/LCReader.h" 00008 #include "IO/LCEventListener.h" 00009 #include "IO/LCRunListener.h" 00010 00011 #include "IOIMPL/LCEventIOImpl.h" 00012 #include "IOIMPL/LCRunHeaderIOImpl.h" 00013 00014 #include "LCIORandomAccessMgr.h" 00015 #include "LCIOTypes.h" 00016 #include "EVENT/LCIO.h" 00017 00018 00019 class SIO_record ; 00020 class SIO_stream ; 00021 00022 00023 namespace SIO { 00024 00025 class SIORunHeaderHandler ; 00026 class SIOEventHandler ; 00027 00033 class SIOReader : public IO::LCReader { 00034 00035 // typedef std::map< EVENT::long64 , EVENT::long64 > EventMap ; 00036 // typedef RunEventMap EventMap ; 00037 public: 00038 00041 SIOReader( int lcReaderFlag=0 ) ; 00042 00044 SIOReader(const SIOReader&) = delete ; 00046 SIOReader& operator=(const SIOReader&) = delete ; 00047 00049 virtual ~SIOReader() ; 00050 00051 00058 virtual void open(const std::vector<std::string>& filenames) 00059 ; 00060 00061 00065 virtual void open(const std::string & filename) ; 00066 00071 virtual EVENT::LCRunHeader * readNextRunHeader() ; 00072 00078 virtual EVENT::LCRunHeader * readNextRunHeader(int accessMode) ; 00079 00080 00085 virtual EVENT::LCEvent* readNextEvent() ; 00086 00087 00093 virtual EVENT::LCEvent* readNextEvent( int accessMode) ; 00094 00095 00100 virtual int getNumberOfEvents() ; 00101 00102 00107 virtual int getNumberOfRuns() ; 00108 00109 00114 virtual void getRuns(EVENT::IntVec & runs) ; 00115 00122 virtual void getEvents(EVENT::IntVec & events) ; 00123 00124 00128 virtual void skipNEvents(int n) ; 00129 00130 00131 00136 virtual void setReadCollectionNames(const std::vector<std::string>& colnames) ; 00137 00138 00144 virtual EVENT::LCRunHeader * readRunHeader(int runNumber ) 00145 ; 00146 00152 virtual EVENT::LCRunHeader * readRunHeader(int runNumber, int accessMode ) 00153 ; 00154 00160 virtual EVENT::LCEvent * readEvent(int runNumber, int evtNumber) 00161 ; 00162 00163 00169 virtual EVENT::LCEvent * readEvent(int runNumber, int evtNumber, int accessMode) 00170 ; 00171 00176 virtual void close() ; 00177 00178 // interface for listeners 00179 00182 virtual void registerLCEventListener(IO::LCEventListener * ls) ; 00183 00186 virtual void removeLCEventListener(IO::LCEventListener * ls) ; 00187 00190 virtual void registerLCRunListener(IO::LCRunListener * ls) ; 00191 00194 virtual void removeLCRunListener(IO::LCRunListener * ls) ; 00195 00203 virtual void readStream() ; 00204 00212 virtual void readStream(int maxRecord) ; 00213 00214 00215 00216 00217 protected: 00218 00219 void setUpHandlers() ; 00220 void readRecord() ; 00221 00222 00223 void postProcessEvent() ; 00224 00225 void getEventMap() ; 00226 00227 void recreateEventMap() ; 00228 00229 protected: 00230 00231 SIO_record *_dummyRecord {NULL}; // used for reading arbitrary records 00232 SIO_stream *_stream{NULL} ; 00233 00234 SIORunHeaderHandler* _runHandler{NULL} ; 00235 SIOEventHandler* _evtHandler{NULL} ; 00236 00237 private: 00238 00239 IOIMPL::LCEventIOImpl *_defaultEvt{NULL} ; // used to add collections when reading 00240 IOIMPL::LCEventIOImpl *_evt{NULL} ; 00241 IOIMPL::LCRunHeaderIOImpl *_run{NULL} ; 00242 00243 std::set<IO::LCRunListener*> _runListeners{} ; 00244 std::set<IO::LCEventListener*> _evtListeners{} ; 00245 00246 std::vector<std::string> _myFilenames{} ; 00247 unsigned int _currentFileIndex{0} ; 00248 00249 bool _readEventMap{false} ; 00250 00251 LCIORandomAccessMgr _raMgr{} ; 00252 00253 }; // class 00254 } // namespace 00255 00256 #endif /* ifndef SIO_SIOREADER_H */