evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IEvioReader.h
Go to the documentation of this file.
1 //
2 // Copyright 2020, Jefferson Science Associates, LLC.
3 // Subject to the terms in the LICENSE file found in the top-level directory.
4 //
5 // EPSCI Group
6 // Thomas Jefferson National Accelerator Facility
7 // 12000, Jefferson Ave, Newport News, VA 23606
8 // (757)-269-7100
9 
10 
11 #ifndef EVIO_6_0_IEVIOREADER_H
12 #define EVIO_6_0_IEVIOREADER_H
13 
14 
15 #include <cstdint>
16 #include <cstring>
17 #include <string>
18 #include <memory>
19 #include <vector>
20 
21 
22 #include "ByteOrder.h"
23 #include "ByteBuffer.h"
24 #include "IBlockHeader.h"
25 #include "EventParser.h"
26 
27 
28 namespace evio {
29 
30 
39  class IEvioReader {
40 
41  public:
42 
56  };
57 
68  virtual void setBuffer(std::shared_ptr<ByteBuffer> & buf) = 0;
69 
76  virtual bool isClosed() = 0;
77 
83  virtual bool checkBlockNumberSequence() = 0;
84 
89  virtual ByteOrder & getByteOrder() = 0;
90 
95  virtual uint32_t getEvioVersion() = 0;
96 
101  virtual std::string getPath() = 0;
102 
107  virtual std::shared_ptr<EventParser> & getParser() = 0;
108 
113  virtual void setParser(std::shared_ptr<EventParser> & evParser) = 0;
114 
119  virtual std::string getDictionaryXML() = 0;
120 
126  virtual bool hasDictionaryXML() = 0;
127 
134  virtual std::shared_ptr<EvioEvent> getFirstEvent() = 0;
135 
143  virtual bool hasFirstEvent() = 0;
144 
152  virtual size_t getNumEventsRemaining() = 0;
153 
158  virtual std::shared_ptr<ByteBuffer> getByteBuffer() = 0;
159 
164  virtual size_t fileSize() = 0;
165 
170  virtual std::shared_ptr<IBlockHeader> getFirstBlockHeader() = 0;
171 
185  virtual std::shared_ptr<EvioEvent> getEvent(size_t index) = 0;
186 
199  virtual std::shared_ptr<EvioEvent> parseEvent(size_t index) = 0;
200 
218  virtual std::shared_ptr<EvioEvent> nextEvent() = 0;
219 
232  virtual std::shared_ptr<EvioEvent> parseNextEvent() = 0;
233 
246  virtual void parseEvent(std::shared_ptr<EvioEvent> evioEvent) = 0;
247 
258  virtual uint32_t getEventArray(size_t evNumber, std::vector<uint8_t> & vec) = 0;
259 
270  virtual uint32_t getEventBuffer(size_t evNumber, ByteBuffer & buf) = 0;
271 
279  virtual void rewind() = 0;
280 
289  virtual ssize_t position() = 0;
290 
292  virtual void close() = 0;
293 
301  virtual std::shared_ptr<IBlockHeader> getCurrentBlockHeader() = 0;
302 
312  virtual std::shared_ptr<EvioEvent> gotoEventNumber(size_t evNumber) = 0;
313 
323  virtual size_t getEventCount() = 0;
324 
332  virtual size_t getBlockCount() = 0;
333  };
334 
335 }
336 
337 #endif //EVIO_6_0_IEVIOREADER_H
virtual uint32_t getEventArray(size_t evNumber, std::vector< uint8_t > &vec)=0
Get an evio bank or event in vector-of-bytes form.
This class is copied from one of the same name in the Java programming language.
Definition: ByteBuffer.h:42
virtual std::shared_ptr< EvioEvent > parseEvent(size_t index)=0
This is a workhorse method.
virtual size_t getBlockCount()=0
This is the number of blocks/records in the file/buffer including the empty block, record or trailer at the end.
ReadWriteStatus
This enum denotes the status of a read/write.
Definition: IEvioReader.h:54
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
virtual std::shared_ptr< EvioEvent > getEvent(size_t index)=0
Get the event in the file/buffer at a given index (starting at 1).
Definition: IEvioReader.h:55
This pure, virtual class is meant to encapsulate the operation of reading both 2 differently formatte...
Definition: IEvioReader.h:39
Definition: IEvioReader.h:55
virtual std::shared_ptr< ByteBuffer > getByteBuffer()=0
Get the byte buffer being read.
virtual std::shared_ptr< EvioEvent > nextEvent()=0
Get the next event in the file/buffer.
virtual std::shared_ptr< EvioEvent > getFirstEvent()=0
Get the &quot;first&quot; event if there is one.
virtual size_t fileSize()=0
Get the size of the file being read, in bytes.
virtual uint32_t getEvioVersion()=0
Get the evio version number.
virtual void setParser(std::shared_ptr< EventParser > &evParser)=0
Set the file/buffer parser.
virtual std::shared_ptr< EventParser > & getParser()=0
Get the file/buffer parser.
virtual size_t getEventCount()=0
This is the number of events in the file/buffer.
virtual bool isClosed()=0
Has close() been called (without reopening by calling setBuffer(std::shared_ptr&lt;ByteBuffer&gt; &amp;))...
Definition: IEvioReader.h:55
virtual void rewind()=0
The equivalent of rewinding the file.
virtual bool checkBlockNumberSequence()=0
Is this reader checking the block number sequence and throwing an exception if it&#39;s not sequential an...
virtual std::string getDictionaryXML()=0
Get the XML format dictionary if there is one.
virtual void setBuffer(std::shared_ptr< ByteBuffer > &buf)=0
This method can be used to avoid creating additional EvioReader objects by reusing this one with anot...
virtual size_t getNumEventsRemaining()=0
Get the number of events remaining in the file.
Definition: IEvioReader.h:55
virtual uint32_t getEventBuffer(size_t evNumber, ByteBuffer &buf)=0
Get an evio bank or event in ByteBuffer form.
virtual ssize_t position()=0
This is equivalent to obtaining the current position in the file.
virtual std::string getPath()=0
Get the path to the file.
virtual std::shared_ptr< IBlockHeader > getFirstBlockHeader()=0
This returns the FIRST block (record) header.
virtual std::shared_ptr< EvioEvent > parseNextEvent()=0
This is a workhorse method.
virtual bool hasFirstEvent()=0
Does this evio file have an associated first event? It&#39;s also called the Beginning-Of-Run event...
virtual bool hasDictionaryXML()=0
Does this evio file have an associated XML dictionary?
virtual ByteOrder & getByteOrder()=0
Get the byte order of the file/buffer being read.
Definition: IEvioReader.h:55
virtual std::shared_ptr< IBlockHeader > getCurrentBlockHeader()=0
This returns the current (active) block (physical record) header.
virtual void close()=0
This is closes the file, but for buffers it only sets the position to 0.
virtual std::shared_ptr< EvioEvent > gotoEventNumber(size_t evNumber)=0
Go to a specific event in the file.