evio
6.0
|
This class is used to store relevant info about an evio container (bank, segment, or tag segment), without having to de-serialize it into many objects and arrays. More...
#include <EvioNode.h>
Public Member Functions | |
EvioNode () | |
Constructor when fancy features not needed. More... | |
EvioNode (const EvioNode &firstNode) | |
Copy constructor. More... | |
EvioNode (const std::shared_ptr< EvioNode > &src) | |
Copy constructor. More... | |
EvioNode (EvioNode &&src) noexcept | |
Move constructor. More... | |
EvioNode (size_t pos, uint32_t place, std::shared_ptr< ByteBuffer > &buffer, RecordNode &blockNode) | |
Constructor which creates an EvioNode associated with an event (top level) evio container when parsing buffers for evio data. More... | |
EvioNode (size_t pos, uint32_t place, size_t recordPos, std::shared_ptr< ByteBuffer > &buffer) | |
Constructor which creates an EvioNode associated with an event (top level) evio container when parsing buffers for evio data. More... | |
EvioNode (uint16_t tag, uint8_t num, size_t pos, size_t dataPos, DataType const &type, DataType const &dataType, std::shared_ptr< ByteBuffer > buffer) | |
Constructor which creates an EvioNode in the CompactEventBuilder. More... | |
~EvioNode ()=default | |
EvioNode & | operator= (const EvioNode &other) |
Assignment operator. More... | |
bool | operator== (const EvioNode &src) const |
Comparison operator. More... | |
EvioNode & | shift (int deltaPos) |
Shift the positions (pos, dataPos, and recordPos) of this node and its children by a fixed amount. More... | |
std::string | toString () |
Get a string representation of this object. More... | |
void | clearLists () |
Clear childNodes. More... | |
void | clear () |
Clear all data in this object. More... | |
void | clearObjects () |
Empty all lists and remove all other objects from this object. More... | |
void | clearIntArray () |
Only clear the data vector. More... | |
void | setBuffer (std::shared_ptr< ByteBuffer > &buf) |
Set the buffer. More... | |
void | setData (size_t position, uint32_t plc, std::shared_ptr< ByteBuffer > &buf, RecordNode &recNode) |
Once this node is cleared, it may be reused and then re-initialized with this method. More... | |
void | setData (size_t position, uint32_t plc, size_t recPos, std::shared_ptr< ByteBuffer > &buf) |
Once this node is cleared, it may be reused and then re-initialized with this method. More... | |
bool | isObsolete () const |
Has the data this node represents in the buffer been removed? More... | |
void | setObsolete (bool ob) |
Set whether this node & descendants are now obsolete because the data they represent in the buffer has been removed. More... | |
std::vector< std::shared_ptr < EvioNode > > & | getAllNodes () |
Get the vector of all nodes that this node contains, always including itself. More... | |
std::vector< std::shared_ptr < EvioNode > > & | getChildNodes () |
Get the vector of all child nodes that this node contains. More... | |
void | getAllDescendants (std::vector< std::shared_ptr< EvioNode >> &descendants) |
Get the list of all descendant nodes that this node contains - not only the immediate children. More... | |
std::shared_ptr< EvioNode > | getChildAt (uint32_t index) |
Get the child node at the given index (starts at 0). More... | |
uint32_t | getChildCount () const |
Get the number all children that this node contains. More... | |
std::shared_ptr< ByteBuffer > | getBuffer () |
Get the object containing the buffer that this node is associated with. More... | |
uint32_t | getLength () const |
Get the length of this evio structure (not including length word itself) in 32-bit words. More... | |
uint32_t | getTotalBytes () const |
Get the length of this evio structure including entire header in bytes. More... | |
uint16_t | getTag () const |
Get the tag of this evio structure. More... | |
uint8_t | getNum () const |
Get the num of this evio structure. More... | |
uint32_t | getPad () const |
Get the padding of this evio structure. More... | |
size_t | getPosition () const |
Get the file/buffer byte position of this evio structure. More... | |
uint32_t | getType () const |
Get the evio type of this evio structure, not what it contains. More... | |
DataType | getTypeObj () const |
Get the evio type of this evio structure as an object. More... | |
uint32_t | getDataLength () const |
Get the length of this evio structure's data only (no header words) in 32-bit words. More... | |
size_t | getDataPosition () const |
Get the file/buffer byte position of this evio structure's data. More... | |
uint32_t | getDataType () const |
Get the evio type of the data this evio structure contains. More... | |
DataType | getDataTypeObj () const |
Get the evio type of the data this evio structure contains as an object. More... | |
size_t | getRecordPosition () const |
Get the file/buffer byte position of the record containing this node. More... | |
uint32_t | getPlace () const |
Get the place of containing event in file/buffer. More... | |
std::shared_ptr< EvioNode > | getParentNode () |
Get this node's parent node. More... | |
uint32_t | getEventNumber () const |
If this object represents an event (top-level, evio bank), then returns its number (place in file or buffer) starting with 1. More... | |
bool | isEvent () const |
Does this object represent an event? More... | |
bool | getScanned () const |
Has this object been scanned (i.e. More... | |
void | updateLengths (uint32_t deltaLen) |
Update the length of this node in the buffer and all its parent nodes as well. More... | |
void | updateTag (uint16_t newTag) |
Update, in the buffer, the tag of the structure header this object represents. More... | |
void | updateNum (uint8_t newNum) |
Update, in the buffer, the num of the bank header this object represents. More... | |
ByteBuffer & | getByteData (ByteBuffer &dest, bool copy) |
Get the data associated with this node in ByteBuffer form. More... | |
std::shared_ptr< ByteBuffer > & | getByteData (std::shared_ptr< ByteBuffer > &dest, bool copy) |
Get the data associated with this node in ByteBuffer form. More... | |
std::shared_ptr< ByteBuffer > | getByteData (bool copy) |
Get the data associated with this node in ByteBuffer form. More... | |
std::vector< uint32_t > & | getIntData () |
Get the data associated with this node as an 32-bit integer vector. More... | |
void | getIntData (std::vector< uint32_t > &intData) |
Get the data associated with this node as an 32-bit integer vector. More... | |
void | getLongData (std::vector< uint64_t > &longData) |
Get the data associated with this node as an 64-bit integer vector. More... | |
void | getShortData (std::vector< uint16_t > &shortData) |
Get the data associated with this node as an 16-bit integer vector. More... | |
ByteBuffer & | getStructureBuffer (ByteBuffer &dest, bool copy) |
Get this node's entire evio structure in ByteBuffer form. More... | |
std::shared_ptr< ByteBuffer > & | getStructureBuffer (std::shared_ptr< ByteBuffer > &dest, bool copy) |
Get this node's entire evio structure in ByteBuffer form. More... | |
Static Public Member Functions | |
static void | scanStructure (std::shared_ptr< EvioNode > &node) |
This method recursively stores, in the given list, all the information about an evio structure's children found in the given ByteBuffer object. More... | |
static std::shared_ptr < EvioNode > & | extractNode (std::shared_ptr< EvioNode > &bankNode, size_t position) |
This method populates an EvioNode object that will represent an evio bank from that same node containing a reference to the backing buffer and given a position in that buffer. More... | |
static std::shared_ptr< EvioNode > | extractEventNode (std::shared_ptr< ByteBuffer > &buffer, RecordNode &recNode, size_t position, uint32_t place) |
This method extracts an EvioNode object representing an evio event (top level evio bank) from a given buffer, a location in the buffer, and a few other things. More... | |
static std::shared_ptr< EvioNode > | extractEventNode (std::shared_ptr< ByteBuffer > &buffer, size_t recPosition, size_t position, uint32_t place) |
This method extracts an EvioNode object representing an evio event (top level evio bank) from a given buffer, a location in the buffer, and a few other things. More... | |
Public Attributes | |
uint32_t | id |
Local id for testing. More... | |
Static Public Attributes | |
static uint32_t | staticId = 0 |
Static id for testing. More... | |
Protected Member Functions | |
EvioNode (std::shared_ptr< EvioNode > &firstNode, int dummy) | |
Constructor used when swapping data. More... | |
std::shared_ptr< EvioNode > | getThis () |
Friends | |
class | Util |
class | EventHeaderParser |
class | EvioCompactReaderV4 |
class | EvioCompactReaderV6 |
This class is used to store relevant info about an evio container (bank, segment, or tag segment), without having to de-serialize it into many objects and arrays.
It is not thread-safe and is designed for speed.
|
explicitprotected |
Constructor used when swapping data.
containingEvent | event containing this node. |
dummy | this arg is only here to differentiate it from the other constructor taking a shared pointer of EvioNode. Use any value. |
evio::EvioNode::EvioNode | ( | ) |
Constructor when fancy features not needed.
evio::EvioNode::EvioNode | ( | const EvioNode & | src | ) |
Copy constructor.
|
explicit |
Copy constructor.
|
noexcept |
Move constructor.
evio::EvioNode::EvioNode | ( | size_t | pos, |
uint32_t | place, | ||
std::shared_ptr< ByteBuffer > & | buffer, | ||
RecordNode & | recordNode | ||
) |
Constructor which creates an EvioNode associated with an event (top level) evio container when parsing buffers for evio data.
pos | position of event in buffer (number of bytes) |
place | containing event's place in buffer (starting at 0) |
buffer | buffer containing this event |
recordNode | block containing this event |
References evio::DataType::BANK, and evio::DataType::getValue().
evio::EvioNode::EvioNode | ( | size_t | pos, |
uint32_t | place, | ||
size_t | recordPos, | ||
std::shared_ptr< ByteBuffer > & | buffer | ||
) |
Constructor which creates an EvioNode associated with an event (top level) evio container when parsing buffers for evio data.
pos | position of event in buffer (number of bytes). |
place | containing event's place in buffer (starting at 0). |
recordPos | position of record containing this node. |
buffer | buffer containing this event. |
References evio::DataType::BANK, and evio::DataType::getValue().
evio::EvioNode::EvioNode | ( | uint16_t | tag, |
uint8_t | num, | ||
size_t | pos, | ||
size_t | dataPos, | ||
DataType const & | type, | ||
DataType const & | dataType, | ||
std::shared_ptr< ByteBuffer > | buffer | ||
) |
Constructor which creates an EvioNode in the CompactEventBuilder.
tag | the tag for the event (or bank) header. |
num | the num for the event (or bank) header. |
pos | position of event in buffer (bytes). |
dataPos | position of event's data in buffer (bytes.) |
type | the type of this evio structure. |
dataType | the data type contained in this evio event. |
buffer | buffer containing this event. |
References evio::DataType::getValue().
|
default |
void evio::EvioNode::clear | ( | ) |
Clear all data in this object.
References clearObjects().
void evio::EvioNode::clearIntArray | ( | ) |
Only clear the data vector.
void evio::EvioNode::clearLists | ( | ) |
void evio::EvioNode::clearObjects | ( | ) |
Empty all lists and remove all other objects from this object.
References evio::RecordNode::clear().
Referenced by clear().
|
static |
This method extracts an EvioNode object representing an evio event (top level evio bank) from a given buffer, a location in the buffer, and a few other things.
An EvioNode object represents an evio container - either a bank, segment, or tag segment.
buffer | buffer to examine |
recNode | object holding data about block header |
position | position in buffer |
place | place of event in buffer (starting at 0) |
EvioException | if not enough data in buffer to read evio bank header (8 bytes). |
References extractNode().
Referenced by evio::Reader::scanBuffer(), and evio::Reader::scanUncompressedBuffer().
|
static |
This method extracts an EvioNode object representing an evio event (top level evio bank) from a given buffer, a location in the buffer, and a few other things.
An EvioNode object represents an evio container - either a bank, segment, or tag segment.
buffer | buffer to examine |
recPosition | position of containing record |
position | position in buffer |
place | place of event in buffer (starting at 0) |
EvioException | if not enough data in buffer to read evio bank header (8 bytes). |
References extractNode().
|
static |
This method populates an EvioNode object that will represent an evio bank from that same node containing a reference to the backing buffer and given a position in that buffer.
bankNode | EvioNode to represent a bank and containing, at least, a reference to backing buffer. |
position | position in backing buffer |
EvioException | if not enough data in buffer to read evio bank header (8 bytes). |
References evio::DataType::BANK, evio::ByteBuffer::getInt(), evio::ByteBuffer::getUInt(), evio::DataType::getValue(), and evio::ByteBuffer::remaining().
Referenced by evio::EvioCompactReaderV4::addStructure(), and extractEventNode().
void evio::EvioNode::getAllDescendants | ( | std::vector< std::shared_ptr< EvioNode >> & | descendants | ) |
Get the list of all descendant nodes that this node contains - not only the immediate children.
This is meaningful only if this node has been scanned, otherwise nothing is added to the given list.
descendants | list to be filled with EvioNodes of all descendants |
std::vector< std::shared_ptr< EvioNode > > & evio::EvioNode::getAllNodes | ( | ) |
Get the vector of all nodes that this node contains, always including itself.
This is meaningful only if this node has been scanned, otherwise it contains only itself.
std::shared_ptr< ByteBuffer > evio::EvioNode::getBuffer | ( | ) |
Get the object containing the buffer that this node is associated with.
Referenced by evio::WriterMT::addEvent().
ByteBuffer & evio::EvioNode::getByteData | ( | ByteBuffer & | dest, |
bool | copy | ||
) |
Get the data associated with this node in ByteBuffer form.
Depending on the copy argument, the given buffer will be filled with either a copy of or a view into this node's buffer. Position and limit are set for reading.
dest | buffer in which to place data. |
copy | if true , then return a copy as opposed to a view into this node's buffer. |
References evio::ByteBuffer::copyData(), and evio::ByteBuffer::limit().
Referenced by getByteData().
std::shared_ptr< ByteBuffer > & evio::EvioNode::getByteData | ( | std::shared_ptr< ByteBuffer > & | dest, |
bool | copy | ||
) |
Get the data associated with this node in ByteBuffer form.
Depending on the copy argument, the given buffer will be filled with either a copy of or a view into this node's buffer. Position and limit are set for reading.
dest | buffer in which to place data. |
copy | if true , then return a copy as opposed to a view into this node's buffer. |
References getByteData().
std::shared_ptr< ByteBuffer > evio::EvioNode::getByteData | ( | bool | copy | ) |
Get the data associated with this node in ByteBuffer form.
Depending on the copy argument, the given buffer will be filled with either a copy of or a view into this node's buffer. Position and limit are set for reading.
copy | if true , then return a copy as opposed to a view into this node's buffer. |
std::shared_ptr< EvioNode > evio::EvioNode::getChildAt | ( | uint32_t | index | ) |
Get the child node at the given index (starts at 0).
This is meaningful only if this node has been scanned, otherwise it is null.
index | index of child node |
uint32_t evio::EvioNode::getChildCount | ( | ) | const |
Get the number all children that this node contains.
This is meaningful only if this node has been scanned, otherwise it returns 0.
std::vector< std::shared_ptr< EvioNode > > & evio::EvioNode::getChildNodes | ( | ) |
Get the vector of all child nodes that this node contains.
This is meaningful only if this node has been scanned, otherwise it is null.
uint32_t evio::EvioNode::getDataLength | ( | ) | const |
Get the length of this evio structure's data only (no header words) in 32-bit words.
Referenced by evio::CompositeData::swapAll().
size_t evio::EvioNode::getDataPosition | ( | ) | const |
Get the file/buffer byte position of this evio structure's data.
uint32_t evio::EvioNode::getDataType | ( | ) | const |
Get the evio type of the data this evio structure contains.
Call DataType#getDataType(uint32_t) on the returned value to get the object representation.
DataType evio::EvioNode::getDataTypeObj | ( | ) | const |
Get the evio type of the data this evio structure contains as an object.
References evio::DataType::getDataType().
Referenced by toString().
uint32_t evio::EvioNode::getEventNumber | ( | ) | const |
If this object represents an event (top-level, evio bank), then returns its number (place in file or buffer) starting with 1.
If not, return -1.
std::vector< uint32_t > & evio::EvioNode::getIntData | ( | ) |
Get the data associated with this node as an 32-bit integer vector.
Store it and return it in future calls (like in event builder). If data is of a type less than 32 bits, the last int will be junk.
void evio::EvioNode::getIntData | ( | std::vector< uint32_t > & | intData | ) |
Get the data associated with this node as an 32-bit integer vector.
Place data in the given vector. If data is of a type less than 32 bits, the last int will be junk.
intData | vector in which to store data. |
uint32_t evio::EvioNode::getLength | ( | ) | const |
Get the length of this evio structure (not including length word itself) in 32-bit words.
void evio::EvioNode::getLongData | ( | std::vector< uint64_t > & | longData | ) |
Get the data associated with this node as an 64-bit integer vector.
Place data in the given vector. If data is of a type less than 64 bits, the last element may be junk.
longData | vector in which to store data. |
uint8_t evio::EvioNode::getNum | ( | ) | const |
Get the num of this evio structure.
Will be zero for tagsegments.
uint32_t evio::EvioNode::getPad | ( | ) | const |
Get the padding of this evio structure.
Will be zero for segments and tagsegments.
Referenced by evio::CompositeData::swapAll().
std::shared_ptr< EvioNode > evio::EvioNode::getParentNode | ( | ) |
Get this node's parent node.
uint32_t evio::EvioNode::getPlace | ( | ) | const |
Get the place of containing event in file/buffer.
First event = 0, second = 1, etc. Only for internal use.
size_t evio::EvioNode::getPosition | ( | ) | const |
Get the file/buffer byte position of this evio structure.
size_t evio::EvioNode::getRecordPosition | ( | ) | const |
Get the file/buffer byte position of the record containing this node.
bool evio::EvioNode::getScanned | ( | ) | const |
Has this object been scanned (i.e.
has all the information about this node's children been parsed and stored) ?
true
if this object has been scanned, else false
void evio::EvioNode::getShortData | ( | std::vector< uint16_t > & | shortData | ) |
Get the data associated with this node as an 16-bit integer vector.
Place data in the given vector. If data is of a type less than 16 bits, the last element may be junk.
shortData | vectro in which to store data. |
ByteBuffer & evio::EvioNode::getStructureBuffer | ( | ByteBuffer & | dest, |
bool | copy | ||
) |
Get this node's entire evio structure in ByteBuffer form.
Depending on the copy argument, the returned buffer will either have a copy of or a view into the data of this node's buffer. Position and limit are set for reading.
dest | ByteBuffer provided to hold the retrieved evio structure. |
copy | if true , then use a copy of as opposed to a view into this node's buffer. |
References evio::ByteBuffer::copyData(), and evio::ByteBuffer::limit().
Referenced by evio::RecordOutput::addEvent(), and getStructureBuffer().
std::shared_ptr< ByteBuffer > & evio::EvioNode::getStructureBuffer | ( | std::shared_ptr< ByteBuffer > & | dest, |
bool | copy | ||
) |
Get this node's entire evio structure in ByteBuffer form.
Depending on the copy argument, the returned buffer will either have a copy of or a view into the data of this node's buffer. Position and limit are set for reading.
dest | ByteBuffer provided to hold the retrieved evio structure. |
copy | if true , then use a copy of as opposed to a view into this node's buffer. |
References getStructureBuffer().
uint16_t evio::EvioNode::getTag | ( | ) | const |
Get the tag of this evio structure.
|
inlineprotected |
Referenced by clearLists(), and setData().
uint32_t evio::EvioNode::getTotalBytes | ( | ) | const |
Get the length of this evio structure including entire header in bytes.
Referenced by evio::RecordOutput::addEvent().
uint32_t evio::EvioNode::getType | ( | ) | const |
Get the evio type of this evio structure, not what it contains.
Call DataType#getDataType(uint32_t) on the returned value to get the object representation.
Referenced by updateLengths().
DataType evio::EvioNode::getTypeObj | ( | ) | const |
Get the evio type of this evio structure as an object.
References evio::DataType::getDataType().
Referenced by evio::RecordOutput::addEvent(), and toString().
bool evio::EvioNode::isEvent | ( | ) | const |
Does this object represent an event?
true
if this object represents an event, else false
bool evio::EvioNode::isObsolete | ( | ) | const |
Has the data this node represents in the buffer been removed?
Assignment operator.
src | right side object. |
bool evio::EvioNode::operator== | ( | const EvioNode & | src | ) | const |
Comparison operator.
src | right side object. |
|
static |
This method recursively stores, in the given list, all the information about an evio structure's children found in the given ByteBuffer object.
It uses absolute gets so buffer's position does not change.
node | node being scanned |
References evio::DataType::BANK, evio::DataType::getValue(), evio::DataType::isBank(), evio::DataType::isSegment(), evio::DataType::isStructure(), evio::DataType::SEGMENT, and evio::DataType::TAGSEGMENT.
Referenced by evio::EvioCompactReaderV4::addStructure().
void evio::EvioNode::setBuffer | ( | std::shared_ptr< ByteBuffer > & | buf | ) |
Set the buffer.
buf | buffer associated with this object. |
void evio::EvioNode::setData | ( | size_t | position, |
uint32_t | plc, | ||
std::shared_ptr< ByteBuffer > & | buf, | ||
RecordNode & | recNode | ||
) |
Once this node is cleared, it may be reused and then re-initialized with this method.
position | position in buffer |
plc | place of event in buffer (starting at 0) |
buf | buffer to examine |
recNode | object holding data about header of block containing event |
References evio::DataType::BANK, getThis(), and evio::DataType::getValue().
void evio::EvioNode::setData | ( | size_t | position, |
uint32_t | plc, | ||
size_t | recPos, | ||
std::shared_ptr< ByteBuffer > & | buf | ||
) |
Once this node is cleared, it may be reused and then re-initialized with this method.
position | position in buffer |
plc | place of event in buffer (starting at 0) |
recPos | place of event in containing record (bytes) |
buf | buffer to examine |
References evio::DataType::BANK, getThis(), and evio::DataType::getValue().
void evio::EvioNode::setObsolete | ( | bool | ob | ) |
Set whether this node & descendants are now obsolete because the data they represent in the buffer has been removed.
Only for internal use.
ob | true if node & descendants no longer represent valid buffer data, else false. |
EvioNode & evio::EvioNode::shift | ( | int | deltaPos | ) |
Shift the positions (pos, dataPos, and recordPos) of this node and its children by a fixed amount.
Useful, for example, when the contents of one buffer is copied into another.
deltaPos | number of bytes to add to existing positions. |
std::string evio::EvioNode::toString | ( | ) |
Get a string representation of this object.
References getDataTypeObj(), getTypeObj(), and evio::DataType::toString().
void evio::EvioNode::updateLengths | ( | uint32_t | deltaLen | ) |
Update the length of this node in the buffer and all its parent nodes as well.
For internal use only.
deltaLen | change in length (words). Negative value reduces lengths. |
References evio::DataType::ALSOBANK, evio::DataType::ALSOSEGMENT, evio::DataType::BANK, evio::ByteOrder::ENDIAN_BIG, getType(), evio::DataType::SEGMENT, and evio::DataType::TAGSEGMENT.
void evio::EvioNode::updateNum | ( | uint8_t | newNum | ) |
Update, in the buffer, the num of the bank header this object represents.
Sometimes it's necessary to go back and change the num of an evio structure that's already been written. This will do that.
newNum | new num value |
References evio::DataType::ALSOBANK, evio::DataType::BANK, and evio::ByteOrder::ENDIAN_BIG.
void evio::EvioNode::updateTag | ( | uint16_t | newTag | ) |
Update, in the buffer, the tag of the structure header this object represents.
Sometimes it's necessary to go back and change the tag of an evio structure that's already been written. This will do that.
newTag | new tag value |
References evio::DataType::ALSOBANK, evio::DataType::ALSOSEGMENT, evio::DataType::BANK, evio::ByteOrder::ENDIAN_BIG, evio::DataType::SEGMENT, and evio::DataType::TAGSEGMENT.
|
friend |
|
friend |
|
friend |
|
friend |
uint32_t evio::EvioNode::id |
Local id for testing.
|
static |
Static id for testing.