LCIO  "2.7.4"
 All Classes Namespaces Functions Variables Typedefs Friends Pages
SIOReader.h
1 #ifndef SIO_SIOREADER_H
2 #define SIO_SIOREADER_H 1
3 
4 #include <string>
5 #include <set>
6 #include <map>
7 #include "IO/LCReader.h"
8 #include "IO/LCEventListener.h"
9 #include "IO/LCRunListener.h"
10 
11 #include "IOIMPL/LCEventIOImpl.h"
12 #include "IOIMPL/LCRunHeaderIOImpl.h"
13 
14 #include "LCIORandomAccessMgr.h"
15 #include "LCIOTypes.h"
16 #include "EVENT/LCIO.h"
17 
18 
19 class SIO_record ;
20 class SIO_stream ;
21 
22 
23 namespace SIO {
24 
25 class SIORunHeaderHandler ;
26 class SIOEventHandler ;
27 
33  class SIOReader : public IO::LCReader {
34 
35  // typedef std::map< EVENT::long64 , EVENT::long64 > EventMap ;
36  // typedef RunEventMap EventMap ;
37  public:
38 
41  SIOReader( int lcReaderFlag=0 ) ;
42 
43  // Destructor
44 
45  virtual ~SIOReader() ;
46 
47 
54  virtual void open(const std::vector<std::string>& filenames)
55  throw (IO::IOException, std::exception) ;
56 
57 
61  virtual void open(const std::string & filename) throw (IO::IOException, std::exception) ;
62 
67  virtual EVENT::LCRunHeader * readNextRunHeader() throw (IO::IOException, std::exception) ;
68 
74  virtual EVENT::LCRunHeader * readNextRunHeader(int accessMode) throw (IO::IOException, std::exception) ;
75 
76 
81  virtual EVENT::LCEvent* readNextEvent() throw (IO::IOException, std::exception) ;
82 
83 
89  virtual EVENT::LCEvent* readNextEvent( int accessMode) throw (IO::IOException, std::exception) ;
90 
91 
96  virtual int getNumberOfEvents() throw (IO::IOException, std::exception ) ;
97 
98 
103  virtual int getNumberOfRuns() throw (IO::IOException, std::exception ) ;
104 
105 
110  virtual void getRuns(EVENT::IntVec & runs) ;
111 
118  virtual void getEvents(EVENT::IntVec & events) ;
119 
120 
124  virtual void skipNEvents(int n) throw (IO::IOException, std::exception ) ;
125 
126 
127 
132  virtual void setReadCollectionNames(const std::vector<std::string>& colnames) ;
133 
134 
140  virtual EVENT::LCRunHeader * readRunHeader(int runNumber )
141  throw (IO::IOException , std::exception) ;
142 
148  virtual EVENT::LCRunHeader * readRunHeader(int runNumber, int accessMode )
149  throw (IO::IOException , std::exception) ;
150 
156  virtual EVENT::LCEvent * readEvent(int runNumber, int evtNumber)
157  throw (IO::IOException, std::exception ) ;
158 
159 
165  virtual EVENT::LCEvent * readEvent(int runNumber, int evtNumber, int accessMode)
166  throw (IO::IOException, std::exception ) ;
167 
172  virtual void close() throw (IO::IOException, std::exception) ;
173 
174  // interface for listeners
175 
178  virtual void registerLCEventListener(IO::LCEventListener * ls) ;
179 
182  virtual void removeLCEventListener(IO::LCEventListener * ls) ;
183 
186  virtual void registerLCRunListener(IO::LCRunListener * ls) ;
187 
190  virtual void removeLCRunListener(IO::LCRunListener * ls) ;
191 
199  virtual void readStream() throw (IO::IOException, std::exception) ;
200 
208  virtual void readStream(int maxRecord) throw (IO::IOException, std::exception) ;
209 
210 
211 
212 
213  protected:
214 
215  void setUpHandlers() ;
216  void readRecord() throw (IO::IOException , IO::EndOfDataException , std::exception) ;
217 
218 
219  void postProcessEvent() ;
220 
221  void getEventMap() ;
222 
223  void recreateEventMap() ;
224 
225  protected:
226 
227  // we need an SIO record for every type
228 // SIO_record *_evtRecord ;
229 // SIO_record *_hdrRecord ;
230 // SIO_record *_runRecord ;
231  SIO_record *_dummyRecord ; // used for reading arbitrary records
232  SIO_stream *_stream ;
233 
234  SIORunHeaderHandler* _runHandler ;
235  SIOEventHandler* _evtHandler ;
236 
237  private:
238 
239  IOIMPL::LCEventIOImpl *_defaultEvt ; // used to add collections when reading
240  IOIMPL::LCEventIOImpl *_evt ;
242 
243  std::set<IO::LCRunListener*> _runListeners ;
244  std::set<IO::LCEventListener*> _evtListeners ;
245 
246  std::vector<std::string> _myFilenames ;
247  unsigned int _currentFileIndex ;
248 
249  // EventMap _evtMap ;
250  bool _readEventMap ;
251 
252  // RunEventMap _reMap ;
253  LCIORandomAccessMgr _raMgr ;
254 
255  }; // class
256 } // namespace
257 
258 #endif /* ifndef SIO_SIOREADER_H */
Manager class for LCIO direct access.
Definition: LCIORandomAccessMgr.h:38
Adding stuff needed for io (friend declarations, etc.)
Definition: LCRunHeaderIOImpl.h:22
virtual int getNumberOfRuns()
Return the number of runs (run headers) in the file - the file has to be open.
Definition: SIOReader.cc:189
virtual void getEvents(EVENT::IntVec &events)
Return the run and event numbers of the events in the file - the file has to be open.
Definition: SIOReader.cc:226
Interface for the run header.
Definition: LCRunHeader.h:23
virtual void readStream()
Reads the input stream and notifies registered listeners according to the object type found in the st...
Definition: SIOReader.cc:657
virtual void registerLCEventListener(IO::LCEventListener *ls)
Registers a listener for reading LCEvents from a stream.
Definition: SIOReader.cc:642
virtual EVENT::LCEvent * readNextEvent()
Reads the next event from the file.
Definition: SIOReader.cc:379
virtual void removeLCRunListener(IO::LCRunListener *ls)
Remove a listener for reading LCRunHeaders from a stream.
Definition: SIOReader.cc:653
SIOReader(int lcReaderFlag=0)
Default constructor.
Definition: SIOReader.cc:48
virtual void close()
Closes the output file/stream etc.
Definition: SIOReader.cc:626
Listener for the occurence of LCEvents when reading a stream.
Definition: LCEventListener.h:24
virtual void open(const std::vector< std::string > &filenames)
Opens a list of files for reading (read-only).
Definition: SIOReader.cc:104
virtual void setReadCollectionNames(const std::vector< std::string > &colnames)
Limit the collection names that are going to be read to the subset given in the vector - all other co...
Definition: SIOReader.cc:98
virtual EVENT::LCRunHeader * readRunHeader(int runNumber)
Reads the specified runHeader from file.
Definition: SIOReader.cc:477
Handler for LCEvent/LCEventIOImpl objects.
Definition: SIOEventHandler.h:19
virtual EVENT::LCRunHeader * readNextRunHeader()
Reads the next run header from the file.
Definition: SIOReader.cc:303
virtual int getNumberOfEvents()
Return the number of events in the file - the file has to be open.
Definition: SIOReader.cc:175
Listener for the occurence of LCRunHeader when reading a stream.
Definition: LCRunListener.h:24
IOException used for reading/writing errors.
Definition: Exceptions.h:92
Interface for reading data from LCIO.
Definition: LCReader.h:32
Adding stuff needed for io (friend declarations, etc.)
Definition: LCEventIOImpl.h:22
virtual void getRuns(EVENT::IntVec &runs)
Return the run numbers of the runs (run headers) in the file - the file has to be open...
Definition: SIOReader.cc:203
Handler for LCRunHeader/LCRunHeaderImpl objects.
Definition: SIORunHeaderHandler.h:20
The main event interface.
Definition: LCEvent.h:30
Concrete implementation of LCWriter using SIO.
Definition: SIOReader.h:33
std::vector< int > IntVec
Vector of ints.
Definition: LCIOSTLTypes.h:22
virtual void registerLCRunListener(IO::LCRunListener *ls)
Registers a listener for reading LCEventsLCRunHeaders from a stream.
Definition: SIOReader.cc:649
EndOfDataException for signaling the end of a data stream.
Definition: Exceptions.h:108
virtual EVENT::LCEvent * readEvent(int runNumber, int evtNumber)
Reads the specified event from file.
Definition: SIOReader.cc:522
virtual void removeLCEventListener(IO::LCEventListener *ls)
Remove a listener for reading LCEvents from a stream.
Definition: SIOReader.cc:645
virtual void skipNEvents(int n)
Skips the next n events from the current position.
Definition: SIOReader.cc:440