evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EvioReaderV6.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_EVIOREADERV6_H
12 #define EVIO_6_0_EVIOREADERV6_H
13 
14 
15 #include <fstream>
16 #include <vector>
17 #include <memory>
18 #include <mutex>
19 
20 
21 #include "ByteOrder.h"
22 #include "ByteBuffer.h"
23 #include "IEvioReader.h"
24 #include "EvioReader.h"
25 #include "IBlockHeader.h"
26 #include "BlockHeaderV2.h"
27 #include "BlockHeaderV4.h"
28 #include "EventParser.h"
29 #include "Reader.h"
30 
31 
32 namespace evio {
33 
52  class EvioReaderV6 : public IEvioReader {
53 
54  private:
55 
57  std::shared_ptr<Reader> reader;
58 
60  bool closed = false;
61 
63  std::shared_ptr<EventParser> parser;
64 
66  bool synchronized = false;
67 
69  std::mutex mtx;
70 
71 
72  public:
73 
74 
75  explicit EvioReaderV6(std::string const & path, bool checkRecNumSeq = false, bool synced = false);
76  explicit EvioReaderV6(std::shared_ptr<ByteBuffer> & byteBuffer, bool checkRecNumSeq = false, bool synced = false);
77 
78 
79  void setBuffer(std::shared_ptr<ByteBuffer> & buf) override ;
80  bool isClosed() override ;
81  bool checkBlockNumberSequence() override ;
82  ByteOrder & getByteOrder() override ;
83  uint32_t getEvioVersion() override ;
84  std::string getPath()override ;
85 
86  std::shared_ptr<EventParser> & getParser() override ;
87  void setParser(std::shared_ptr<EventParser> & evParser) override ;
88 
89  std::string getDictionaryXML() override ;
90  bool hasDictionaryXML() override ;
91  std::shared_ptr<EvioEvent> getFirstEvent() override;
92  bool hasFirstEvent() override;
93 
94  size_t getNumEventsRemaining() override ;
95  std::shared_ptr<ByteBuffer> getByteBuffer() override ;
96  size_t fileSize() override ;
97  std::shared_ptr<IBlockHeader> getFirstBlockHeader() override ;
98 
99  std::shared_ptr<EvioEvent> getEvent(size_t index) override ;
100  std::shared_ptr<EvioEvent> parseEvent(size_t index) override ;
101  std::shared_ptr<EvioEvent> nextEvent() override ;
102  std::shared_ptr<EvioEvent> parseNextEvent() override ;
103  void parseEvent(std::shared_ptr<EvioEvent> evioEvent) override ;
104 
105  uint32_t getEventArray(size_t evNumber, std::vector<uint8_t> & vec) override;
106  uint32_t getEventBuffer(size_t evNumber, ByteBuffer & buf) override;
107 
108  void rewind() override ;
109  ssize_t position() override ;
110  void close() override ;
111 
112  std::shared_ptr<IBlockHeader> getCurrentBlockHeader() override ;
113  std::shared_ptr<EvioEvent> gotoEventNumber(size_t evNumber) override ;
114 
115  size_t getEventCount() override ;
116  size_t getBlockCount() override ;
117  };
118 
119 }
120 
121 
122 #endif //EVIO_6_0_EVIOREADERV6_H
std::shared_ptr< EventParser > & getParser() override
Get the file/buffer parser.file/buffer parser.
Definition: EvioReaderV6.cpp:103
std::shared_ptr< EvioEvent > getFirstEvent() override
Get the &quot;first&quot; event if there is one.It&#39;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: EvioReaderV6.cpp:121
This class is copied from one of the same name in the Java programming language.
Definition: ByteBuffer.h:42
std::shared_ptr< IBlockHeader > getFirstBlockHeader() override
This returns the FIRST block (record) header.the first block (record) header.
Definition: EvioReaderV6.cpp:160
size_t fileSize() override
Get the size of the file being read, in bytes.the file size in bytes
Definition: EvioReaderV6.cpp:156
bool hasFirstEvent() override
Does this evio file have an associated first event? It&#39;s also called the Beginning-Of-Run event...
Definition: EvioReaderV6.cpp:144
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: EvioReaderV6.cpp:148
uint32_t getEvioVersion() override
Get the evio version number.evio version number.
Definition: EvioReaderV6.cpp:95
std::shared_ptr< IBlockHeader > getCurrentBlockHeader() override
This returns the current (active) block (physical record) header.Since most users have no interest in...
Definition: EvioReaderV6.cpp:290
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
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: EvioReaderV6.cpp:152
This pure, virtual class is meant to encapsulate the operation of reading both 2 differently formatte...
Definition: IEvioReader.h:39
std::string getPath() override
Get the path to the file.path to the file
Definition: EvioReaderV6.cpp:99
std::string getDictionaryXML() override
Get the XML format dictionary if there is one.XML format dictionary, else null.
Definition: EvioReaderV6.cpp:115
EvioReaderV6(std::string const &path, bool checkRecNumSeq=false, bool synced=false)
Constructor for reading an event file.
Definition: EvioReaderV6.cpp:32
bool checkBlockNumberSequence() override
Is this reader checking the block number sequence and throwing an exception if it&#39;s not sequential an...
Definition: EvioReaderV6.cpp:87
This class is used to read an evio version 6 format file or buffer.
Definition: EvioReaderV6.h:52
void setParser(std::shared_ptr< EventParser > &evParser) override
Set the file/buffer parser.file/buffer parser.
Definition: EvioReaderV6.cpp:107
ByteOrder & getByteOrder() override
Get the byte order of the file/buffer being read.byte order of the file/buffer being read...
Definition: EvioReaderV6.cpp:91
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: EvioReaderV6.cpp:322
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: EvioReaderV6.cpp:187
bool isClosed() override
Has close() been called (without reopening by calling setBuffer(std::shared_ptr&lt;ByteBuffer&gt; &amp;))...
Definition: EvioReaderV6.cpp:83
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: EvioReaderV6.cpp:176
void close() override
This is closes the file, but for buffers it only sets the position to 0.
Definition: EvioReaderV6.cpp:275
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: EvioReaderV6.cpp:335
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&#39;s/eve...
Definition: EvioReaderV6.cpp:244
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: EvioReaderV6.cpp:224
bool hasDictionaryXML() override
Does this evio file have an associated XML dictionary?true if this evio file has an associated XML di...
Definition: EvioReaderV6.cpp:118
std::shared_ptr< EvioEvent > gotoEventNumber(size_t evNumber) override
In this version, this method is a wrapper on parseEvent(size_t).
Definition: EvioReaderV6.cpp:303
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: EvioReaderV6.cpp:68
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: EvioReaderV6.cpp:203
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: EvioReaderV6.cpp:164
void rewind() override
This method is not relevant in evio 6 and does nothing.
Definition: EvioReaderV6.cpp:261
ssize_t position() override
This method is not relevant in evio 6, does nothing, and returns 0.
Definition: EvioReaderV6.cpp:268