evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::EvioCompactReaderV4 Class Reference

This class is used to read an evio format version 4 formatted file or buffer and extract specific evio containers (bank, seg, or tagseg) with actual data in them given a tag/num pair. More...

#include <EvioCompactReaderV4.h>

Public Member Functions

 EvioCompactReaderV4 (std::string const &path)
 Constructor for reading an event file. More...
 
 EvioCompactReaderV4 (std::shared_ptr< ByteBuffer > &byteBuffer)
 Constructor for reading a buffer. More...
 
void setBuffer (std::shared_ptr< ByteBuffer > &buf) override
 This method can be used to avoid creating additional EvioCompactReader objects by reusing this one with another buffer.The method close() should be called before calling this.
Parameters
bufByteBuffer to be read
Exceptions
EvioExceptionif arg is null; if failure to read first block header; if buffer not in evio format.
More...
 
bool isFile () override
 Is this reader reading a file?
Returns
true if reading file, false if reading buffer
More...
 
bool isCompressed () override
 Is the data in the file/buffer compressed?
Returns
true if data is compressed.
More...
 
bool isClosed () override
 Has close() been called (without reopening by calling setBuffer(std::shared_ptr<ByteBuffer> &))?
Returns
true
if this object closed, else
false
.
More...
 
ByteOrder getByteOrder () override
 Get the byte order of the file/buffer being read.
Returns
byte order of the file/buffer being read.
More...
 
uint32_t getEvioVersion () override
 Get the evio version number.
Returns
evio version number.
More...
 
std::string getPath () override
 Get the path to the file.
Returns
path to the file
More...
 
ByteOrder getFileByteOrder () override
 When reading a file, this method's return value is the byte order of the evio data in the file.
Returns
byte order of the evio data in the file.
More...
 
std::string getDictionaryXML () override
 Get the XML format dictionary is there is one.
Exceptions
EvioExceptionif object closed and dictionary still unread
Returns
XML format dictionary, else null.
More...
 
std::shared_ptr
< EvioXMLDictionary
getDictionary () override
 Get the evio dictionary if is there is one.
Exceptions
EvioExceptionif object closed and dictionary still unread
Returns
evio dictionary if exists, else null.
More...
 
bool hasDictionary () override
 Does this evio file have an associated XML dictionary?
Returns
true if this evio file has an associated XML dictionary, else false
More...
 
std::shared_ptr< ByteBuffergetByteBuffer () override
 Get the byte buffer being read directly or corresponding to the event file.
Returns
the byte buffer being read directly or corresponding to the event file.
More...
 
size_t fileSize () override
 Get the size of the file being read, in bytes.For small files, obtain the file size using the memory mapped buffer's capacity.

Returns
the file size in bytes
More...
 
std::shared_ptr< EvioNodegetEvent (size_t eventNumber) override
 Get the EvioNode object associated with a particular event number.
Parameters
eventNumbernumber of event (place in file/buffer) starting at 1.
Returns
EvioNode object associated with a particular event number, or null if there is none.
More...
 
std::shared_ptr< EvioNodegetScannedEvent (size_t eventNumber) override
 Get the EvioNode object associated with a particular event number which has been scanned so all substructures are contained in the node.allNodes list.
Parameters
eventNumbernumber of event (place in file/buffer) starting at 1.
Returns
EvioNode object associated with a particular event number, or null if there is none.
More...
 
std::shared_ptr< IBlockHeadergetFirstBlockHeader () override
 This returns the FIRST block (or record) header.(Not the file header of evio version 6+ files).

Returns
the first block header.
More...
 
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 which contain information about a single evio structure which matches the given tag and num.
Parameters
eventNumberplace of event in buffer (starting with 1)
tagtag to match.
numnum to match.
vecvector to be filled with matching evio structures (empty if none found).
Exceptions
EvioExceptionif bad arg value(s); if object closed
More...
 
void searchEvent (size_t eventNumber, std::string const &dictName, std::shared_ptr< EvioXMLDictionary > &dictionary, 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 which contain information about a single evio structure which matches the given dictionary entry name.
Parameters
eventNumberplace of event in buffer (starting with 1)
dictNamename of dictionary entry to search for
dictionarydictionary to use; if null, use dictionary with file/buffer
vecvector to be filled with matching evio structures (empty if none found).
Exceptions
EvioExceptionif dictName is null; if dictName is an invalid dictionary entry; if dictionary is null and none provided in file/buffer being read; if object closed
More...
 
std::shared_ptr< ByteBufferremoveEvent (size_t eventNumber) override
 This method removes the data of the given event from the buffer.It also marks any existing EvioNodes representing the event and its descendants as obsolete. They must not be used anymore.If the constructor of this reader read in data from a file, it will now switch to using a new, internal buffer which is returned by this method or can be retrieved by calling getByteBuffer(). It will not change the file originally used. A new file can be created by calling either the toFile(std::string const &) method.
Parameters
eventNumbernumber of event to remove from buffer
Returns
new ByteBuffer created and updated to reflect the event removal
Exceptions
EvioExceptionif evNumber < 1; if event number does not correspond to existing event; if object closed; if node was not found in any event; if internal programming error
More...
 
std::shared_ptr< ByteBufferremoveStructure (std::shared_ptr< EvioNode > &removeNode) override
 This method removes the data, represented by the given node, from the buffer.It also marks the node and its descendants as obsolete. They must not be used anymore.If the constructor of this reader read in data from a file, it will now switch to using a new, internal buffer which is returned by this method or can be retrieved by calling getByteBuffer(). It will not change the file originally used. A new file can be created by calling either the toFile(std::string const &) method.
Parameters
removeNodeevio structure to remove from buffer
Returns
new ByteBuffer (perhaps created) and updated to reflect the node removal
Exceptions
EvioExceptionif object closed; if node was not found in any event; if internal programming error
More...
 
std::shared_ptr< ByteBufferaddStructure (size_t eventNumber, ByteBuffer &addBuffer) override
 This method adds an evio container (bank, segment, or tag segment) as the last structure contained in an event.It is the responsibility of the caller to make sure that the buffer argument contains valid evio data (only data representing the structure to be added - not in file format with block header and the like) which is compatible with the type of data stored in the given event.To produce such evio data use EvioBank#write(ByteBuffer &), EvioSegment#write(ByteBuffer &) or EvioTagSegment#write(ByteBuffer &) depending on whether a bank, seg, or tagseg is being added.A note about files here. If the constructor of this reader read in data from a file, it will now switch to using a new, internal buffer which is returned by this method or can be retrieved by calling getByteBuffer(). It will not expand the file originally used. A new file can be created by calling either the toFile(std::string const &) method.The given buffer argument must be ready to read with its position and limit defining the limits of the data to copy. This method is synchronized due to the bulk, relative puts.
Parameters
eventNumbernumber of event to which addBuffer is to be added
addBufferbuffer containing evio data to add (not evio file format, i.e. no block headers)
Returns
a new ByteBuffer object which is created and filled with all the data including what was just added.
Exceptions
EvioExceptionif evNumber < 1; if addBuffer is null; if addBuffer arg is empty or has non-evio format; if addBuffer is opposite endian to current event buffer; if added data is not the proper length (i.e. multiple of 4 bytes); if the event number does not correspond to an existing event; if there is an internal programming error; if object closed
More...
 
std::shared_ptr< ByteBuffergetData (std::shared_ptr< EvioNode > &node) override
 Get the data associated with an evio structure in ByteBuffer form.The returned buffer is a view into this reader's buffer (no copy done). Changes in one will affect the other.
Parameters
nodeevio structure whose data is to be retrieved
Exceptions
EvioExceptionif object closed or node arg is null.
Returns
ByteBuffer filled with data.
More...
 
std::shared_ptr< ByteBuffergetData (std::shared_ptr< EvioNode > &node, bool copy) override
 Get the data associated with an evio structure in ByteBuffer form.Depending on the copy argument, the given/returned buffer will either be a copy of or a view into the data of this reader's buffer.This method is synchronized due to the bulk, relative gets & puts.
Parameters
nodeevio structure whose data is to be retrieved
copyif true, then return a copy as opposed to a view into this reader object's buffer.
Exceptions
EvioExceptionif object closed
Returns
ByteBuffer filled with data.
More...
 
std::shared_ptr< ByteBuffergetData (std::shared_ptr< EvioNode > &node, std::shared_ptr< ByteBuffer > &buf) override
 Get the data associated with an evio structure in ByteBuffer form.The returned buffer is a view into this reader's buffer (no copy done). Changes in one will affect the other.
Parameters
nodeevio structure whose data is to be retrieved
bufuser-supplied ByteBuffer to be filled with data.
Exceptions
EvioExceptionif object closed or node arg is null.
Returns
buf arg.
More...
 
std::shared_ptr< ByteBuffergetData (std::shared_ptr< EvioNode > &node, std::shared_ptr< ByteBuffer > &buf, bool copy) override
 Get the data associated with an evio structure in ByteBuffer form.Depending on the copy argument, the given/returned buffer will either be a copy of or a view into the data of this reader's buffer.This method is synchronized due to the bulk, relative gets & puts.
Parameters
nodeevio structure whose data is to be retrieved
bufuser-supplied ByteBuffer to be filled with data.
copyif true, then return a copy as opposed to a view into this reader object's buffer.
Exceptions
EvioExceptionif object closed
Returns
buf arg.
More...
 
std::shared_ptr< ByteBuffergetEventBuffer (size_t eventNumber) override
 Get an evio bank or event in ByteBuffer form.The returned buffer is a view into the data of this reader's buffer.
Parameters
eventNumbernumber of event of interest
Returns
ByteBuffer object containing bank's/event's bytes. Position and limit are set for reading.
Exceptions
EvioExceptionif evNumber < 1; if the event number does not correspond to an existing event; if object closed
More...
 
std::shared_ptr< ByteBuffergetEventBuffer (size_t eventNumber, bool copy) override
 Get an evio bank or event in ByteBuffer form.Depending on the copy argument, the returned buffer will either be a copy of or a view into the data of this reader's buffer.
Parameters
eventNumbernumber of event of interest
copyif true, then return a copy as opposed to a view into this reader object's buffer.
Returns
ByteBuffer object containing bank's/event's bytes. Position and limit are set for reading.
Exceptions
EvioExceptionif evNumber < 1; if the event number does not correspond to an existing event; if object closed
More...
 
std::shared_ptr< ByteBuffergetStructureBuffer (std::shared_ptr< EvioNode > &node) override
 Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.The returned buffer is a view into the data of this reader's buffer.
Parameters
nodenode object representing evio structure of interest
Returns
ByteBuffer object containing bank's/event's bytes. Position and limit are set for reading.
Exceptions
EvioExceptionif node is null; if object closed
More...
 
std::shared_ptr< ByteBuffergetStructureBuffer (std::shared_ptr< EvioNode > &node, bool copy) override
 Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.Depending on the copy argument, the returned buffer will either be a copy of or a view into the data of this reader's buffer.
Parameters
nodenode object representing evio structure of interest
copyif true, then return a copy as opposed to a view into this reader object's buffer.
Returns
ByteBuffer object containing structure's bytes. Position and limit are set for reading.
Exceptions
EvioExceptionif node is null; if object closed
More...
 
void close () override
 This only sets the position to its initial value. More...
 
uint32_t getEventCount () override
 This is the number of events in the file/buffer.Any dictionary event is not included in the count. In versions 3 and earlier, it is not computed unless asked for, and if asked for it is computed and cached.
Returns
the number of events in the file/buffer.
More...
 
uint32_t getBlockCount () override
 This is the number of blocks in the file/buffer including the empty block at the end.
Returns
the number of blocks in the file/buffer (estimate for version 3 files)
More...
 
void toFile (std::string const &fileName) override
 Save the internal byte buffer to the given file (overwrites existing file).
Parameters
fileNamename of file to write
Exceptions
IOExceptionif error writing to file
EvioExceptionif fileName arg is null; if object closed
More...
 

Static Public Attributes

static const int BLOCK_SIZE_OFFSET = 0
 Offset to get block size from start of block. More...
 
static const int BLOCK_NUMBER = 4
 Offset to get block number from start of block. More...
 
static const int BLOCK_HEADER_SIZE_OFFSET = 8
 Offset to get block header size from start of block. More...
 
static const int BLOCK_EVENT_COUNT = 12
 Offset to get block event count from start of block. More...
 
static const int BLOCK_RESERVED_1 = 16
 Offset to get block size from start of block. More...
 
static const int VERSION_MASK = 0xff
 Mask to get version number from 6th int in block. More...
 

Detailed Description

This class is used to read an evio format version 4 formatted file or buffer and extract specific evio containers (bank, seg, or tagseg) with actual data in them given a tag/num pair.

Date
07/01/2020
Author
timmer

Constructor & Destructor Documentation

evio::EvioCompactReaderV4::EvioCompactReaderV4 ( std::string const &  path)
explicit

Constructor for reading an event file.

Parameters
paththe full path to the file that contains events. For writing event files, use an EventWriter object.
See Also
EventWriter
Exceptions
EvioExceptionif read failure, if path arg is empty

Object for reading file.

evio::EvioCompactReaderV4::EvioCompactReaderV4 ( std::shared_ptr< ByteBuffer > &  byteBuffer)
explicit

Constructor for reading a buffer.

Parameters
byteBufferthe buffer that contains events.
See Also
EventWriter
Exceptions
EvioExceptionif buffer arg is null; failure to read first block header

Member Function Documentation

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::addStructure ( size_t  eventNumber,
ByteBuffer addBuffer 
)
overridevirtual

This method adds an evio container (bank, segment, or tag segment) as the last structure contained in an event.It is the responsibility of the caller to make sure that the buffer argument contains valid evio data (only data representing the structure to be added - not in file format with block header and the like) which is compatible with the type of data stored in the given event.To produce such evio data use EvioBank#write(ByteBuffer &), EvioSegment#write(ByteBuffer &) or EvioTagSegment#write(ByteBuffer &) depending on whether a bank, seg, or tagseg is being added.A note about files here. If the constructor of this reader read in data from a file, it will now switch to using a new, internal buffer which is returned by this method or can be retrieved by calling getByteBuffer(). It will not expand the file originally used. A new file can be created by calling either the toFile(std::string const &) method.The given buffer argument must be ready to read with its position and limit defining the limits of the data to copy. This method is synchronized due to the bulk, relative puts.

Parameters
eventNumbernumber of event to which addBuffer is to be added
addBufferbuffer containing evio data to add (not evio file format, i.e. no block headers)
Returns
a new ByteBuffer object which is created and filled with all the data including what was just added.
Exceptions
EvioExceptionif evNumber < 1; if addBuffer is null; if addBuffer arg is empty or has non-evio format; if addBuffer is opposite endian to current event buffer; if added data is not the proper length (i.e. multiple of 4 bytes); if the event number does not correspond to an existing event; if there is an internal programming error; if object closed

Implements evio::IEvioCompactReader.

References evio::DataType::ALSOBANK, evio::DataType::ALSOSEGMENT, evio::DataType::BANK, evio::ByteOrder::ENDIAN_BIG, evio::EvioNode::extractNode(), evio::ByteBuffer::order(), evio::ByteBuffer::position(), evio::ByteBuffer::remaining(), evio::EvioNode::scanStructure(), evio::DataType::SEGMENT, and evio::DataType::TAGSEGMENT.

void evio::EvioCompactReaderV4::close ( )
overridevirtual

This only sets the position to its initial value.

Implements evio::IEvioCompactReader.

size_t evio::EvioCompactReaderV4::fileSize ( )
overridevirtual

Get the size of the file being read, in bytes.For small files, obtain the file size using the memory mapped buffer's capacity.

Returns
the file size in bytes

Implements evio::IEvioCompactReader.

uint32_t evio::EvioCompactReaderV4::getBlockCount ( )
overridevirtual

This is the number of blocks in the file/buffer including the empty block at the end.

Returns
the number of blocks in the file/buffer (estimate for version 3 files)

Implements evio::IEvioCompactReader.

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getByteBuffer ( )
overridevirtual

Get the byte buffer being read directly or corresponding to the event file.

Returns
the byte buffer being read directly or corresponding to the event file.

Implements evio::IEvioCompactReader.

ByteOrder evio::EvioCompactReaderV4::getByteOrder ( )
overridevirtual

Get the byte order of the file/buffer being read.

Returns
byte order of the file/buffer being read.

Implements evio::IEvioCompactReader.

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getData ( std::shared_ptr< EvioNode > &  node)
overridevirtual

Get the data associated with an evio structure in ByteBuffer form.The returned buffer is a view into this reader's buffer (no copy done). Changes in one will affect the other.

Parameters
nodeevio structure whose data is to be retrieved
Exceptions
EvioExceptionif object closed or node arg is null.
Returns
ByteBuffer filled with data.

Implements evio::IEvioCompactReader.

Referenced by getData().

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getData ( std::shared_ptr< EvioNode > &  node,
bool  copy 
)
overridevirtual

Get the data associated with an evio structure in ByteBuffer form.Depending on the copy argument, the given/returned buffer will either be a copy of or a view into the data of this reader's buffer.This method is synchronized due to the bulk, relative gets & puts.

Parameters
nodeevio structure whose data is to be retrieved
copyif true, then return a copy as opposed to a view into this reader object's buffer.
Exceptions
EvioExceptionif object closed
Returns
ByteBuffer filled with data.

Implements evio::IEvioCompactReader.

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getData ( std::shared_ptr< EvioNode > &  node,
std::shared_ptr< ByteBuffer > &  buf 
)
overridevirtual

Get the data associated with an evio structure in ByteBuffer form.The returned buffer is a view into this reader's buffer (no copy done). Changes in one will affect the other.

Parameters
nodeevio structure whose data is to be retrieved
bufuser-supplied ByteBuffer to be filled with data.
Exceptions
EvioExceptionif object closed or node arg is null.
Returns
buf arg.

Implements evio::IEvioCompactReader.

References getData().

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getData ( std::shared_ptr< EvioNode > &  node,
std::shared_ptr< ByteBuffer > &  buf,
bool  copy 
)
overridevirtual

Get the data associated with an evio structure in ByteBuffer form.Depending on the copy argument, the given/returned buffer will either be a copy of or a view into the data of this reader's buffer.This method is synchronized due to the bulk, relative gets & puts.

Parameters
nodeevio structure whose data is to be retrieved
bufuser-supplied ByteBuffer to be filled with data.
copyif true, then return a copy as opposed to a view into this reader object's buffer.
Exceptions
EvioExceptionif object closed
Returns
buf arg.

Implements evio::IEvioCompactReader.

std::shared_ptr< EvioXMLDictionary > evio::EvioCompactReaderV4::getDictionary ( )
overridevirtual

Get the evio dictionary if is there is one.

Exceptions
EvioExceptionif object closed and dictionary still unread
Returns
evio dictionary if exists, else null.

Implements evio::IEvioCompactReader.

Referenced by searchEvent().

std::string evio::EvioCompactReaderV4::getDictionaryXML ( )
overridevirtual

Get the XML format dictionary is there is one.

Exceptions
EvioExceptionif object closed and dictionary still unread
Returns
XML format dictionary, else null.

Implements evio::IEvioCompactReader.

std::shared_ptr< EvioNode > evio::EvioCompactReaderV4::getEvent ( size_t  eventNumber)
overridevirtual

Get the EvioNode object associated with a particular event number.

Parameters
eventNumbernumber of event (place in file/buffer) starting at 1.
Returns
EvioNode object associated with a particular event number, or null if there is none.

Implements evio::IEvioCompactReader.

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getEventBuffer ( size_t  eventNumber)
overridevirtual

Get an evio bank or event in ByteBuffer form.The returned buffer is a view into the data of this reader's buffer.

Parameters
eventNumbernumber of event of interest
Returns
ByteBuffer object containing bank's/event's bytes. Position and limit are set for reading.
Exceptions
EvioExceptionif evNumber < 1; if the event number does not correspond to an existing event; if object closed

Implements evio::IEvioCompactReader.

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getEventBuffer ( size_t  eventNumber,
bool  copy 
)
overridevirtual

Get an evio bank or event in ByteBuffer form.Depending on the copy argument, the returned buffer will either be a copy of or a view into the data of this reader's buffer.

Parameters
eventNumbernumber of event of interest
copyif true, then return a copy as opposed to a view into this reader object's buffer.
Returns
ByteBuffer object containing bank's/event's bytes. Position and limit are set for reading.
Exceptions
EvioExceptionif evNumber < 1; if the event number does not correspond to an existing event; if object closed

Implements evio::IEvioCompactReader.

uint32_t evio::EvioCompactReaderV4::getEventCount ( )
overridevirtual

This is the number of events in the file/buffer.Any dictionary event is not included in the count. In versions 3 and earlier, it is not computed unless asked for, and if asked for it is computed and cached.

Returns
the number of events in the file/buffer.

Implements evio::IEvioCompactReader.

uint32_t evio::EvioCompactReaderV4::getEvioVersion ( )
overridevirtual

Get the evio version number.

Returns
evio version number.

Implements evio::IEvioCompactReader.

ByteOrder evio::EvioCompactReaderV4::getFileByteOrder ( )
overridevirtual

When reading a file, this method's return value is the byte order of the evio data in the file.

Returns
byte order of the evio data in the file.

Implements evio::IEvioCompactReader.

std::shared_ptr< IBlockHeader > evio::EvioCompactReaderV4::getFirstBlockHeader ( )
overridevirtual

This returns the FIRST block (or record) header.(Not the file header of evio version 6+ files).

Returns
the first block header.

Implements evio::IEvioCompactReader.

std::string evio::EvioCompactReaderV4::getPath ( )
overridevirtual

Get the path to the file.

Returns
path to the file

Implements evio::IEvioCompactReader.

std::shared_ptr< EvioNode > evio::EvioCompactReaderV4::getScannedEvent ( size_t  eventNumber)
overridevirtual

Get the EvioNode object associated with a particular event number which has been scanned so all substructures are contained in the node.allNodes list.

Parameters
eventNumbernumber of event (place in file/buffer) starting at 1.
Returns
EvioNode object associated with a particular event number, or null if there is none.

Implements evio::IEvioCompactReader.

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getStructureBuffer ( std::shared_ptr< EvioNode > &  node)
overridevirtual

Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.The returned buffer is a view into the data of this reader's buffer.

Parameters
nodenode object representing evio structure of interest
Returns
ByteBuffer object containing bank's/event's bytes. Position and limit are set for reading.
Exceptions
EvioExceptionif node is null; if object closed

Implements evio::IEvioCompactReader.

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::getStructureBuffer ( std::shared_ptr< EvioNode > &  node,
bool  copy 
)
overridevirtual

Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.Depending on the copy argument, the returned buffer will either be a copy of or a view into the data of this reader's buffer.

Parameters
nodenode object representing evio structure of interest
copyif true, then return a copy as opposed to a view into this reader object's buffer.
Returns
ByteBuffer object containing structure's bytes. Position and limit are set for reading.
Exceptions
EvioExceptionif node is null; if object closed

Implements evio::IEvioCompactReader.

bool evio::EvioCompactReaderV4::hasDictionary ( )
overridevirtual

Does this evio file have an associated XML dictionary?

Returns
true if this evio file has an associated XML dictionary, else false

Implements evio::IEvioCompactReader.

Referenced by searchEvent().

bool evio::EvioCompactReaderV4::isClosed ( )
overridevirtual

Has close() been called (without reopening by calling setBuffer(std::shared_ptr<ByteBuffer> &))?

Returns
true
if this object closed, else
false
.

Implements evio::IEvioCompactReader.

bool evio::EvioCompactReaderV4::isCompressed ( )
overridevirtual

Is the data in the file/buffer compressed?

Returns
true if data is compressed.

Implements evio::IEvioCompactReader.

bool evio::EvioCompactReaderV4::isFile ( )
overridevirtual

Is this reader reading a file?

Returns
true if reading file, false if reading buffer

Implements evio::IEvioCompactReader.

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::removeEvent ( size_t  eventNumber)
overridevirtual

This method removes the data of the given event from the buffer.It also marks any existing EvioNodes representing the event and its descendants as obsolete. They must not be used anymore.If the constructor of this reader read in data from a file, it will now switch to using a new, internal buffer which is returned by this method or can be retrieved by calling getByteBuffer(). It will not change the file originally used. A new file can be created by calling either the toFile(std::string const &) method.

Parameters
eventNumbernumber of event to remove from buffer
Returns
new ByteBuffer created and updated to reflect the event removal
Exceptions
EvioExceptionif evNumber < 1; if event number does not correspond to existing event; if object closed; if node was not found in any event; if internal programming error

Implements evio::IEvioCompactReader.

References removeStructure().

std::shared_ptr< ByteBuffer > evio::EvioCompactReaderV4::removeStructure ( std::shared_ptr< EvioNode > &  removeNode)
overridevirtual

This method removes the data, represented by the given node, from the buffer.It also marks the node and its descendants as obsolete. They must not be used anymore.If the constructor of this reader read in data from a file, it will now switch to using a new, internal buffer which is returned by this method or can be retrieved by calling getByteBuffer(). It will not change the file originally used. A new file can be created by calling either the toFile(std::string const &) method.

Parameters
removeNodeevio structure to remove from buffer
Returns
new ByteBuffer (perhaps created) and updated to reflect the node removal
Exceptions
EvioExceptionif object closed; if node was not found in any event; if internal programming error

Implements evio::IEvioCompactReader.

References evio::DataType::ALSOBANK, evio::DataType::ALSOSEGMENT, evio::DataType::BANK, evio::ByteOrder::ENDIAN_BIG, evio::DataType::SEGMENT, and evio::DataType::TAGSEGMENT.

Referenced by removeEvent().

void evio::EvioCompactReaderV4::searchEvent ( size_t  eventNumber,
uint16_t  tag,
uint8_t  num,
std::vector< std::shared_ptr< EvioNode >> &  vec 
)
overridevirtual

This method searches the specified event in a file/buffer and returns a vector of objects each of which contain information about a single evio structure which matches the given tag and num.

Parameters
eventNumberplace of event in buffer (starting with 1)
tagtag to match.
numnum to match.
vecvector to be filled with matching evio structures (empty if none found).
Exceptions
EvioExceptionif bad arg value(s); if object closed

Implements evio::IEvioCompactReader.

Referenced by searchEvent().

void evio::EvioCompactReaderV4::searchEvent ( size_t  eventNumber,
std::string const &  dictName,
std::shared_ptr< EvioXMLDictionary > &  dictionary,
std::vector< std::shared_ptr< EvioNode >> &  vec 
)
overridevirtual

This method searches the specified event in a file/buffer and returns a vector of objects each of which contain information about a single evio structure which matches the given dictionary entry name.

Parameters
eventNumberplace of event in buffer (starting with 1)
dictNamename of dictionary entry to search for
dictionarydictionary to use; if null, use dictionary with file/buffer
vecvector to be filled with matching evio structures (empty if none found).
Exceptions
EvioExceptionif dictName is null; if dictName is an invalid dictionary entry; if dictionary is null and none provided in file/buffer being read; if object closed

Implements evio::IEvioCompactReader.

References getDictionary(), hasDictionary(), and searchEvent().

void evio::EvioCompactReaderV4::setBuffer ( std::shared_ptr< ByteBuffer > &  buf)
overridevirtual

This method can be used to avoid creating additional EvioCompactReader objects by reusing this one with another buffer.The method close() should be called before calling this.

Parameters
bufByteBuffer to be read
Exceptions
EvioExceptionif arg is null; if failure to read first block header; if buffer not in evio format.

Implements evio::IEvioCompactReader.

void evio::EvioCompactReaderV4::toFile ( std::string const &  fileName)
overridevirtual

Save the internal byte buffer to the given file (overwrites existing file).

Parameters
fileNamename of file to write
Exceptions
IOExceptionif error writing to file
EvioExceptionif fileName arg is null; if object closed

Implements evio::IEvioCompactReader.

Member Data Documentation

const int evio::EvioCompactReaderV4::BLOCK_EVENT_COUNT = 12
static

Offset to get block event count from start of block.

const int evio::EvioCompactReaderV4::BLOCK_HEADER_SIZE_OFFSET = 8
static

Offset to get block header size from start of block.

const int evio::EvioCompactReaderV4::BLOCK_NUMBER = 4
static

Offset to get block number from start of block.

const int evio::EvioCompactReaderV4::BLOCK_RESERVED_1 = 16
static

Offset to get block size from start of block.

const int evio::EvioCompactReaderV4::BLOCK_SIZE_OFFSET = 0
static

Offset to get block size from start of block.

const int evio::EvioCompactReaderV4::VERSION_MASK = 0xff
static

Mask to get version number from 6th int in block.


The documentation for this class was generated from the following files: