evio
6.0
|
This class is used to read the bytes of just an evio structure (NOT a full evio formatted file or buffer). More...
#include <EvioCompactStructureHandler.h>
Public Member Functions | |
EvioCompactStructureHandler (std::shared_ptr< EvioNode > &node) | |
Constructor for reading an EvioNode object. More... | |
EvioCompactStructureHandler (std::shared_ptr< ByteBuffer > &byteBuffer, const DataType &type) | |
Constructor for reading a buffer that contains 1 structure only (no record headers). More... | |
void | setBuffer (std::shared_ptr< ByteBuffer > &buf, const DataType &type) |
This method can be used to avoid creating additional EvioCompactStructureHandler objects by reusing this one with another buffer. More... | |
bool | isClosed () |
Has close() been called (without reopening by calling setBuffer)? More... | |
std::shared_ptr< ByteBuffer > & | getByteBuffer () |
Get the byte buffer being read. More... | |
std::shared_ptr< EvioNode > & | getStructure () |
Get the EvioNode object associated with the structure. More... | |
std::shared_ptr< EvioNode > & | getScannedStructure () |
Get the EvioNode object associated with the structure which has been scanned so all substructures are contained in the node.allNodes vector. More... | |
std::vector< std::shared_ptr< EvioNode > > & | scanStructure () |
This method scans the event in the buffer. More... | |
std::vector< std::shared_ptr< EvioNode > > | searchStructure (uint16_t tag, uint8_t num) |
This method searches the event and returns a vector of objects each of which contain information about a single evio structure which matches the given tag and num. More... | |
std::vector< std::shared_ptr< EvioNode > > | searchStructure (std::string const &dictName, std::shared_ptr< EvioXMLDictionary > dictionary) |
This method searches the event and returns a vector of objects each of which contain information about a single evio structure which matches the given dictionary entry name. More... | |
std::shared_ptr< ByteBuffer > & | removeStructure (std::shared_ptr< EvioNode > removeNode) |
This method removes the data, represented by the given node, from the buffer. More... | |
std::shared_ptr< ByteBuffer > & | addStructure (std::shared_ptr< ByteBuffer > addBuffer) |
This method adds a bank, segment, or tagsegment onto the end of a structure which contains banks, segments, or tagsegments respectively. More... | |
std::shared_ptr< ByteBuffer > | getData (std::shared_ptr< EvioNode > &node) |
Get the data associated with an evio structure in ByteBuffer form. More... | |
std::shared_ptr< ByteBuffer > | getData (std::shared_ptr< EvioNode > &node, bool copy) |
Get the data associated with an evio structure in ByteBuffer form. More... | |
std::shared_ptr< ByteBuffer > | getStructureBuffer (std::shared_ptr< EvioNode > &node) |
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form. More... | |
std::shared_ptr< ByteBuffer > | getStructureBuffer (std::shared_ptr< EvioNode > &node, bool copy) |
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form. More... | |
std::vector< std::shared_ptr< EvioNode > > & | getNodes () |
This method returns a vector of all evio structures in buffer as EvioNode objects. More... | |
std::vector< std::shared_ptr< EvioNode > > & | getChildNodes () |
This method returns a vector of all child evio structures in buffer as EvioNode objects. More... | |
ByteOrder | getByteOrder () |
Get the byte order of buffer being read. More... | |
void | close () |
This only sets the position to its initial value. More... | |
This class is used to read the bytes of just an evio structure (NOT a full evio formatted file or buffer).
It is also capable of adding another structure to or removing it from that structure. The EvioCompactReader class is similar but reads files and buffers in the complete evio version format. It is theoretically thread-safe. It is designed to be fast and does NOT do a deserialization on the buffer examined.
|
explicit |
Constructor for reading an EvioNode object.
The data represented by the given EvioNode object will be copied to a new buffer (obtainable by calling getByteBuffer()) and the node and all of its descendants will switch to that new buffer.
node | the node to be analyzed. |
evio::EvioCompactStructureHandler::EvioCompactStructureHandler | ( | std::shared_ptr< ByteBuffer > & | buf, |
const DataType & | type | ||
) |
Constructor for reading a buffer that contains 1 structure only (no record headers).
The data in the given ByteBuffer object will be copied to a new buffer (obtainable by calling getByteBuffer()).
buf | the buffer to be read that contains 1 structure only (no block headers). |
type | the type of outermost structure contained in buffer, may be DataType#BANK, DataType#SEGMENT, DataType#TAGSEGMENT or equivalent. |
EvioException | if byteBuffer arg is null; if type arg is null or is not an evio structure; if byteBuffer not in proper format; |
References setBuffer().
std::shared_ptr< ByteBuffer > & evio::EvioCompactStructureHandler::addStructure | ( | std::shared_ptr< ByteBuffer > | addBuffer | ) |
This method adds a bank, segment, or tagsegment onto the end of a structure which contains banks, segments, or tagsegments respectively.
It is the responsibility of the caller to make sure that the buffer argument contains valid evio data (only data representing the bank or structure to be added - not in file format with bank header and the like) which is compatible with the type of data structure stored in the parent structure. This means it is not possible to add to structures which contain only a primitive data type.
To produce properly formatted evio data, use EvioBank#write(ByteBuffer), EvioSegment#write(ByteBuffer) or EvioTagSegment#write(ByteBuffer) depending on whether a bank, seg, or tagseg is being added.
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 locked due to the bulk, relative puts.
addBuffer | buffer containing evio data to add (not evio file format, i.e. no bank headers) |
EvioException | 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 there is an internal programming error; if object closed. |
References evio::ByteOrder::ENDIAN_BIG, evio::DataType::isBank(), evio::DataType::isStructure(), and evio::EvioNode::scanStructure().
void evio::EvioCompactStructureHandler::close | ( | ) |
This only sets the position to its initial value.
std::shared_ptr< ByteBuffer > & evio::EvioCompactStructureHandler::getByteBuffer | ( | ) |
Get the byte buffer being read.
ByteOrder evio::EvioCompactStructureHandler::getByteOrder | ( | ) |
Get the byte order of buffer being read.
std::vector< std::shared_ptr< EvioNode > > & evio::EvioCompactStructureHandler::getChildNodes | ( | ) |
This method returns a vector of all child evio structures in buffer as EvioNode objects.
EvioException | if object closed |
References scanStructure().
std::shared_ptr< ByteBuffer > evio::EvioCompactStructureHandler::getData | ( | std::shared_ptr< EvioNode > & | node | ) |
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.
node | evio structure whose data is to be retrieved |
EvioException | if object closed |
std::shared_ptr< ByteBuffer > evio::EvioCompactStructureHandler::getData | ( | std::shared_ptr< EvioNode > & | node, |
bool | copy | ||
) |
Get the data associated with an evio structure 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.
This method is locked due to the bulk, relative gets & puts.
node | evio structure whose data is to be retrieved |
copy | if true , then return a copy as opposed to a view into this reader object's buffer. |
EvioException | if object closed |
std::vector< std::shared_ptr< EvioNode > > & evio::EvioCompactStructureHandler::getNodes | ( | ) |
This method returns a vector of all evio structures in buffer as EvioNode objects.
EvioException | if object closed |
References scanStructure().
std::shared_ptr< EvioNode > & evio::EvioCompactStructureHandler::getScannedStructure | ( | ) |
Get the EvioNode object associated with the structure which has been scanned so all substructures are contained in the node.allNodes vector.
References evio::EvioNode::scanStructure().
std::shared_ptr< EvioNode > & evio::EvioCompactStructureHandler::getStructure | ( | ) |
std::shared_ptr< ByteBuffer > evio::EvioCompactStructureHandler::getStructureBuffer | ( | std::shared_ptr< EvioNode > & | node | ) |
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.
This method is locked due to the bulk, relative gets & puts.
node | node object representing evio structure of interest |
EvioException | if object closed |
std::shared_ptr< ByteBuffer > evio::EvioCompactStructureHandler::getStructureBuffer | ( | std::shared_ptr< EvioNode > & | node, |
bool | copy | ||
) |
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.
This method is locked due to the bulk, relative gets & puts.
node | node object representing evio structure of interest |
copy | if true , then return a copy as opposed to a view into this reader object's buffer. |
EvioException | if object closed |
bool evio::EvioCompactStructureHandler::isClosed | ( | ) |
std::shared_ptr< ByteBuffer > & evio::EvioCompactStructureHandler::removeStructure | ( | std::shared_ptr< EvioNode > | removeNode | ) |
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.
removeNode | evio structure to remove from buffer |
EvioException | if object closed; if node was not found in any event; if internal programming error |
References evio::ByteBuffer::clear(), evio::ByteOrder::ENDIAN_BIG, evio::ByteBuffer::order(), and evio::ByteBuffer::put().
std::vector< std::shared_ptr< EvioNode > > & evio::EvioCompactStructureHandler::scanStructure | ( | ) |
This method scans the event in the buffer.
The results are stored for future reference so the event is only scanned once. It returns a vector of EvioNode objects representing evio structures (banks, segs, tagsegs).
References evio::EvioNode::scanStructure().
Referenced by getChildNodes(), getNodes(), and searchStructure().
std::vector< std::shared_ptr< EvioNode > > evio::EvioCompactStructureHandler::searchStructure | ( | std::string const & | dictName, |
std::shared_ptr< EvioXMLDictionary > | dictionary | ||
) |
This method searches the event and returns a vector of objects each of which contain information about a single evio structure which matches the given dictionary entry name.
dictName | name of dictionary entry to search for |
dictionary | dictionary to use |
EvioException | if either dictName or dictionary arg is empty/null; if dictName is an invalid dictionary entry; if object closed. |
References searchStructure().
std::vector< std::shared_ptr< EvioNode > > evio::EvioCompactStructureHandler::searchStructure | ( | uint16_t | tag, |
uint8_t | num | ||
) |
This method searches the event and returns a vector of objects each of which contain information about a single evio structure which matches the given tag and num.
tag | tag to match |
num | num to match |
EvioException | if object closed. |
References scanStructure().
Referenced by searchStructure().
void evio::EvioCompactStructureHandler::setBuffer | ( | std::shared_ptr< ByteBuffer > & | buf, |
const DataType & | type | ||
) |
This method can be used to avoid creating additional EvioCompactStructureHandler objects by reusing this one with another buffer.
buf | the buffer to be read that contains 1 structure only (no block headers). |
type | the type of outermost structure contained in buffer, may be DataType#BANK, DataType#SEGMENT, DataType#TAGSEGMENT or equivalent. |
EvioException | if type is not an evio structure; if buf not in proper format; |
References evio::DataType::isBank(), and evio::DataType::isStructure().
Referenced by EvioCompactStructureHandler().