12 #ifndef EVIO_6_0_EVIOREADERV4_H
13 #define EVIO_6_0_EVIOREADERV4_H
83 uint32_t eventNumber = 0;
89 int32_t eventCount = -1;
92 uint32_t evioVersion = 4;
98 uint32_t firstBlockSize = 0;
105 uint32_t blockCount = 0;
108 std::shared_ptr<BlockHeaderV2> blockHeader2;
111 std::shared_ptr<BlockHeaderV4> blockHeader4;
116 std::shared_ptr<IBlockHeader> blockHeader;
119 std::shared_ptr<IBlockHeader> firstBlockHeader;
122 std::shared_ptr<BlockHeaderV2> firstBlockHeader2;
125 std::shared_ptr<BlockHeaderV4> firstBlockHeader4;
128 uint32_t blockNumberExpected = 1;
131 bool checkBlockNumSeq =
false;
134 bool lastBlock =
false;
137 bool synchronized =
false;
143 std::string dictionaryXML;
146 std::shared_ptr<ByteBuffer> byteBuffer;
149 std::shared_ptr<EventParser> parser;
152 size_t initialPosition = 0;
156 std::vector<uint32_t> eventPositions;
174 size_t fileBytes = 0;
183 bool sequentialRead =
false;
201 uint32_t eventNumber;
203 size_t byteBufferLimit;
204 size_t byteBufferPosition;
205 uint32_t blockNumberExpected;
206 std::shared_ptr<BlockHeaderV2> blockHeader2;
207 std::shared_ptr<BlockHeaderV4> blockHeader4;
210 ReaderState * getState();
211 void restoreState(ReaderState * state);
215 size_t generateEventPositions(std::shared_ptr<ByteBuffer> & byteBuffer);
219 explicit EvioReaderV4(std::string
const & path,
bool checkBlkNumSeq =
false,
bool synced =
false);
220 explicit EvioReaderV4(std::shared_ptr<ByteBuffer> & byteBuffer,
bool checkBlkNumSeq =
false,
bool synced =
false);
223 void setBuffer(std::shared_ptr<ByteBuffer> & buf)
override;
228 std::string
getPath()
override;
230 std::shared_ptr<EventParser> &
getParser()
override;
231 void setParser(std::shared_ptr<EventParser> & evParser)
override;
250 void prepareForSequentialRead();
251 void prepareForBufferRead(std::shared_ptr<ByteBuffer> & buffer)
const;
253 void readDictionary(std::shared_ptr<ByteBuffer> & buffer);
254 std::shared_ptr<EvioEvent> getEventV4(
size_t index);
258 std::shared_ptr<EvioEvent>
getEvent(
size_t index)
override ;
259 std::shared_ptr<EvioEvent>
parseEvent(
size_t index)
override ;
260 std::shared_ptr<EvioEvent>
nextEvent()
override ;
262 void parseEvent(std::shared_ptr<EvioEvent> evioEvent)
override ;
263 uint32_t
getEventArray(
size_t evNumber, std::vector<uint8_t> & vec)
override;
264 uint32_t
getEventBuffer(
size_t evNumber, ByteBuffer & buf)
override;
268 size_t bufferBytesRemaining()
const;
269 uint32_t blockBytesRemaining()
const;
270 std::shared_ptr<EvioEvent> gotoEventNumber(
size_t evNumber,
bool parse);
276 void close()
override ;
279 std::shared_ptr<EvioEvent> gotoEventNumber(
size_t evNumber)
override ;
289 #endif //EVIO_6_0_EVIOREADERV4_H
std::shared_ptr< EvioEvent > parseEvent(size_t index) override
This is a workhorse method.It retrieves the desired event from the file/buffer, and then parses it SA...
Definition: EvioReaderV4.cpp:975
std::shared_ptr< EvioEvent > getEvent(size_t index) override
Get the event in the file/buffer at a given index (starting at 1).As useful as this sounds...
Definition: EvioReaderV4.cpp:897
EvioReaderV4(std::string const &path, bool checkBlkNumSeq=false, bool synced=false)
Constructor for reading an event file.
Definition: EvioReaderV4.cpp:84
std::shared_ptr< EvioEvent > parseNextEvent() override
This is a workhorse method.It retrieves the next event from the file/buffer, and then parses it SAX-l...
Definition: EvioReaderV4.cpp:1130
std::shared_ptr< IBlockHeader > getCurrentBlockHeader() override
This returns the current (active) block (physical record) header.Since most users have no interest in...
Definition: EvioReaderV4.cpp:1287
std::string getPath() override
Get the path to the file.path to the file
Definition: EvioReaderV4.cpp:387
std::shared_ptr< EvioEvent > getFirstEvent() override
Get the "first" event if there is one.It's also called the Beginning-Of-Run event. This event is defined once but included in each of the related split files written out. the first event is it existed, else null.
Definition: EvioReaderV4.cpp:407
static const uint32_t MAGIC_OFFSET
Offset to get magic number from start of file.
Definition: EvioReaderV4.h:63
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
static const uint32_t VERSION_MASK
Mask to get version number from 6th int in block.
Definition: EvioReaderV4.h:72
std::shared_ptr< EvioEvent > nextEvent() override
Get the next event in the file/buffer.As useful as this sounds, most applications will probably call ...
Definition: EvioReaderV4.cpp:988
bool checkBlockNumberSequence() override
Is this reader checking the block number sequence and throwing an exception if it's not sequential an...
Definition: EvioReaderV4.cpp:375
size_t fileSize() override
Get the size of the file being read, in bytes.the file size in bytes
Definition: EvioReaderV4.cpp:438
This pure, virtual class is meant to encapsulate the operation of reading both 2 differently formatte...
Definition: IEvioReader.h:39
void parseFirstHeader(std::shared_ptr< ByteBuffer > &headerBuf)
Reads 8 words of the first block (physical record) header in order to determine the evio version # an...
Definition: EvioReaderV4.cpp:455
void setBuffer(std::shared_ptr< ByteBuffer > &buf) override
This method can be used to avoid creating additional EvioReader objects by reusing this one with anot...
Definition: EvioReaderV4.cpp:332
static const uint32_t BLOCK_SIZE_OFFSET
Offset to get block size from start of block.
Definition: EvioReaderV4.h:69
void close() override
This is closes the file, but for buffers it only sets the position to 0.
Definition: EvioReaderV4.cpp:1262
static const uint32_t DEFAULT_READ_BYTES
Default size for a single file read in bytes when reading evio format 1-3.
Definition: EvioReaderV4.h:77
ssize_t position() override
This is equivalent to obtaining the current position in the file.What it actually does is return the ...
Definition: EvioReaderV4.cpp:1243
ByteOrder & getByteOrder() override
Get the byte order of the file/buffer being read.byte order of the file/buffer being read...
Definition: EvioReaderV4.cpp:379
uint32_t getEventBuffer(size_t evNumber, ByteBuffer &buf) override
Get an evio bank or event in ByteBuffer form.number of event of interest buffer to contain bank's/eve...
Definition: EvioReaderV4.cpp:1166
std::shared_ptr< IBlockHeader > getFirstBlockHeader() override
This returns the FIRST block (record) header.the first block (record) header.
Definition: EvioReaderV4.cpp:442
std::string getDictionaryXML() override
Get the XML format dictionary if there is one.XML format dictionary, else null.
Definition: EvioReaderV4.cpp:399
static const uint32_t VERSION_OFFSET
Offset to get version number from start of file.
Definition: EvioReaderV4.h:66
IEvioReader::ReadWriteStatus processNextBlock()
Reads the block (physical record) header.
Definition: EvioReaderV4.cpp:671
bool isClosed() override
Has close() been called (without reopening by calling setBuffer(std::shared_ptr<ByteBuffer> &))...
Definition: EvioReaderV4.cpp:371
std::shared_ptr< EventParser > & getParser() override
Get the file/buffer parser.file/buffer parser.
Definition: EvioReaderV4.cpp:391
size_t getEventCount() override
This is the number of events in the file/buffer.Any dictionary or first event are not included in the...
Definition: EvioReaderV4.cpp:1358
bool hasFirstEvent() override
Does this evio file have an associated first event? It's also called the Beginning-Of-Run event...
Definition: EvioReaderV4.cpp:416
void setParser(std::shared_ptr< EventParser > &evParser) override
Set the file/buffer parser.file/buffer parser.
Definition: EvioReaderV4.cpp:395
size_t getNumEventsRemaining() override
Get the number of events remaining in the file.Useful only if doing a sequential read.number of events remaining in the file if failed reading from file
Definition: EvioReaderV4.cpp:425
uint32_t getEventArray(size_t evNumber, std::vector< uint8_t > &vec) override
Get an evio bank or event in vector-of-bytes form.number of event of interest (starting at 1)...
Definition: EvioReaderV4.cpp:1152
std::shared_ptr< ByteBuffer > getByteBuffer() override
Get the byte buffer being read.Not useful when reading files. the byte buffer being read (in certain ...
Definition: EvioReaderV4.cpp:434
size_t getBlockCount() override
This is the number of blocks/records in the file/buffer including the empty block, record or trailer at the end.if object closed. the number of records in the file/buffer (estimate for version 3 files).
Definition: EvioReaderV4.cpp:1413
void rewind() override
The equivalent of rewinding the file.What it actually does is set the position of the file/buffer bac...
Definition: EvioReaderV4.cpp:1203
bool hasDictionaryXML() override
Does this evio file have an associated XML dictionary?true if this evio file has an associated XML di...
Definition: EvioReaderV4.cpp:403
static const ByteOrder ENDIAN_LOCAL
Local host's byte order.
Definition: ByteOrder.h:61
This is a class of interest to the user.
Definition: EvioReaderV4.h:58
uint32_t getEvioVersion() override
Get the evio version number.evio version number.
Definition: EvioReaderV4.cpp:383