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

This is an interface for a compact reader of evio format files and buffers. More...

#include <IEvioCompactReader.h>

Public Member Functions

virtual bool isFile ()=0
 Is this reader reading a file? More...
 
virtual bool isCompressed ()=0
 Is the data in the file/buffer compressed? More...
 
virtual void setBuffer (std::shared_ptr< ByteBuffer > &buf)=0
 This method can be used to avoid creating additional EvioCompactReader objects by reusing this one with another buffer. More...
 
virtual bool isClosed ()=0
 Has close() been called (without reopening by calling setBuffer(std::shared_ptr<ByteBuffer> &))? More...
 
virtual ByteOrder getByteOrder ()=0
 Get the byte order of the file/buffer being read. More...
 
virtual uint32_t getEvioVersion ()=0
 Get the evio version number. More...
 
virtual std::string getPath ()=0
 Get the path to the file. More...
 
virtual ByteOrder getFileByteOrder ()=0
 When reading a file, this method's return value is the byte order of the evio data in the file. More...
 
virtual std::string getDictionaryXML ()=0
 Get the XML format dictionary is there is one. More...
 
virtual std::shared_ptr
< EvioXMLDictionary
getDictionary ()=0
 Get the evio dictionary if is there is one. More...
 
virtual bool hasDictionary ()=0
 Does this evio file have an associated XML dictionary? More...
 
virtual std::shared_ptr
< ByteBuffer
getByteBuffer ()=0
 Get the byte buffer being read directly or corresponding to the event file. More...
 
virtual size_t fileSize ()=0
 Get the size of the file being read, in bytes. More...
 
virtual std::shared_ptr< EvioNodegetEvent (size_t eventNumber)=0
 Get the EvioNode object associated with a particular event number. More...
 
virtual std::shared_ptr< EvioNodegetScannedEvent (size_t eventNumber)=0
 Get the EvioNode object associated with a particular event number which has been scanned so all substructures are contained in the node.allNodes list. More...
 
virtual std::shared_ptr
< IBlockHeader
getFirstBlockHeader ()=0
 This returns the FIRST block (or record) header. More...
 
virtual void searchEvent (size_t eventNumber, uint16_t tag, uint8_t num, std::vector< std::shared_ptr< EvioNode >> &vec)=0
 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. More...
 
virtual void searchEvent (size_t eventNumber, std::string const &dictName, std::shared_ptr< EvioXMLDictionary > &dictionary, std::vector< std::shared_ptr< EvioNode >> &vec)=0
 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. More...
 
virtual std::shared_ptr
< ByteBuffer
removeEvent (size_t eventNumber)=0
 This method removes the data of the given event from the buffer. More...
 
virtual std::shared_ptr
< ByteBuffer
removeStructure (std::shared_ptr< EvioNode > &removeNode)=0
 This method removes the data, represented by the given node, from the buffer. More...
 
virtual std::shared_ptr
< ByteBuffer
addStructure (size_t eventNumber, ByteBuffer &addBuffer)=0
 This method adds an evio container (bank, segment, or tag segment) as the last structure contained in an event. More...
 
virtual std::shared_ptr
< ByteBuffer
getData (std::shared_ptr< EvioNode > &node)=0
 Get the data associated with an evio structure in ByteBuffer form. More...
 
virtual std::shared_ptr
< ByteBuffer
getData (std::shared_ptr< EvioNode > &node, bool copy)=0
 Get the data associated with an evio structure in ByteBuffer form. More...
 
virtual std::shared_ptr
< ByteBuffer
getData (std::shared_ptr< EvioNode > &node, std::shared_ptr< ByteBuffer > &buf)=0
 Get the data associated with an evio structure in ByteBuffer form. More...
 
virtual std::shared_ptr
< ByteBuffer
getData (std::shared_ptr< EvioNode > &node, std::shared_ptr< ByteBuffer > &buf, bool copy)=0
 Get the data associated with an evio structure in ByteBuffer form. More...
 
virtual std::shared_ptr
< ByteBuffer
getEventBuffer (size_t eventNumber)=0
 Get an evio bank or event in ByteBuffer form. More...
 
virtual std::shared_ptr
< ByteBuffer
getEventBuffer (size_t eventNumber, bool copy)=0
 Get an evio bank or event in ByteBuffer form. More...
 
virtual std::shared_ptr
< ByteBuffer
getStructureBuffer (std::shared_ptr< EvioNode > &node)=0
 Get an evio structure (bank, seg, or tagseg) in ByteBuffer form. More...
 
virtual std::shared_ptr
< ByteBuffer
getStructureBuffer (std::shared_ptr< EvioNode > &node, bool copy)=0
 Get an evio structure (bank, seg, or tagseg) in ByteBuffer form. More...
 
virtual void close ()=0
 This sets the position to its initial value and marks reader as closed. More...
 
virtual uint32_t getEventCount ()=0
 This is the number of events in the file/buffer. More...
 
virtual uint32_t getBlockCount ()=0
 This is the number of blocks in the file/buffer including the empty block at the end. More...
 
virtual void toFile (std::string const &fileName)=0
 Save the internal byte buffer to the given file (overwrites existing file). More...
 

Detailed Description

This is an interface for a compact reader of evio format files and buffers.

The word "compact" refers to using the EvioNode class as a compact or lightweight means to refer to an evio event or structure in a buffer. Compact readers do not use EvioEvent, EvioBank, EvioSegment or EvioTagSegment classes which require a full parsing of each event and the creation of a large number of objects.

Author
timmer
Date
6/18/2020.

Member Function Documentation

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::addStructure ( size_t  eventNumber,
ByteBuffer addBuffer 
)
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual void evio::IEvioCompactReader::close ( )
pure virtual

This sets the position to its initial value and marks reader as closed.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual size_t evio::IEvioCompactReader::fileSize ( )
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual uint32_t evio::IEvioCompactReader::getBlockCount ( )
pure virtual

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)

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getByteBuffer ( )
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual ByteOrder evio::IEvioCompactReader::getByteOrder ( )
pure virtual

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

Returns
byte order of the file/buffer being read.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getData ( std::shared_ptr< EvioNode > &  node)
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getData ( std::shared_ptr< EvioNode > &  node,
bool  copy 
)
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getData ( std::shared_ptr< EvioNode > &  node,
std::shared_ptr< ByteBuffer > &  buf 
)
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getData ( std::shared_ptr< EvioNode > &  node,
std::shared_ptr< ByteBuffer > &  buf,
bool  copy 
)
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual std::shared_ptr<EvioXMLDictionary> evio::IEvioCompactReader::getDictionary ( )
pure virtual

Get the evio dictionary if is there is one.

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::string evio::IEvioCompactReader::getDictionaryXML ( )
pure virtual

Get the XML format dictionary is there is one.

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::shared_ptr<EvioNode> evio::IEvioCompactReader::getEvent ( size_t  eventNumber)
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getEventBuffer ( size_t  eventNumber)
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getEventBuffer ( size_t  eventNumber,
bool  copy 
)
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual uint32_t evio::IEvioCompactReader::getEventCount ( )
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual uint32_t evio::IEvioCompactReader::getEvioVersion ( )
pure virtual

Get the evio version number.

Returns
evio version number.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual ByteOrder evio::IEvioCompactReader::getFileByteOrder ( )
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::shared_ptr<IBlockHeader> evio::IEvioCompactReader::getFirstBlockHeader ( )
pure virtual

This returns the FIRST block (or record) header.

(Not the file header of evio version 6+ files).

Returns
the first block header.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::string evio::IEvioCompactReader::getPath ( )
pure virtual

Get the path to the file.

Returns
path to the file

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::shared_ptr<EvioNode> evio::IEvioCompactReader::getScannedEvent ( size_t  eventNumber)
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getStructureBuffer ( std::shared_ptr< EvioNode > &  node)
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::getStructureBuffer ( std::shared_ptr< EvioNode > &  node,
bool  copy 
)
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual bool evio::IEvioCompactReader::hasDictionary ( )
pure virtual

Does this evio file have an associated XML dictionary?

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual bool evio::IEvioCompactReader::isClosed ( )
pure virtual

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

Returns
true
if this object closed, else
false
.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual bool evio::IEvioCompactReader::isCompressed ( )
pure virtual

Is the data in the file/buffer compressed?

Returns
true if data is compressed.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual bool evio::IEvioCompactReader::isFile ( )
pure virtual

Is this reader reading a file?

Returns
true if reading file, false if reading buffer

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::removeEvent ( size_t  eventNumber)
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual std::shared_ptr<ByteBuffer> evio::IEvioCompactReader::removeStructure ( std::shared_ptr< EvioNode > &  removeNode)
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

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

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

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

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.

virtual void evio::IEvioCompactReader::setBuffer ( std::shared_ptr< ByteBuffer > &  buf)
pure virtual

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.

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReader, and evio::EvioCompactReaderV6.

virtual void evio::IEvioCompactReader::toFile ( std::string const &  fileName)
pure virtual

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

Implemented in evio::EvioCompactReaderV4, evio::EvioCompactReaderV6, and evio::EvioCompactReader.


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