12 #ifndef EVIO_6_0_EVIOCOMPACTREADERV4_H
13 #define EVIO_6_0_EVIOCOMPACTREADERV4_H
79 std::vector<std::shared_ptr<EvioNode>> eventNodes;
82 std::unordered_map<uint32_t, std::shared_ptr<RecordNode>> blockNodes;
88 int32_t eventCount = -1;
91 uint32_t evioVersion = 4;
101 int32_t blockCount = -1;
104 uint32_t firstBlockHeaderWords = 0;
107 std::shared_ptr<BlockHeaderV4> blockHeader;
110 bool hasDict =
false;
116 std::string dictionaryXML;
119 std::shared_ptr<EvioXMLDictionary> dictionary =
nullptr;
122 std::shared_ptr<ByteBuffer> byteBuffer =
nullptr;
125 size_t initialPosition = 0;
129 size_t validDataWords = 0;
139 bool readingFile =
false;
145 std::string path =
"";
148 size_t fileBytes = 0;
155 void setBuffer(std::shared_ptr<ByteBuffer> & buf)
override ;
162 std::string
getPath()
override ;
165 std::shared_ptr<EvioXMLDictionary>
getDictionary()
override ;
170 void mapFile(std::string
const & filename,
size_t fileS);
171 void generateEventPositionTable();
178 std::shared_ptr<EvioNode>
getEvent(
size_t eventNumber)
override ;
179 std::shared_ptr<EvioNode>
getScannedEvent(
size_t eventNumber)
override ;
186 void readDictionary();
187 std::shared_ptr<EvioNode> scanStructure(
size_t eventNumber);
191 void searchEvent(
size_t eventNumber, uint16_t tag, uint8_t num,
192 std::vector<std::shared_ptr<EvioNode>> & vec)
override ;
193 void searchEvent(
size_t eventNumber, std::string
const & dictName,
194 std::shared_ptr<EvioXMLDictionary> & dictionary,
195 std::vector<std::shared_ptr<EvioNode>> & vec)
override ;
198 std::shared_ptr<ByteBuffer>
removeEvent(
size_t eventNumber)
override ;
200 std::shared_ptr<ByteBuffer>
removeStructure(std::shared_ptr<EvioNode> & removeNode)
override ;
203 std::shared_ptr<ByteBuffer>
getData(std::shared_ptr<EvioNode> & node)
override ;
204 std::shared_ptr<ByteBuffer>
getData(std::shared_ptr<EvioNode> & node,
bool copy)
override ;
206 std::shared_ptr<ByteBuffer>
getData(std::shared_ptr<EvioNode> & node,
207 std::shared_ptr<ByteBuffer> & buf)
override ;
208 std::shared_ptr<ByteBuffer>
getData(std::shared_ptr<EvioNode> & node,
209 std::shared_ptr<ByteBuffer> & buf,
bool copy)
override ;
211 std::shared_ptr<ByteBuffer>
getEventBuffer(
size_t eventNumber)
override ;
212 std::shared_ptr<ByteBuffer>
getEventBuffer(
size_t eventNumber,
bool copy)
override ;
214 std::shared_ptr<ByteBuffer>
getStructureBuffer(std::shared_ptr<EvioNode> & node)
override ;
215 std::shared_ptr<ByteBuffer>
getStructureBuffer(std::shared_ptr<EvioNode> & node,
bool copy)
override ;
217 void close()
override ;
222 void toFile(std::string
const & fileName)
override ;
227 #endif //EVIO_6_0_EVIOCOMPACTREADERV4_H
static const int BLOCK_SIZE_OFFSET
Offset to get block size from start of block.
Definition: EvioCompactReaderV4.h:59
This class is copied from one of the same name in the Java programming language.
Definition: ByteBuffer.h:42
uint32_t getEvioVersion() override
Get the evio version number.evio version number.
Definition: EvioCompactReaderV4.cpp:137
static const int BLOCK_EVENT_COUNT
Offset to get block event count from start of block.
Definition: EvioCompactReaderV4.h:68
uint32_t getBlockCount() override
This is the number of blocks in the file/buffer including the empty block at the end.the number of blocks in the file/buffer (estimate for version 3 files)
Definition: EvioCompactReaderV4.cpp:1191
std::shared_ptr< EvioNode > getScannedEvent(size_t eventNumber) override
Get the EvioNode object associated with a particular event number which has been scanned so all subst...
Definition: EvioCompactReaderV4.cpp:253
bool isClosed() override
Has close() been called (without reopening by calling setBuffer(std::shared_ptr<ByteBuffer> &))...
Definition: EvioCompactReaderV4.cpp:129
ReadWriteStatus
This enum denotes the status of a read/write.
Definition: IEvioReader.h:54
std::shared_ptr< ByteBuffer > getData(std::shared_ptr< EvioNode > &node) override
Get the data associated with an evio structure in ByteBuffer form.The returned buffer is a view into ...
Definition: EvioCompactReaderV4.cpp:1108
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
static const int BLOCK_RESERVED_1
Offset to get block size from start of block.
Definition: EvioCompactReaderV4.h:71
bool hasDictionary() override
Does this evio file have an associated XML dictionary?true if this evio file has an associated XML di...
Definition: EvioCompactReaderV4.cpp:193
std::shared_ptr< EvioNode > getEvent(size_t eventNumber) override
Get the EvioNode object associated with a particular event number.number of event (place in file/buff...
Definition: EvioCompactReaderV4.cpp:243
std::shared_ptr< ByteBuffer > removeEvent(size_t eventNumber) override
This method removes the data of the given event from the buffer.It also marks any existing EvioNodes ...
Definition: EvioCompactReaderV4.cpp:655
static const int VERSION_MASK
Mask to get version number from 6th int in block.
Definition: EvioCompactReaderV4.h:74
std::shared_ptr< IBlockHeader > getFirstBlockHeader() override
This returns the FIRST block (or record) header.(Not the file header of evio version 6+ files)...
Definition: EvioCompactReaderV4.cpp:504
This class is used to read an evio format version 4 formatted file or buffer and extract specific evi...
Definition: EvioCompactReaderV4.h:54
std::shared_ptr< ByteBuffer > removeStructure(std::shared_ptr< EvioNode > &removeNode) override
This method removes the data, represented by the given node, from the buffer.It also marks the node a...
Definition: EvioCompactReaderV4.cpp:674
bool isFile() override
Is this reader reading a file?true if reading file, false if reading buffer
Definition: EvioCompactReaderV4.cpp:121
void setBuffer(std::shared_ptr< ByteBuffer > &buf) override
This method can be used to avoid creating additional EvioCompactReader objects by reusing this one wi...
Definition: EvioCompactReaderV4.cpp:97
EvioCompactReaderV4(std::string const &path)
Constructor for reading an event file.
Definition: EvioCompactReaderV4.cpp:26
std::shared_ptr< EvioXMLDictionary > getDictionary() override
Get the evio dictionary if is there is one.if object closed and dictionary still unread evio dictiona...
Definition: EvioCompactReaderV4.cpp:169
std::string getPath() override
Get the path to the file.path to the file
Definition: EvioCompactReaderV4.cpp:141
uint32_t getEventCount() override
This is the number of events in the file/buffer.Any dictionary event is not included in the count...
Definition: EvioCompactReaderV4.cpp:1187
std::string getDictionaryXML() override
Get the XML format dictionary is there is one.if object closed and dictionary still unread XML format...
Definition: EvioCompactReaderV4.cpp:149
std::shared_ptr< ByteBuffer > getByteBuffer() override
Get the byte buffer being read directly or corresponding to the event file.the byte buffer being read...
Definition: EvioCompactReaderV4.cpp:235
std::shared_ptr< ByteBuffer > addStructure(size_t eventNumber, ByteBuffer &addBuffer) override
This method adds an evio container (bank, segment, or tag segment) as the last structure contained in...
Definition: EvioCompactReaderV4.cpp:907
size_t fileSize() override
Get the size of the file being read, in bytes.For small files, obtain the file size using the memory ...
Definition: EvioCompactReaderV4.cpp:239
std::shared_ptr< ByteBuffer > getEventBuffer(size_t eventNumber) override
Get an evio bank or event in ByteBuffer form.The returned buffer is a view into the data of this read...
Definition: EvioCompactReaderV4.cpp:1137
This is an interface for a compact reader of evio format files and buffers.
Definition: IEvioCompactReader.h:41
ByteOrder getByteOrder() override
Get the byte order of the file/buffer being read.byte order of the file/buffer being read...
Definition: EvioCompactReaderV4.cpp:133
std::shared_ptr< ByteBuffer > getStructureBuffer(std::shared_ptr< EvioNode > &node) override
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.The returned buffer is a view into th...
Definition: EvioCompactReaderV4.cpp:1160
void toFile(std::string const &fileName) override
Save the internal byte buffer to the given file (overwrites existing file).name of file to write if e...
Definition: EvioCompactReaderV4.cpp:1195
static const int BLOCK_HEADER_SIZE_OFFSET
Offset to get block header size from start of block.
Definition: EvioCompactReaderV4.h:65
void searchEvent(size_t eventNumber, uint16_t tag, uint8_t num, std::vector< std::shared_ptr< EvioNode >> &vec) override
This method searches the specified event in a file/buffer and returns a vector of objects each of whi...
Definition: EvioCompactReaderV4.cpp:586
static const int BLOCK_NUMBER
Offset to get block number from start of block.
Definition: EvioCompactReaderV4.h:62
ByteOrder getFileByteOrder() override
When reading a file, this method's return value is the byte order of the evio data in the file...
Definition: EvioCompactReaderV4.cpp:145
void close() override
This only sets the position to its initial value.
Definition: EvioCompactReaderV4.cpp:1180
bool isCompressed() override
Is the data in the file/buffer compressed?true if data is compressed.
Definition: EvioCompactReaderV4.cpp:125
static const ByteOrder ENDIAN_LOCAL
Local host's byte order.
Definition: ByteOrder.h:61