evio
6.0
|
#include <EvioNode.h>
Public Member Functions | |
EvioNode (const EvioNode &)=delete | |
~EvioNode ()=default | |
EvioNode & | operator= (const EvioNode &other)=delete |
bool | operator== (const EvioNode &src) const |
Comparison operator. More... | |
bool | operator== (std::shared_ptr< const EvioNode > &src) const |
Comparison operator. More... | |
void | shift (int deltaPos) |
Shift the positions (pos, dataPos, and recordPos) of this node and its children by a fixed amount. More... | |
std::string | toString () const |
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... | |
uint32_t | getChildCount (int level) |
Get the number of children that this node contains at a single level of the evio tree. More... | |
std::shared_ptr< ByteBuffer > & | getBuffer () |
Get the buffer containing this node. 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 (int32_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 | |
template<class ... Args> | |
static std::shared_ptr< EvioNode > | createEvioNode (Args &&...args) |
Create an instance of an EvioNode as a shared_ptr<EvioNode>. More... | |
static void | scanStructure (std::shared_ptr< EvioNode > &node) |
This recursive method stores, in the given EvioNode, all the information about an evio structure and its children found in that node (representing all or part of an underlying ByteBuffer). 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 = 0 |
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 () |
This methods calls shared_from_this() to obtain a new std::shared_ptr that shares ownership of the current object (this). More... | |
Friends | |
class | Util |
class | EventHeaderParser |
class | EvioCompactReaderV4 |
class | EvioCompactReaderV6 |
class | EvioCompactStructureHandler |
class | EvioSwap |
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.
It designed to allow the user to obtain only shared_ptrs to EvioNode objects. The reason for this (and for extending std::enable_shared_from_this<EvioNode>) is that the allNodes vector must (as in Java) contain a reference to itself. This is only possible thru shared pointers and jumping through some other hoops.
|
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. |
|
delete |
|
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.
Referenced by clear().
|
inlinestatic |
Create an instance of an EvioNode as a shared_ptr<EvioNode>.
This variadic template allows createEvioNode to handle all args normally given to EvioNode constructor.
Args |
args | args to pass through to private EvioNode constructors. |
Referenced by evio::EvioCompactReaderV4::addStructure(), extractEventNode(), evio::CompactEventBuilder::openBank(), evio::CompactEventBuilder::openSegment(), evio::CompactEventBuilder::openTagSegment(), scanStructure(), evio::EvioSwap::swapEvent(), and evio::EvioSwap::swapStructure().
|
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 createEvioNode(), and 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 createEvioNode(), and 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 buffer containing this node.
Note, buffer's position and limit may not be set according to this node's position and limit.
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. |
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< 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.
uint32_t evio::EvioNode::getChildCount | ( | int | level | ) |
Get the number of children that this node contains at a single level of the evio tree.
This is meaningful only if this node has been scanned, otherwise it returns 0.
level | go down this many levels in evio structure to count children. A level of 0 means immediate children, 1 means grandchildren, etc. |
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.
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.
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 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 |
This methods calls shared_from_this() to obtain a new std::shared_ptr that shares ownership of the current object (this).
Referenced by clearLists(), and setData().
uint32_t evio::EvioNode::getTotalBytes | ( | ) | const |
Get the length of this evio structure including entire header in bytes.
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 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?
bool evio::EvioNode::operator== | ( | const EvioNode & | src | ) | const |
Comparison operator.
src | right side object. |
bool evio::EvioNode::operator== | ( | std::shared_ptr< const EvioNode > & | src | ) | const |
Comparison operator.
src | right side object. |
|
static |
This recursive method stores, in the given EvioNode, all the information about an evio structure and its children found in that node (representing all or part of an underlying ByteBuffer).
It uses absolute gets so the underlying buffer's position does not change. In the vector of all nodes contained in each EvioNode object (including the top-level object), the ordering is according to their placement in the buffer (which happens to be depth-first). This method does a depth-first search (DFS).
node | node being scanned |
References evio::DataType::BANK, createEvioNode(), evio::DataType::getValue(), evio::DataType::isBank(), evio::DataType::isSegment(), evio::DataType::isStructure(), evio::DataType::SEGMENT, and evio::DataType::TAGSEGMENT.
Referenced by evio::EvioCompactReaderV4::addStructure(), evio::EvioCompactStructureHandler::addStructure(), evio::EvioCompactStructureHandler::getScannedStructure(), and evio::EvioCompactStructureHandler::scanStructure().
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, | ||
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::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::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. |
void 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 | ( | ) | const |
Get a string representation of this object.
References getDataTypeObj(), getTypeObj(), and evio::DataType::toString().
void evio::EvioNode::updateLengths | ( | int32_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 |
|
friend |
|
friend |
uint32_t evio::EvioNode::id = 0 |
Local id for testing.
|
static |
Static id for testing.