evio
6.0
|
This is the base class for all evio structures: Banks, Segments, and TagSegments. More...
#include <BaseStructure.h>
Public Types | |
typedef size_t | size_type |
typedef std::ptrdiff_t | difference_type |
typedef std::input_iterator_tag | iterator_category |
typedef std::shared_ptr < BaseStructure > | value_type |
typedef std::shared_ptr < BaseStructure > | reference |
typedef std::shared_ptr < BaseStructure > | pointer |
typedef nodeIterator < std::shared_ptr < BaseStructure > > | iterator |
typedef nodeBreadthIterator < std::shared_ptr < BaseStructure > > | breadth_iterator |
Public Member Functions | |
iterator | begin () |
Get the beginning depth-first iterator. More... | |
iterator | end () |
Get the end depth-first iterator. More... | |
breadth_iterator | bbegin () |
Get the beginning breadth-first iterator. More... | |
breadth_iterator | bend () |
Get the end breadth-first iterator. More... | |
std::shared_ptr< BaseStructure > | getThis () |
std::shared_ptr< const BaseStructure > | getThisConst () const |
void | insert (const std::shared_ptr< BaseStructure > newChild, size_t childIndex) |
Removes newChild from its present parent (if it has a parent), sets the child's parent to this node, and then adds the child to this node's child array at index childIndex . More... | |
void | remove (size_t childIndex) |
Removes the child at the specified index from this node's children and sets that node's parent to null. More... | |
std::shared_ptr< BaseStructure > | getParent () const |
Returns this node's parent or null if this node has no parent. More... | |
std::vector< std::shared_ptr < BaseStructure > > | getChildren () const |
Get the children of this structure. More... | |
std::shared_ptr< BaseStructure > | getChildAt (size_t index) const |
Returns the child at the specified index in this node's child vector. More... | |
size_t | getChildCount () const |
Returns the number of children of this node. More... | |
ssize_t | getIndex (const std::shared_ptr< BaseStructure > aChild) |
Returns the index of the specified child in this node's child vector. More... | |
std::vector< std::shared_ptr < BaseStructure > >::iterator | childrenBegin () |
Creates and returns a forward-order begin iterator of this node's children. More... | |
std::vector< std::shared_ptr < BaseStructure > >::iterator | childrenEnd () |
Creates and returns a forward-order end iterator of this node's children. More... | |
void | setAllowsChildren (bool allows) |
Determines whether or not this node is allowed to have children. More... | |
bool | getAllowsChildren () const |
Returns true if this node is allowed to have children. More... | |
void | removeFromParent () |
Removes the subtree rooted at this node from the tree, giving this node a null parent. More... | |
void | remove (const std::shared_ptr< BaseStructure > aChild) |
Removes aChild from this node's child vector, giving it a null parent. More... | |
void | removeAllChildren () |
Removes all of this node's children, setting their parents to null. More... | |
void | add (std::shared_ptr< BaseStructure > newChild) |
Removes newChild from its parent and makes it a child of this node by adding it to the end of this node's child array. More... | |
bool | isNodeAncestor (const std::shared_ptr< BaseStructure > anotherNode) const |
Returns true if anotherNode is an ancestor of this node – if it is this node, this node's parent, or an ancestor of this node's parent. More... | |
bool | isNodeDescendant (std::shared_ptr< BaseStructure > anotherNode) |
Returns true if anotherNode is a descendant of this node – if it is this node, one of this node's children, or a descendant of one of this node's children. More... | |
std::shared_ptr< BaseStructure > | getSharedAncestor (std::shared_ptr< BaseStructure > aNode) |
Returns the nearest common ancestor to this node and aNode . More... | |
bool | isNodeRelated (std::shared_ptr< BaseStructure > aNode) |
Returns true if and only if aNode is in the same tree as this node. More... | |
uint32_t | getDepth () |
Returns the depth of the tree rooted at this node – the longest distance from this node to a leaf. More... | |
uint32_t | getLevel () const |
Returns the number of levels above this node – the distance from the root to this node. More... | |
std::vector< std::shared_ptr < BaseStructure > > | getPath () |
Returns the path from the root, to get to this node. More... | |
std::shared_ptr< BaseStructure > | getRoot () |
Returns the root of the tree that contains this node. More... | |
bool | isRoot () const |
Returns true if this node is the root of the tree. More... | |
std::shared_ptr< BaseStructure > | getNextNode () |
Returns the node that follows this node in a preorder traversal of this node's tree (return left nodes all the way down before coming back and doing siblings from bottom up). More... | |
std::shared_ptr< BaseStructure > | getPreviousNode () |
Returns the node that precedes this node in a preorder traversal of this node's tree (return left nodes all the way down before coming back and doing siblings from bottom up). More... | |
bool | isNodeChild (const std::shared_ptr< BaseStructure > aNode) const |
Returns true if aNode is a child of this node. More... | |
std::shared_ptr< BaseStructure > | getFirstChild () const |
Returns this node's first child. More... | |
std::shared_ptr< BaseStructure > | getLastChild () const |
Returns this node's last child. More... | |
std::shared_ptr< BaseStructure > | getChildAfter (const std::shared_ptr< BaseStructure > aChild) |
Returns the child in this node's child vector that immediately follows aChild , which must be a child of this node. More... | |
std::shared_ptr< BaseStructure > | getChildBefore (const std::shared_ptr< BaseStructure > aChild) |
Returns the child in this node's child vector that immediately precedes aChild , which must be a child of this node. More... | |
bool | isNodeSibling (const std::shared_ptr< BaseStructure > anotherNode) const |
Returns true if anotherNode is a sibling of (has the same parent as) this node. More... | |
size_t | getSiblingCount () const |
Returns the number of siblings of this node. More... | |
std::shared_ptr< BaseStructure > | getNextSibling () |
Returns the next sibling of this node in the parent's children vector. More... | |
std::shared_ptr< BaseStructure > | getPreviousSibling () |
Returns the previous sibling of this node in the parent's children vector. More... | |
bool | isLeaf () const |
Returns true if this node has no children. More... | |
std::shared_ptr< BaseStructure > | getFirstLeaf () |
Finds and returns the first leaf that is a descendant of this node – either this node or its first child's first leaf. More... | |
std::shared_ptr< BaseStructure > | getLastLeaf () |
Finds and returns the last leaf that is a descendant of this node – either this node or its last child's last leaf. More... | |
std::shared_ptr< BaseStructure > | getNextLeaf () |
Returns the leaf after this node or null if this node is the last leaf in the tree. More... | |
std::shared_ptr< BaseStructure > | getPreviousLeaf () |
Returns the leaf before this node or null if this node is the first leaf in the tree. More... | |
ssize_t | getLeafCount () |
Returns the total number of leaves that are descendants of this node. More... | |
void | visitAllStructures (std::shared_ptr< IEvioListener > listener) |
Visit all the structures in this structure (including the structure itself – which is considered its own descendant). More... | |
void | visitAllStructures (std::shared_ptr< IEvioListener > listener, std::shared_ptr< IEvioFilter > filter) |
Visit all the structures in this structure (including the structure itself – which is considered its own descendant) in a depth first manner. More... | |
void | getMatchingStructures (std::shared_ptr< IEvioFilter > filter, std::vector< std::shared_ptr< BaseStructure >> &vec) |
Visit all the descendant structures, and collect those that pass a filter. More... | |
void | transform (std::shared_ptr< BaseStructure > const &structure) |
This method does a partial copy and is designed to help convert between banks, segments,and tagsegments in the StructureTransformer class (hence the name "transform"). More... | |
virtual StructureType | getStructureType () const |
ByteOrder | getByteOrder () |
What is the byte order of this data? More... | |
void | setByteOrder (ByteOrder const &order) |
Set the byte order of this data. More... | |
bool | needSwap () const |
Is a byte swap required (i.e. More... | |
virtual std::string | toString () const |
Obtain a string representation of the structure. More... | |
std::string | treeToString (std::string const &indent) const |
Recursive method to obtain a string representation of the entire tree structure rooted at this structure. More... | |
std::shared_ptr < BaseStructureHeader > | getHeader () const |
Return the header for this structure. More... | |
size_t | write (ByteBuffer &dest) |
Write myself out into a byte buffer with fastest algorithm I could find. More... | |
size_t | write (uint8_t *dest, ByteOrder const &order) |
Write myself out to a pointer. More... | |
size_t | writeQuick (uint8_t *dest) |
Write myself out as evio format data in the data's current byte order given by getByteOrder() at the given pointer. More... | |
size_t | writeQuick (ByteBuffer &dest) |
Write myself into a ByteBuffer as evio format data in the data's current byte order given by getByteOrder(). More... | |
uint32_t | getNumberDataItems () |
Get the number of stored data items like number of banks, ints, floats, etc. More... | |
uint32_t | setAllHeaderLengths () |
Compute and set length of all header fields for this structure and all its descendants. More... | |
bool | isContainer () const |
Checks whether this structure is a container, i.e. More... | |
uint32_t | getTotalBytes () const |
Get the length of this structure in bytes, including the header. More... | |
std::vector< uint8_t > & | getRawBytes () |
Get the raw data of the structure. More... | |
std::vector< int16_t > & | getShortData () |
Gets the raw data as an int16_t vector if the content type as indicated by the header is appropriate. More... | |
std::vector< uint16_t > & | getUShortData () |
Gets the raw data as an uint16_t vector if the content type as indicated by the header is appropriate. More... | |
std::vector< int32_t > & | getIntData () |
Gets the raw data as an int32_t vector if the content type as indicated by the header is appropriate. More... | |
std::vector< uint32_t > & | getUIntData () |
Gets the raw data as an uint32_t vector if the content type as indicated by the header is appropriate. More... | |
std::vector< int64_t > & | getLongData () |
Gets the raw data as an int64_t vector if the content type as indicated by the header is appropriate. More... | |
std::vector< uint64_t > & | getULongData () |
Gets the raw data as an uint64_t vector if the content type as indicated by the header is appropriate. More... | |
std::vector< float > & | getFloatData () |
Gets the raw data as a float vector if the content type as indicated by the header is appropriate. More... | |
std::vector< double > & | getDoubleData () |
Gets the raw data as a double vector if the content type as indicated by the header is appropriate. More... | |
std::vector< signed char > & | getCharData () |
Gets the raw data as an signed char vector, if the contents type as indicated by the header is appropriate. More... | |
std::vector< unsigned char > & | getUCharData () |
Gets the raw data as an unsigned char vector, if the contents type as indicated by the header is appropriate. More... | |
std::vector< std::shared_ptr < CompositeData > > & | getCompositeData () |
Gets the composite data as an vector of CompositeData objects, if the content type as indicated by the header is appropriate. More... | |
std::vector< std::string > & | getStringData () |
Gets the raw data (ascii) as an vector of string objects, if the contents type as indicated by the header is appropriate. More... | |
uint32_t | unpackRawBytesToStrings () |
Extract string data from rawBytes array. More... | |
void | updateIntData () |
If data in this structure was changed by modifying the vector returned from getIntData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateUIntData () |
If data in this structure was changed by modifying the vector returned from getUIntData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateShortData () |
If data in this structure was changed by modifying the vector returned from getShortData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateUShortData () |
If data in this structure was changed by modifying the vector returned from getUShortData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateLongData () |
If data in this structure was changed by modifying the vector returned from getLongData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateULongData () |
If data in this structure was changed by modifying the vector returned from getULongData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateCharData () |
If data in this structure was changed by modifying the vector returned from getCharData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateUCharData () |
If data in this structure was changed by modifying the vector returned from getUCharData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateFloatData () |
If data in this structure was changed by modifying the vector returned from getFloatData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateDoubleData () |
If data in this structure was changed by modifying the vector returned from getDoubleData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateStringData () |
If data in this structure was changed by modifying the vector returned from getStringData(), then this method needs to be called in order to make this object internally consistent. More... | |
void | updateCompositeData () |
If data in this structure was changed by modifying the vector returned from getCompositeData(), then this method needs to be called in order to make this object internally consistent. More... | |
Static Public Member Functions | |
static uint32_t | stringToRawSize (const std::string &str) |
This method returns the number of bytes in a raw evio format of the given string vector, not including header. More... | |
static uint32_t | stringsToRawSize (std::vector< std::string > const &strings) |
This method returns the number of bytes in a raw evio format of the given string vector, not including header. More... | |
static void | stringsToRawBytes (std::vector< std::string > &strings, std::vector< uint8_t > &bytes) |
This method transforms a vector of strings into raw evio format data, not including header. More... | |
static void | unpackRawBytesToStrings (std::vector< uint8_t > &bytes, size_t offset, std::vector< std::string > &strData) |
This method extracts a vector of strings from bytes of raw evio string data. More... | |
static void | unpackRawBytesToStrings (std::vector< uint8_t > &bytes, size_t offset, size_t maxLength, std::vector< std::string > &strData) |
This method extracts a vector of strings from bytes of raw evio string data. More... | |
static void | unpackRawBytesToStrings (uint8_t *bytes, size_t length, std::vector< std::string > &strData) |
This method extracts a vector of strings from bytes of raw evio string data. More... | |
static void | unpackRawBytesToStrings (ByteBuffer &buffer, size_t pos, size_t length, std::vector< std::string > &strData) |
This method extracts a vector of strings from buffer containing raw evio string data. More... | |
Protected Member Functions | |
void | setParent (const std::shared_ptr< BaseStructure > &newParent) |
Sets this node's parent to newParent but does not change the parent's child array. More... | |
std::vector< std::shared_ptr < BaseStructure > > | getPathToRoot (const std::shared_ptr< BaseStructure > &aNode, int depth) const |
Builds the parents of node up to and including the root node, where the original node is the last element in the returned vector. More... | |
bool | getLengthsUpToDate () const |
Get whether the lengths of all header fields for this structure and all it descendants are up to date or not. More... | |
void | setLengthsUpToDate (bool lengthsUpToDate) |
Set whether the lengths of all header fields for this structure and all it descendants are up to date or not. More... | |
uint32_t | dataLength () |
Compute the dataLength in 32-bit words. More... | |
void | stringsToRawBytes () |
This method transforms the internal vector of strings into internal rawBytes vector of evio format data not including header. More... | |
BaseStructure () | |
Constructor. More... | |
BaseStructure (std::shared_ptr< BaseStructureHeader > head) | |
Constructor using a provided header. More... | |
BaseStructure (const BaseStructure &srcBuf) | |
Copy constructor. More... | |
BaseStructure (BaseStructure &&srcBuf) noexcept | |
Move constructor. More... | |
BaseStructure & | operator= (BaseStructure &&other) noexcept |
Move assignment operator. More... | |
BaseStructure & | operator= (const BaseStructure &other) |
Assignment operator. More... | |
void | setRawBytes (uint8_t *bytes, uint32_t len) |
Set the data for the structure. More... | |
void | setRawBytes (std::vector< uint8_t > &bytes) |
Set the data for the structure. More... | |
Protected Attributes | |
std::shared_ptr< BaseStructure > | parent = nullptr |
This node's parent, or null if this node has no parent. More... | |
std::vector< std::shared_ptr < BaseStructure > > | children |
Array of children, may be null if this node has no children. More... | |
bool | allowsChildren = true |
True if the node is able to have children. More... | |
std::shared_ptr < BaseStructureHeader > | header |
Holds the header of the bank as a shared pointer. More... | |
std::vector< uint8_t > | rawBytes |
The raw data of the structure. More... | |
std::vector< int16_t > | shortData |
Used if raw data should be interpreted as shorts. More... | |
std::vector< uint16_t > | ushortData |
Used if raw data should be interpreted as unsigned shorts. More... | |
std::vector< int32_t > | intData |
Used if raw data should be interpreted as ints. More... | |
std::vector< uint32_t > | uintData |
Used if raw data should be interpreted as unsigned ints. More... | |
std::vector< int64_t > | longData |
Used if raw data should be interpreted as longs. More... | |
std::vector< uint64_t > | ulongData |
Used if raw data should be interpreted as unsigned longs. More... | |
std::vector< double > | doubleData |
Used if raw data should be interpreted as doubles. More... | |
std::vector< float > | floatData |
Used if raw data should be interpreted as floats. More... | |
std::vector< std::shared_ptr < CompositeData > > | compositeData |
Used if raw data should be interpreted as composite type. More... | |
std::vector< signed char > | charData |
Used if raw data should be interpreted as signed chars. More... | |
std::vector< unsigned char > | ucharData |
Used if raw data should be interpreted as unsigned chars. More... | |
std::vector< std::string > | stringList |
Used if raw data should be interpreted as a string. More... | |
int | stringEnd = 0 |
Keep track of end of the last string added to stringData (including null but not padding). More... | |
bool | badStringFormat = false |
True if char data has non-ascii or non-printable characters, or has too little data to be in proper format. More... | |
size_t | numberDataItems = 0 |
The number of stored data items like number of banks, ints, floats, etc. More... | |
ByteOrder | byteOrder {ByteOrder::ENDIAN_LOCAL} |
Endianness of the raw data if appropriate. More... | |
bool | lengthsUpToDate = false |
Keep track of whether header length data is up-to-date or not. More... | |
Friends | |
class | EventParser |
class | EvioReader |
class | EvioReaderV4 |
class | EventBuilder |
class | StructureTransformer |
class | nodeIterator< std::shared_ptr< BaseStructure > > |
class | nodeBreadthIterator< std::shared_ptr< BaseStructure > > |
This is the base class for all evio structures: Banks, Segments, and TagSegments.
It is also a tree node which allows the evio structures to be represented as a tree and iterated over.
The tree code is taken from Java's DefaultMutableTreeNode
class which has been ported to C++ and included here. In this code, all nodes, such as children and parent, are shared pointers. That explains inheriting from enable_shared_from_this since "this" object must also be used as a shared pointer.
typedef nodeBreadthIterator<std::shared_ptr<BaseStructure> > evio::BaseStructure::breadth_iterator |
typedef std::ptrdiff_t evio::BaseStructure::difference_type |
typedef nodeIterator<std::shared_ptr<BaseStructure> > evio::BaseStructure::iterator |
typedef std::input_iterator_tag evio::BaseStructure::iterator_category |
typedef std::shared_ptr<BaseStructure> evio::BaseStructure::pointer |
typedef std::shared_ptr<BaseStructure> evio::BaseStructure::reference |
typedef size_t evio::BaseStructure::size_type |
typedef std::shared_ptr<BaseStructure> evio::BaseStructure::value_type |
|
protected |
|
explicitprotected |
|
protected |
Copy constructor.
base | BaseStructure to copy. |
References allowsChildren, children, header, lengthsUpToDate, and parent.
|
protectednoexcept |
Move constructor.
base | BaseStructure to move. |
References allowsChildren, badStringFormat, byteOrder, charData, children, compositeData, doubleData, floatData, header, intData, lengthsUpToDate, longData, numberDataItems, parent, rawBytes, shortData, stringEnd, stringList, ucharData, uintData, ulongData, and ushortData.
void evio::BaseStructure::add | ( | std::shared_ptr< BaseStructure > | newChild | ) |
Removes newChild
from its parent and makes it a child of this node by adding it to the end of this node's child array.
Originally part of java's DefaultMutableTreeNode.
newChild | node to add as a child of this node. |
EvioException | if newChild is null, or this node does not allow children. |
References getChildCount(), getThis(), and insert().
|
inline |
Get the beginning breadth-first iterator.
References getThis().
Referenced by getDepth(), and getLeafCount().
|
inline |
Get the beginning depth-first iterator.
References getThis().
|
inline |
Get the end breadth-first iterator.
References getThis().
Referenced by getDepth(), and getLeafCount().
std::vector< std::shared_ptr< BaseStructure > >::iterator evio::BaseStructure::childrenBegin | ( | ) |
Creates and returns a forward-order begin iterator of this node's children.
Modifying this node's child array invalidates any child iterators created before the modification. Originally part of java's DefaultMutableTreeNode.
References children.
std::vector< std::shared_ptr< BaseStructure > >::iterator evio::BaseStructure::childrenEnd | ( | ) |
Creates and returns a forward-order end iterator of this node's children.
Modifying this node's child array invalidates any child iterators created before the modification. Originally part of java's DefaultMutableTreeNode.
References children.
|
protected |
Compute the dataLength in 32-bit words.
This is the amount of data needed by a leaf of primitives. For non-leafs (structures of structures) this returns 0. For data types smaller than an int, e.g. a short, it computes assuming padding to an integer number of ints. For example, if we are writing a byte array of length 3 or 4, the it would return 1. If the byte array is 5,6,7 or 8 it would return 2;
References evio::DataType::CHAR8, evio::DataType::CHARSTAR8, evio::DataType::COMPOSITE, evio::DataType::getBytes(), getNumberDataItems(), header, isLeaf(), rawBytes, evio::DataType::UCHAR8, and evio::DataType::UNKNOWN32.
Referenced by setAllHeaderLengths().
|
inline |
Get the end depth-first iterator.
References getThis().
Referenced by getIndex(), and remove().
bool evio::BaseStructure::getAllowsChildren | ( | ) | const |
Returns true if this node is allowed to have children.
Originally part of java's DefaultMutableTreeNode.
References allowsChildren.
ByteOrder evio::BaseStructure::getByteOrder | ( | ) |
What is the byte order of this data?
References byteOrder.
Referenced by writeQuick().
std::vector< signed char > & evio::BaseStructure::getCharData | ( | ) |
Gets the raw data as an signed char vector, if the contents type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateCharData MUST be called!
null
if this makes no sense for the given contents type. References evio::DataType::CHAR8, charData, header, and rawBytes.
std::shared_ptr< BaseStructure > evio::BaseStructure::getChildAfter | ( | const std::shared_ptr< BaseStructure > | aChild | ) |
Returns the child in this node's child vector that immediately follows aChild
, which must be a child of this node.
If aChild
is the last child, returns null. This method performs a linear search of this node's children for aChild
and is O(n) where n is the number of children; to traverse the entire vector of children, use an iterator instead. Originally part of java's DefaultMutableTreeNode.
aChild | child of this node which immediately precedes the returned child structure. |
EvioException | if aChild is null or is not a child of this node. |
aChild
. References getChildAt(), getChildCount(), and getIndex().
std::shared_ptr< BaseStructure > evio::BaseStructure::getChildAt | ( | size_t | index | ) | const |
Returns the child at the specified index in this node's child vector.
Originally part of java's DefaultMutableTreeNode.
index | an index into this node's child array. |
std::out_of_range | if index is out of bounds. |
References children.
Referenced by getChildAfter(), getChildBefore(), getFirstChild(), getLastChild(), getNextNode(), and remove().
std::shared_ptr< BaseStructure > evio::BaseStructure::getChildBefore | ( | const std::shared_ptr< BaseStructure > | aChild | ) |
Returns the child in this node's child vector that immediately precedes aChild
, which must be a child of this node.
If aChild
is the first child, returns null. This method performs a linear search of this node's children for aChild
and is O(n) where n is the number of children. Originally part of java's DefaultMutableTreeNode.
aChild | child of this node which comes immediately after the returned child structure. |
EvioException | if aChild is null or is not a child of this node. |
aChild
. References getChildAt(), and getIndex().
size_t evio::BaseStructure::getChildCount | ( | ) | const |
Returns the number of children of this node.
Originally part of java's DefaultMutableTreeNode.
References children.
Referenced by add(), getChildAfter(), getFirstChild(), getLastChild(), getNextNode(), isLeaf(), isNodeChild(), removeAllChildren(), and treeToString().
std::vector< std::shared_ptr< BaseStructure > > evio::BaseStructure::getChildren | ( | ) | const |
std::vector< std::shared_ptr< CompositeData > > & evio::BaseStructure::getCompositeData | ( | ) |
Gets the composite data as an vector of CompositeData objects, if the content type as indicated by the header is appropriate.
null
if this makes no sense for the given content type. EvioException | if the data is internally inconsistent. |
References byteOrder, evio::DataType::COMPOSITE, compositeData, header, evio::CompositeData::parse(), and rawBytes.
uint32_t evio::BaseStructure::getDepth | ( | ) |
Returns the depth of the tree rooted at this node – the longest distance from this node to a leaf.
If this node has no children, returns 0. This operation is much more expensive than getLevel()
because it must effectively traverse the entire tree rooted at this node. Originally part of java's DefaultMutableTreeNode.
EvioException | if internal logic error. |
References bbegin(), bend(), and getLevel().
std::vector< double > & evio::BaseStructure::getDoubleData | ( | ) |
Gets the raw data as a double vector if the content type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateDoubleData MUST be called!
EvioException | if contained data type is not double. |
References evio::DataType::DOUBLE64, doubleData, header, needSwap(), rawBytes, and SWAP_64.
std::shared_ptr< BaseStructure > evio::BaseStructure::getFirstChild | ( | ) | const |
Returns this node's first child.
If this node has no children, throws EvioException. Originally part of java's DefaultMutableTreeNode.
EvioException | if this node has no children. |
References getChildAt(), and getChildCount().
std::shared_ptr< BaseStructure > evio::BaseStructure::getFirstLeaf | ( | ) |
Finds and returns the first leaf that is a descendant of this node – either this node or its first child's first leaf.
Returns this node if it is a leaf. Originally part of java's DefaultMutableTreeNode.
References getThis().
std::vector< float > & evio::BaseStructure::getFloatData | ( | ) |
Gets the raw data as a float vector if the content type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateFloatData MUST be called!
EvioException | if contained data type is not float. |
References evio::DataType::FLOAT32, floatData, header, needSwap(), rawBytes, and SWAP_32.
std::shared_ptr< BaseStructureHeader > evio::BaseStructure::getHeader | ( | ) | const |
ssize_t evio::BaseStructure::getIndex | ( | const std::shared_ptr< BaseStructure > | aChild | ) |
Returns the index of the specified child in this node's child vector.
If the specified node is not a child of this node, returns -1
. This method performs a linear search and is O(n) where n is the number of children. Originally part of java's DefaultMutableTreeNode.
aChild | the BaseStructure to search for among this node's children. |
EvioException | if aChild is null. |
-1
if the specified node is a not a child of this node. References children, end(), and isNodeChild().
Referenced by getChildAfter(), getChildBefore(), and remove().
std::vector< int32_t > & evio::BaseStructure::getIntData | ( | ) |
Gets the raw data as an int32_t vector if the content type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateIntData MUST be called!
EvioException | if contained data type is not int32_t. |
References header, evio::DataType::INT32, intData, needSwap(), rawBytes, and SWAP_32.
std::shared_ptr< BaseStructure > evio::BaseStructure::getLastChild | ( | ) | const |
Returns this node's last child.
If this node has no children, throws EvioException. Originally part of java's DefaultMutableTreeNode.
EvioException | if this node has no children. |
References getChildAt(), and getChildCount().
std::shared_ptr< BaseStructure > evio::BaseStructure::getLastLeaf | ( | ) |
Finds and returns the last leaf that is a descendant of this node – either this node or its last child's last leaf.
Returns this node if it is a leaf. Originally part of java's DefaultMutableTreeNode.
References getThis().
ssize_t evio::BaseStructure::getLeafCount | ( | ) |
Returns the total number of leaves that are descendants of this node.
If this node is a leaf, returns 1
. This method is O(n) where n is the number of descendants of this node. Originally part of java's DefaultMutableTreeNode.
EvioException | if tree has zero leaves. |
|
protected |
Get whether the lengths of all header fields for this structure and all it descendants are up to date or not.
References lengthsUpToDate.
uint32_t evio::BaseStructure::getLevel | ( | ) | const |
Returns the number of levels above this node – the distance from the root to this node.
If this node is the root, returns 0. Originally part of java's DefaultMutableTreeNode.
References getThisConst().
Referenced by getDepth(), and getSharedAncestor().
std::vector< int64_t > & evio::BaseStructure::getLongData | ( | ) |
Gets the raw data as an int64_t vector if the content type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateLongData MUST be called!
EvioException | if contained data type is not int64_t. |
References header, evio::DataType::LONG64, longData, needSwap(), rawBytes, and SWAP_64.
void evio::BaseStructure::getMatchingStructures | ( | std::shared_ptr< IEvioFilter > | filter, |
std::vector< std::shared_ptr< BaseStructure >> & | vec | ||
) |
Visit all the descendant structures, and collect those that pass a filter.
filter | the filter that must be passed. If null , this will return all the structures. |
vec | vector provided to contain all structures that are accepted by the filter. |
References visitAllStructures().
std::shared_ptr< BaseStructure > evio::BaseStructure::getNextLeaf | ( | ) |
Returns the leaf after this node or null if this node is the last leaf in the tree.
This operation is very inefficient. In order to determine the next node, this method first performs a linear search in the parent's child-list in order to find the current node.
This implementation makes the operation suitable for short traversals from a known position. But to traverse all of the leaves in the tree, you should use A depth-first iterator of the nodes in the tree and use isLeaf
on each node to determine which are leaves. Originally part of java's DefaultMutableTreeNode.
References getNextSibling(), and getParent().
std::shared_ptr< BaseStructure > evio::BaseStructure::getNextNode | ( | ) |
Returns the node that follows this node in a preorder traversal of this node's tree (return left nodes all the way down before coming back and doing siblings from bottom up).
Returns null if this node is the last node of the traversal. This is an inefficient way to traverse the entire tree; use an iterator instead. Originally part of java's DefaultMutableTreeNode.
References getChildAt(), getChildCount(), getNextSibling(), and getParent().
std::shared_ptr< BaseStructure > evio::BaseStructure::getNextSibling | ( | ) |
Returns the next sibling of this node in the parent's children vector.
Returns null if this node has no parent or is the parent's last child. This method performs a linear search that is O(n) where n is the number of children; to traverse the entire array, use the parent's child iterator instead. Originally part of java's DefaultMutableTreeNode.
EvioException | if child of parent is not a sibling. |
References getParent(), getThis(), and isNodeSibling().
Referenced by getNextLeaf(), and getNextNode().
uint32_t evio::BaseStructure::getNumberDataItems | ( | ) |
Get the number of stored data items like number of banks, ints, floats, etc.
(not the size in ints or bytes). Some items may be padded such as shorts and bytes. This will tell the meaningful number of such data items. In the case of containers, returns number of 32-bit words not in header.
References evio::DataType::CHARSTAR8, evio::DataType::COMPOSITE, compositeData, evio::DataType::getBytes(), getStringData(), header, isContainer(), numberDataItems, and rawBytes.
Referenced by dataLength().
std::shared_ptr< BaseStructure > evio::BaseStructure::getParent | ( | ) | const |
Returns this node's parent or null if this node has no parent.
Originally part of java's DefaultMutableTreeNode.
References parent.
Referenced by getNextLeaf(), getNextNode(), getNextSibling(), getPreviousLeaf(), getPreviousNode(), getPreviousSibling(), getSiblingCount(), isNodeSibling(), isRoot(), and removeFromParent().
std::vector< std::shared_ptr< BaseStructure > > evio::BaseStructure::getPath | ( | ) |
Returns the path from the root, to get to this node.
The last element in the path is this node. Originally part of java's DefaultMutableTreeNode.
References getPathToRoot(), and getThis().
|
protected |
Builds the parents of node up to and including the root node, where the original node is the last element in the returned vector.
The length of the returned array gives the node's depth in the tree. Originally part of java's DefaultMutableTreeNode.
aNode | the BaseStructure to get the path for. |
depth | an int giving the number of steps already taken towards the root (on recursive calls), used to size the returned vector. |
Referenced by getPath().
std::shared_ptr< BaseStructure > evio::BaseStructure::getPreviousLeaf | ( | ) |
Returns the leaf before this node or null if this node is the first leaf in the tree.
This operation is very inefficient. In order to determine the previous node, this method first performs a linear search in the parent's child-list in order to find the current node.
This implementation makes the operation suitable for short traversals from a known position. But to traverse all of the leaves in the tree, you should use A depth-first iterator of the nodes in the tree and use isLeaf
on each node to determine which are leaves. Originally part of java's DefaultMutableTreeNode.
References getParent(), and getPreviousSibling().
std::shared_ptr< BaseStructure > evio::BaseStructure::getPreviousNode | ( | ) |
Returns the node that precedes this node in a preorder traversal of this node's tree (return left nodes all the way down before coming back and doing siblings from bottom up).
Returns null
if this node is the first node of the traversal – the root of the tree. This is an inefficient way to traverse the entire tree; use an iterator instead. Originally part of java's DefaultMutableTreeNode.
References getParent(), and getPreviousSibling().
std::shared_ptr< BaseStructure > evio::BaseStructure::getPreviousSibling | ( | ) |
Returns the previous sibling of this node in the parent's children vector.
Returns null if this node has no parent or is the parent's first child. This method performs a linear search that is O(n) where n is the number of children. Originally part of java's DefaultMutableTreeNode.
EvioException | if child of parent is not a sibling. |
References getParent(), getThis(), and isNodeSibling().
Referenced by getPreviousLeaf(), and getPreviousNode().
std::vector< uint8_t > & evio::BaseStructure::getRawBytes | ( | ) |
std::shared_ptr< BaseStructure > evio::BaseStructure::getRoot | ( | ) |
Returns the root of the tree that contains this node.
The root is the ancestor with a null parent. Originally part of java's DefaultMutableTreeNode.
References getThis().
Referenced by isNodeRelated().
std::shared_ptr< BaseStructure > evio::BaseStructure::getSharedAncestor | ( | std::shared_ptr< BaseStructure > | aNode | ) |
Returns the nearest common ancestor to this node and aNode
.
Returns null if no such ancestor exists – if this node and aNode
are in different trees or if aNode
is null. A node is considered an ancestor of itself. Originally part of java's DefaultMutableTreeNode.
aNode | node to find common ancestor with. |
EvioException | if internal logic error. |
aNode
, or null if none. References getLevel(), and getThis().
std::vector< int16_t > & evio::BaseStructure::getShortData | ( | ) |
Gets the raw data as an int16_t vector if the content type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateShortData MUST be called!
EvioException | if contained data type is not int16_t. |
References header, needSwap(), rawBytes, evio::DataType::SHORT16, shortData, and SWAP_16.
size_t evio::BaseStructure::getSiblingCount | ( | ) | const |
Returns the number of siblings of this node.
A node is its own sibling (if it has no parent or no siblings, this method returns 1
). Originally part of java's DefaultMutableTreeNode.
References getParent().
std::vector< std::string > & evio::BaseStructure::getStringData | ( | ) |
Gets the raw data (ascii) as an vector of string objects, if the contents type as indicated by the header is appropriate.
For any other behavior, the user should retrieve the data as a bytes and manipulate it in the exact manner desired. If there are non ascii or non-printing ascii chars or the bytes or not in evio format, a single string containing everything is returned.
Originally, in evio versions 1, 2 and 3, only one string was stored. Subsequent changes allowed a vector of strings to be stored and retrieved. The changes are backwards compatible.
The following is true about the string raw data format:
null
if this makes no sense for the given type. References evio::DataType::CHARSTAR8, header, rawBytes, stringList, and unpackRawBytesToStrings().
Referenced by getNumberDataItems().
|
inlinevirtual |
Reimplemented in evio::EvioBank, evio::EvioSegment, and evio::EvioTagSegment.
References evio::StructureType::STRUCT_UNKNOWN32.
Referenced by toString().
|
inline |
Referenced by add(), bbegin(), begin(), bend(), end(), getFirstLeaf(), getLastLeaf(), getNextSibling(), getPath(), getPreviousSibling(), getRoot(), getSharedAncestor(), insert(), isNodeDescendant(), removeFromParent(), and visitAllStructures().
|
inline |
Referenced by getLevel(), isNodeAncestor(), isNodeChild(), and isNodeSibling().
uint32_t evio::BaseStructure::getTotalBytes | ( | ) | const |
std::vector< unsigned char > & evio::BaseStructure::getUCharData | ( | ) |
Gets the raw data as an unsigned char vector, if the contents type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateCharData MUST be called!
null
if this makes no sense for the given contents type. References header, rawBytes, evio::DataType::UCHAR8, and ucharData.
std::vector< uint32_t > & evio::BaseStructure::getUIntData | ( | ) |
Gets the raw data as an uint32_t vector if the content type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateUIntData MUST be called!
EvioException | if contained data type is not uint32_t. |
References header, needSwap(), rawBytes, SWAP_32, evio::DataType::UINT32, and uintData.
std::vector< uint64_t > & evio::BaseStructure::getULongData | ( | ) |
Gets the raw data as an uint64_t vector if the content type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateULongData MUST be called!
EvioException | if contained data type is not uint64_t. |
References header, needSwap(), rawBytes, SWAP_64, evio::DataType::ULONG64, and ulongData.
std::vector< uint16_t > & evio::BaseStructure::getUShortData | ( | ) |
Gets the raw data as an uint16_t vector if the content type as indicated by the header is appropriate.
If the returned vector's data is modified, then updateUShortData MUST be called!
EvioException | if contained data type is not uint16_t. |
References header, needSwap(), rawBytes, SWAP_16, evio::DataType::USHORT16, and ushortData.
void evio::BaseStructure::insert | ( | const std::shared_ptr< BaseStructure > | newChild, |
size_t | childIndex | ||
) |
Removes newChild
from its present parent (if it has a parent), sets the child's parent to this node, and then adds the child to this node's child array at index childIndex
.
newChild
must not be null and must not be an ancestor of this node. Originally part of java's DefaultMutableBaseStructure.
newChild | the BaseStructure to insert under this node. |
childIndex | the index in this node's child array. where this node is to be inserted. |
std::out_of_range | if childIndex is out of bounds. |
EvioException | if newChild is null, is an ancestor of this node, or this node does not allow children. |
References allowsChildren, children, getThis(), isNodeAncestor(), and setLengthsUpToDate().
Referenced by add().
bool evio::BaseStructure::isContainer | ( | ) | const |
Checks whether this structure is a container, i.e.
a structure of structures.
true
if this structure is a container. This is the same check as getAllowsChildren. References header.
Referenced by getNumberDataItems().
bool evio::BaseStructure::isLeaf | ( | ) | const |
Returns true if this node has no children.
To distinguish between nodes that have no children and nodes that cannot have children (e.g. to distinguish files from empty directories), use this method in conjunction with getAllowsChildren
. Originally part of java's DefaultMutableBaseStructure.
References getChildCount().
Referenced by dataLength(), setAllHeaderLengths(), treeToString(), and write().
bool evio::BaseStructure::isNodeAncestor | ( | const std::shared_ptr< BaseStructure > | anotherNode | ) | const |
Returns true if anotherNode
is an ancestor of this node – if it is this node, this node's parent, or an ancestor of this node's parent.
(Note that a node is considered an ancestor of itself.) If anotherNode
is null, this method returns false. This operation is at worst O(h) where h is the distance from the root to this node. Originally part of java's DefaultMutableTreeNode.
anotherNode | node to test as an ancestor of this node |
anotherNode
References getThisConst().
Referenced by insert().
bool evio::BaseStructure::isNodeChild | ( | const std::shared_ptr< BaseStructure > | aNode | ) | const |
Returns true if aNode
is a child of this node.
If aNode
is null, this method returns false. Originally part of java's DefaultMutableTreeNode.
aNode | structure to test if it's a child of this one. |
aNode
is a child of this node; false if aNode
is null. References getChildCount(), and getThisConst().
Referenced by getIndex(), and remove().
bool evio::BaseStructure::isNodeDescendant | ( | std::shared_ptr< BaseStructure > | anotherNode | ) |
Returns true if anotherNode
is a descendant of this node – if it is this node, one of this node's children, or a descendant of one of this node's children.
Note that a node is considered a descendant of itself. If anotherNode
is null, returns false. This operation is at worst O(h) where h is the distance from the root to anotherNode
. Originally part of java's DefaultMutableTreeNode.
anotherNode | node to test as descendant of this node |
anotherNode
References getThis().
bool evio::BaseStructure::isNodeRelated | ( | std::shared_ptr< BaseStructure > | aNode | ) |
Returns true if and only if aNode
is in the same tree as this node.
Returns false if aNode
is null. Originally part of java's DefaultMutableTreeNode.
aNode | structure to test if it's in the same tree as this one. |
aNode
is in the same tree as this node; false if aNode
is null References getRoot().
bool evio::BaseStructure::isNodeSibling | ( | const std::shared_ptr< BaseStructure > | anotherNode | ) | const |
Returns true if anotherNode
is a sibling of (has the same parent as) this node.
A node is its own sibling. If anotherNode
is null, returns false. Originally part of java's DefaultMutableTreeNode.
anotherNode | node to test as sibling of this node. |
EvioException | if sibling has different parent. |
anotherNode
is a sibling of this node. References getParent(), and getThisConst().
Referenced by getNextSibling(), and getPreviousSibling().
bool evio::BaseStructure::isRoot | ( | ) | const |
Returns true if this node is the root of the tree.
The root is the only node in the tree with a null parent; every tree has exactly one root. Originally part of java's DefaultMutableTreeNode.
References getParent().
bool evio::BaseStructure::needSwap | ( | ) | const |
Is a byte swap required (i.e.
is the data endian opposite of local endian)?
true
if byte swapping is required. References byteOrder, and evio::ByteOrder::ENDIAN_LOCAL.
Referenced by getDoubleData(), getFloatData(), getIntData(), getLongData(), getShortData(), getUIntData(), getULongData(), and getUShortData().
|
protectednoexcept |
Move assignment operator.
other | right side object. |
References allowsChildren, badStringFormat, byteOrder, charData, children, compositeData, doubleData, floatData, header, intData, lengthsUpToDate, longData, numberDataItems, parent, rawBytes, shortData, stringEnd, stringList, ucharData, uintData, ulongData, and ushortData.
|
protected |
Assignment operator.
other | right side object. |
References allowsChildren, children, header, lengthsUpToDate, and parent.
void evio::BaseStructure::remove | ( | size_t | childIndex | ) |
Removes the child at the specified index from this node's children and sets that node's parent to null.
The child node to remove must be a BaseStructure
. Originally part of java's DefaultMutableTreeNode.
childIndex | the index of the child to remove |
std::out_of_range | if childIndex is out of bounds |
References children, end(), getChildAt(), and setLengthsUpToDate().
void evio::BaseStructure::remove | ( | const std::shared_ptr< BaseStructure > | aChild | ) |
Removes aChild
from this node's child vector, giving it a null parent.
Originally part of java's DefaultMutableTreeNode.
aChild | a child of this node to remove |
EvioException | if aChild is not a child of this node |
References getIndex(), and isNodeChild().
void evio::BaseStructure::removeAllChildren | ( | ) |
Removes all of this node's children, setting their parents to null.
If this node has no children, this method does nothing. Originally part of java's DefaultMutableTreeNode.
References getChildCount().
Referenced by setAllowsChildren().
void evio::BaseStructure::removeFromParent | ( | ) |
Removes the subtree rooted at this node from the tree, giving this node a null parent.
Does nothing if this node is the root of its tree. Originally part of java's DefaultMutableTreeNode.
References getParent(), and getThis().
uint32_t evio::BaseStructure::setAllHeaderLengths | ( | ) |
Compute and set length of all header fields for this structure and all its descendants.
For writing events, this will be crucial for setting the values in the headers.
EvioException | if the length is too large. |
References children, dataLength(), header, isLeaf(), lengthsUpToDate, and setLengthsUpToDate().
Referenced by updateCharData(), updateCompositeData(), updateDoubleData(), updateFloatData(), updateIntData(), updateLongData(), updateShortData(), updateStringData(), updateUCharData(), updateUIntData(), updateULongData(), and updateUShortData().
void evio::BaseStructure::setAllowsChildren | ( | bool | allows | ) |
Determines whether or not this node is allowed to have children.
If allows
is false, all of this node's children are removed. Originally part of java's DefaultMutableTreeNode.
Note: By default, a node allows children.
allows | true if this node is allowed to have children. |
References allowsChildren, and removeAllChildren().
void evio::BaseStructure::setByteOrder | ( | ByteOrder const & | order | ) |
Set the byte order of this data.
This method cannot be used to swap data. It is only used to describe the endianness of the rawdata contained.
order | ByteOrder#ENDIAN_BIG or ByteOrder#ENDIAN_LITTLE. |
References byteOrder.
|
protected |
Set whether the lengths of all header fields for this structure and all it descendants are up to date or not.
lenUpToDate | are the lengths of all header fields for this structure and all it descendants up to date or not. |
References lengthsUpToDate, and parent.
Referenced by insert(), remove(), setAllHeaderLengths(), updateCharData(), updateCompositeData(), updateDoubleData(), updateFloatData(), updateIntData(), updateLongData(), updateShortData(), updateStringData(), updateUCharData(), updateUIntData(), updateULongData(), and updateUShortData().
|
protected |
Sets this node's parent to newParent
but does not change the parent's child array.
This method is called from insert and remove to reassign a child's parent, it should not be messaged from anywhere else. Originally part of java's DefaultMutableBaseStructure.
newParent | this node's new parent. |
References parent.
|
protected |
Set the data for the structure.
bytes | pointer to the data to be copied. |
len | number of bytes to be copied. |
References rawBytes.
|
protected |
|
protected |
This method transforms the internal vector of strings into internal rawBytes vector of evio format data not including header.
References header, numberDataItems, rawBytes, stringList, and evio::Util::stringsToRawSize().
Referenced by updateStringData().
|
static |
This method transforms a vector of strings into raw evio format data, not including header.
strings | vector of strings to transform. |
bytes | vector of bytes to contain evio formatted strings. |
References stringsToRawSize().
|
static |
This method returns the number of bytes in a raw evio format of the given string vector, not including header.
strings | vector of strings to size. |
Referenced by stringsToRawBytes().
|
static |
This method returns the number of bytes in a raw evio format of the given string vector, not including header.
str | vector of strings to size. |
|
virtual |
Obtain a string representation of the structure.
Reimplemented in evio::EvioEvent.
References children, getStructureType(), header, rawBytes, evio::StructureType::STRUCT_BANK, evio::StructureType::toString(), and evio::DataType::toString().
Referenced by treeToString().
void evio::BaseStructure::transform | ( | std::shared_ptr< BaseStructure > const & | structure | ) |
This method does a partial copy and is designed to help convert between banks, segments,and tagsegments in the StructureTransformer class (hence the name "transform").
It copies all the data from another BaseStructure object. Children are not copied in the deep clone way, but their references are added to this structure. It does not copy header data or the parent either.
structure | BaseStructure from which to copy data. |
References children, evio::DataType::getDataType(), evio::DataType::isStructure(), and lengthsUpToDate.
std::string evio::BaseStructure::treeToString | ( | std::string const & | indent | ) | const |
Recursive method to obtain a string representation of the entire tree structure rooted at this structure.
indent | string containing indentation for this structure. Generally called with "". |
References children, getChildCount(), isLeaf(), and toString().
uint32_t evio::BaseStructure::unpackRawBytesToStrings | ( | ) |
Extract string data from rawBytes array.
References badStringFormat, rawBytes, stringEnd, and stringList.
Referenced by getStringData(), and unpackRawBytesToStrings().
|
static |
This method extracts a vector of strings from bytes of raw evio string data.
bytes | raw evio string data. |
offset | offset into raw data array. |
strData | vector in which to place extracted strings. |
References unpackRawBytesToStrings().
|
static |
This method extracts a vector of strings from bytes of raw evio string data.
Don't go beyond the specified max character limit and stop at the first non-character value.
bytes | raw evio string data. |
offset | offset into raw data vector. |
maxLength | max length in bytes of valid data in bytes vector. |
strData | vector in which to place extracted strings. |
|
static |
This method extracts a vector of strings from bytes of raw evio string data.
Don't go beyond the specified max character limit and stop at the first non-character value.
bytes | raw evio string data. |
length | length in bytes of valid data at bytes pointer. |
strData | vector in which to place extracted strings. |
|
static |
This method extracts a vector of strings from buffer containing raw evio string data.
buffer | buffer containing evio string data. |
pos | position of string data in buffer. |
length | length of string data in buffer in bytes. |
strData | vector in which to place extracted strings. |
References evio::ByteBuffer::array(), and evio::ByteBuffer::arrayOffset().
void evio::BaseStructure::updateCharData | ( | ) |
If data in this structure was changed by modifying the vector returned from getCharData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References evio::DataType::CHAR8, charData, header, numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), and evio::DataType::toString().
void evio::BaseStructure::updateCompositeData | ( | ) |
If data in this structure was changed by modifying the vector returned from getCompositeData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::DataType::COMPOSITE, compositeData, evio::CompositeData::generateRawBytes(), header, numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), and evio::DataType::toString().
void evio::BaseStructure::updateDoubleData | ( | ) |
If data in this structure was changed by modifying the vector returned from getDoubleData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::ByteOrder::byteSwap64(), evio::DataType::DOUBLE64, doubleData, header, evio::ByteOrder::needToSwap(), numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), and evio::DataType::toString().
void evio::BaseStructure::updateFloatData | ( | ) |
If data in this structure was changed by modifying the vector returned from getFloatData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::ByteOrder::byteSwap32(), evio::DataType::FLOAT32, floatData, header, evio::ByteOrder::needToSwap(), numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), and evio::DataType::toString().
void evio::BaseStructure::updateIntData | ( | ) |
If data in this structure was changed by modifying the vector returned from getIntData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::ByteOrder::byteSwap32(), header, evio::DataType::INT32, intData, evio::ByteOrder::needToSwap(), numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), and evio::DataType::toString().
void evio::BaseStructure::updateLongData | ( | ) |
If data in this structure was changed by modifying the vector returned from getLongData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::ByteOrder::byteSwap64(), header, evio::DataType::LONG64, longData, evio::ByteOrder::needToSwap(), numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), and evio::DataType::toString().
void evio::BaseStructure::updateShortData | ( | ) |
If data in this structure was changed by modifying the vector returned from getShortData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::ByteOrder::byteSwap16(), header, evio::ByteOrder::needToSwap(), numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), evio::DataType::SHORT16, shortData, and evio::DataType::toString().
void evio::BaseStructure::updateStringData | ( | ) |
If data in this structure was changed by modifying the vector returned from getStringData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References evio::DataType::CHARSTAR8, header, setAllHeaderLengths(), setLengthsUpToDate(), stringsToRawBytes(), and evio::DataType::toString().
void evio::BaseStructure::updateUCharData | ( | ) |
If data in this structure was changed by modifying the vector returned from getUCharData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References header, numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), evio::DataType::toString(), evio::DataType::UCHAR8, and ucharData.
void evio::BaseStructure::updateUIntData | ( | ) |
If data in this structure was changed by modifying the vector returned from getUIntData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::ByteOrder::byteSwap32(), header, evio::ByteOrder::needToSwap(), numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), evio::DataType::toString(), evio::DataType::UINT32, and uintData.
void evio::BaseStructure::updateULongData | ( | ) |
If data in this structure was changed by modifying the vector returned from getULongData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::ByteOrder::byteSwap64(), header, evio::ByteOrder::needToSwap(), numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), evio::DataType::toString(), evio::DataType::ULONG64, and ulongData.
void evio::BaseStructure::updateUShortData | ( | ) |
If data in this structure was changed by modifying the vector returned from getUShortData(), then this method needs to be called in order to make this object internally consistent.
EvioException | if this object corresponds to a different data type. |
References byteOrder, evio::ByteOrder::byteSwap16(), header, evio::ByteOrder::needToSwap(), numberDataItems, rawBytes, setAllHeaderLengths(), setLengthsUpToDate(), evio::DataType::toString(), evio::DataType::USHORT16, and ushortData.
void evio::BaseStructure::visitAllStructures | ( | std::shared_ptr< IEvioListener > | listener | ) |
Visit all the structures in this structure (including the structure itself – which is considered its own descendant).
This is similar to listening to the event as it is being parsed, but is done to a complete (already) parsed event.
listener | a listener to notify as each structure is visited. |
References getThis().
Referenced by getMatchingStructures().
void evio::BaseStructure::visitAllStructures | ( | std::shared_ptr< IEvioListener > | listener, |
std::shared_ptr< IEvioFilter > | filter | ||
) |
Visit all the structures in this structure (including the structure itself – which is considered its own descendant) in a depth first manner.
listener | a listener to notify as each structure is visited. |
filter | an optional filter that must "accept" structures before they are passed to the listener. If null , all structures are passed. In this way, specific types of structures can be captured. |
References getThis().
size_t evio::BaseStructure::write | ( | ByteBuffer & | byteBuffer | ) |
Write myself out into a byte buffer with fastest algorithm I could find.
byteBuffer | the byteBuffer to write to. |
overflow_error | if too little space in byteBuffer. |
References evio::ByteBuffer::array(), evio::ByteBuffer::arrayOffset(), getTotalBytes(), evio::ByteBuffer::order(), evio::ByteBuffer::position(), and evio::ByteBuffer::remaining().
size_t evio::BaseStructure::write | ( | uint8_t * | dest, |
ByteOrder const & | order | ||
) |
Write myself out to a pointer.
dest | pointer at which to write evio format data of this bank. |
order | byte order in which to write. |
References byteOrder, evio::ByteOrder::byteSwap16(), evio::ByteOrder::byteSwap32(), evio::ByteOrder::byteSwap64(), evio::DataType::CHAR8, charData, evio::DataType::CHARSTAR8, children, evio::DataType::COMPOSITE, evio::DataType::DOUBLE64, doubleData, evio::DataType::FLOAT32, floatData, header, evio::DataType::INT32, intData, isLeaf(), evio::ByteOrder::isLocalEndian(), evio::DataType::LONG64, longData, rawBytes, evio::DataType::SHORT16, shortData, evio::CompositeData::swapAll(), evio::DataType::UCHAR8, evio::DataType::UINT32, evio::DataType::ULONG64, evio::DataType::UNKNOWN32, and evio::DataType::USHORT16.
size_t evio::BaseStructure::writeQuick | ( | uint8_t * | dest | ) |
Write myself out as evio format data in the data's current byte order given by getByteOrder() at the given pointer.
This method is much more efficient than using write(uint8_t *, ByteOrder const &).
However, be warned that this method is only useful when this structure has just been read from a file or buffer. Once the user adds data (and does not call the appropriate update method) or children to this structure, this method does NOT produce correct results.
dest | pointer at which to write evio format data of this bank in currently set byte order. |
size_t evio::BaseStructure::writeQuick | ( | ByteBuffer & | dest | ) |
Write myself into a ByteBuffer as evio format data in the data's current byte order given by getByteOrder().
This method is much more efficient than using write(ByteBuffer &).
However, be warned that this method is only useful when this structure has just been read from a file or buffer. Once the user adds data (and does not call the appropriate update method) or children to this structure, this method does NOT produce correct results.
dest | destination ByteBuffer to contain evio format data of this bank in currently set byte order. |
References getByteOrder(), header, evio::ByteBuffer::order(), evio::ByteBuffer::put(), and rawBytes.
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
True if the node is able to have children.
Referenced by BaseStructure(), getAllowsChildren(), insert(), operator=(), and setAllowsChildren().
|
protected |
True if char data has non-ascii or non-printable characters, or has too little data to be in proper format.
Referenced by BaseStructure(), operator=(), and unpackRawBytesToStrings().
|
protected |
Endianness of the raw data if appropriate.
Initialize to local endian.
Referenced by BaseStructure(), getByteOrder(), getCompositeData(), needSwap(), operator=(), setByteOrder(), updateCompositeData(), updateDoubleData(), updateFloatData(), updateIntData(), updateLongData(), updateShortData(), updateUIntData(), updateULongData(), updateUShortData(), write(), and writeQuick().
|
protected |
Used if raw data should be interpreted as signed chars.
The reason rawBytes is not used directly is because it may be padded and it may not, depending on whether this object was created by EvioReader or by EventBuilder, etc., etc. We don't want to return rawBytes when a user calls getCharData() if there are padding bytes in it.
Referenced by BaseStructure(), getCharData(), operator=(), updateCharData(), and write().
|
protected |
Array of children, may be null if this node has no children.
Referenced by BaseStructure(), childrenBegin(), childrenEnd(), getChildAt(), getChildCount(), getChildren(), getIndex(), insert(), operator=(), remove(), setAllHeaderLengths(), evio::EvioEvent::toString(), toString(), transform(), treeToString(), and write().
|
protected |
Used if raw data should be interpreted as composite type.
Referenced by BaseStructure(), getCompositeData(), getNumberDataItems(), operator=(), and updateCompositeData().
|
protected |
Used if raw data should be interpreted as doubles.
Referenced by BaseStructure(), getDoubleData(), operator=(), updateDoubleData(), and write().
|
protected |
Used if raw data should be interpreted as floats.
Referenced by BaseStructure(), getFloatData(), operator=(), updateFloatData(), and write().
|
protected |
Holds the header of the bank as a shared pointer.
Referenced by BaseStructure(), dataLength(), getCharData(), getCompositeData(), getDoubleData(), getFloatData(), getHeader(), getIntData(), getLongData(), getNumberDataItems(), getShortData(), getStringData(), getTotalBytes(), getUCharData(), getUIntData(), getULongData(), getUShortData(), isContainer(), operator=(), setAllHeaderLengths(), stringsToRawBytes(), evio::EvioEvent::toString(), toString(), updateCharData(), updateCompositeData(), updateDoubleData(), updateFloatData(), updateIntData(), updateLongData(), updateShortData(), updateStringData(), updateUCharData(), updateUIntData(), updateULongData(), updateUShortData(), write(), and writeQuick().
|
protected |
Used if raw data should be interpreted as ints.
Referenced by BaseStructure(), getIntData(), operator=(), updateIntData(), and write().
|
protected |
Keep track of whether header length data is up-to-date or not.
Referenced by BaseStructure(), getLengthsUpToDate(), operator=(), setAllHeaderLengths(), setLengthsUpToDate(), and transform().
|
protected |
Used if raw data should be interpreted as longs.
Referenced by BaseStructure(), getLongData(), operator=(), updateLongData(), and write().
|
protected |
The number of stored data items like number of banks, ints, floats, etc.
(not the size in ints or bytes). Some items may be padded such as shorts and bytes. This will tell the meaningful number of such data items. In other words, no padding is included. In the case of containers, returns number of bytes not in header.
Referenced by BaseStructure(), getNumberDataItems(), operator=(), stringsToRawBytes(), updateCharData(), updateCompositeData(), updateDoubleData(), updateFloatData(), updateIntData(), updateLongData(), updateShortData(), updateUCharData(), updateUIntData(), updateULongData(), and updateUShortData().
|
protected |
This node's parent, or null if this node has no parent.
Referenced by BaseStructure(), getParent(), operator=(), setLengthsUpToDate(), and setParent().
|
protected |
The raw data of the structure.
May contain padding.
Referenced by BaseStructure(), dataLength(), getCharData(), getCompositeData(), getDoubleData(), getFloatData(), getIntData(), getLongData(), getNumberDataItems(), getRawBytes(), getShortData(), getStringData(), getUCharData(), getUIntData(), getULongData(), getUShortData(), operator=(), setRawBytes(), stringsToRawBytes(), evio::EvioEvent::toString(), toString(), unpackRawBytesToStrings(), updateCharData(), updateCompositeData(), updateDoubleData(), updateFloatData(), updateIntData(), updateLongData(), updateShortData(), updateUCharData(), updateUIntData(), updateULongData(), updateUShortData(), write(), and writeQuick().
|
protected |
Used if raw data should be interpreted as shorts.
Referenced by BaseStructure(), getShortData(), operator=(), updateShortData(), and write().
|
protected |
Keep track of end of the last string added to stringData (including null but not padding).
Referenced by BaseStructure(), operator=(), and unpackRawBytesToStrings().
|
protected |
Used if raw data should be interpreted as a string.
Referenced by BaseStructure(), getStringData(), operator=(), stringsToRawBytes(), and unpackRawBytesToStrings().
|
protected |
Used if raw data should be interpreted as unsigned chars.
Referenced by BaseStructure(), getUCharData(), operator=(), and updateUCharData().
|
protected |
Used if raw data should be interpreted as unsigned ints.
Referenced by BaseStructure(), getUIntData(), operator=(), and updateUIntData().
|
protected |
Used if raw data should be interpreted as unsigned longs.
Referenced by BaseStructure(), getULongData(), operator=(), and updateULongData().
|
protected |
Used if raw data should be interpreted as unsigned shorts.
Referenced by BaseStructure(), getUShortData(), operator=(), and updateUShortData().