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

This holds a CODA TagSegment structure. More...

#include <EvioTagSegment.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

StructureType getStructureType () const override
 This implements the virtual method from BaseStructure. More...
 
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< BaseStructuregetThis ()
 
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...
 
void remove (const std::shared_ptr< BaseStructure > aChild)
 Removes aChild from this node's child vector, giving it a null parent. More...
 
std::shared_ptr< BaseStructuregetParent () 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< BaseStructuregetChildAt (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 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< BaseStructuregetSharedAncestor (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< BaseStructuregetRoot ()
 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< BaseStructuregetNextNode ()
 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< BaseStructuregetPreviousNode ()
 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< BaseStructuregetFirstChild () const
 Returns this node's first child. More...
 
std::shared_ptr< BaseStructuregetLastChild () const
 Returns this node's last child. More...
 
std::shared_ptr< BaseStructuregetChildAfter (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< BaseStructuregetChildBefore (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< BaseStructuregetNextSibling ()
 Returns the next sibling of this node in the parent's children vector. More...
 
std::shared_ptr< BaseStructuregetPreviousSibling ()
 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< BaseStructuregetFirstLeaf ()
 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< BaseStructuregetLastLeaf ()
 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< BaseStructuregetNextLeaf ()
 Returns the leaf after this node or null if this node is the last leaf in the tree. More...
 
std::shared_ptr< BaseStructuregetPreviousLeaf ()
 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...
 
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 std::shared_ptr
< EvioTagSegment
getInstance (std::shared_ptr< TagSegmentHeader > const &head)
 Method to return a shared pointer to a constructed object of this class. More...
 
static std::shared_ptr
< EvioTagSegment
getInstance (uint16_t tag, DataType const &typ)
 Method to return a shared pointer to a constructed object of this class. 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...
 
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...
 

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...
 
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< BaseStructureparent = 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...
 

Detailed Description

This holds a CODA TagSegment structure.

Mostly it has a header (a TagSegementHeader) and the raw data stored as a vector.

Author
heddle
timmer

Member Typedef Documentation

typedef std::ptrdiff_t evio::BaseStructure::difference_type
inherited
typedef nodeIterator<std::shared_ptr<BaseStructure> > evio::BaseStructure::iterator
inherited
typedef std::input_iterator_tag evio::BaseStructure::iterator_category
inherited
typedef std::shared_ptr<BaseStructure> evio::BaseStructure::pointer
inherited
typedef std::shared_ptr<BaseStructure> evio::BaseStructure::reference
inherited
typedef size_t evio::BaseStructure::size_type
inherited
typedef std::shared_ptr<BaseStructure> evio::BaseStructure::value_type
inherited

Member Function Documentation

void evio::BaseStructure::add ( std::shared_ptr< BaseStructure newChild)
inherited

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.

See Also
insert
Parameters
newChildnode to add as a child of this node.
Exceptions
EvioExceptionif newChild is null, or this node does not allow children.

References evio::BaseStructure::getChildCount(), evio::BaseStructure::getThis(), and evio::BaseStructure::insert().

breadth_iterator evio::BaseStructure::bbegin ( )
inlineinherited

Get the beginning breadth-first iterator.

Returns
beginning breadth-first iterator.

References evio::BaseStructure::getThis().

Referenced by evio::BaseStructure::getDepth(), and evio::BaseStructure::getLeafCount().

iterator evio::BaseStructure::begin ( )
inlineinherited

Get the beginning depth-first iterator.

Returns
beginning depth-first iterator.

References evio::BaseStructure::getThis().

breadth_iterator evio::BaseStructure::bend ( )
inlineinherited

Get the end breadth-first iterator.

Returns
end breadth-first iterator.

References evio::BaseStructure::getThis().

Referenced by evio::BaseStructure::getDepth(), and evio::BaseStructure::getLeafCount().

std::vector< std::shared_ptr< BaseStructure > >::iterator evio::BaseStructure::childrenBegin ( )
inherited

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.

Returns
a begin iterator of this node's children.

References evio::BaseStructure::children.

std::vector< std::shared_ptr< BaseStructure > >::iterator evio::BaseStructure::childrenEnd ( )
inherited

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.

Returns
an end iterator of this node's children.

References evio::BaseStructure::children.

uint32_t evio::BaseStructure::dataLength ( )
protectedinherited

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;

Returns
the amount of 32-bit words (ints) needed by a leaf of primitives, else 0.

References evio::DataType::CHAR8, evio::DataType::CHARSTAR8, evio::DataType::COMPOSITE, evio::DataType::getBytes(), evio::BaseStructure::getNumberDataItems(), evio::BaseStructure::header, evio::BaseStructure::isLeaf(), evio::BaseStructure::rawBytes, evio::DataType::UCHAR8, and evio::DataType::UNKNOWN32.

Referenced by evio::BaseStructure::setAllHeaderLengths().

iterator evio::BaseStructure::end ( )
inlineinherited

Get the end depth-first iterator.

Returns
end depth-first iterator.

References evio::BaseStructure::getThis().

Referenced by evio::BaseStructure::getIndex(), and evio::BaseStructure::remove().

bool evio::BaseStructure::getAllowsChildren ( ) const
inherited

Returns true if this node is allowed to have children.

Originally part of java's DefaultMutableTreeNode.

Returns
true if this node allows children, else false.

References evio::BaseStructure::allowsChildren.

ByteOrder evio::BaseStructure::getByteOrder ( )
inherited

What is the byte order of this data?

Returns
ByteOrder#ENDIAN_BIG or ByteOrder#ENDIAN_LITTLE.

References evio::BaseStructure::byteOrder.

Referenced by evio::BaseStructure::writeQuick().

std::vector< signed char > & evio::BaseStructure::getCharData ( )
inherited

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!

Returns
the data as an signed char vector, or null if this makes no sense for the given contents type.

References evio::DataType::CHAR8, evio::BaseStructure::charData, evio::BaseStructure::header, and evio::BaseStructure::rawBytes.

std::shared_ptr< BaseStructure > evio::BaseStructure::getChildAfter ( const std::shared_ptr< BaseStructure aChild)
inherited

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.

See Also
children
Parameters
aChildchild of this node which immediately precedes the returned child structure.
Exceptions
EvioExceptionif aChild is null or is not a child of this node.
Returns
the child of this node that immediately follows aChild.

References evio::BaseStructure::getChildAt(), evio::BaseStructure::getChildCount(), and evio::BaseStructure::getIndex().

std::shared_ptr< BaseStructure > evio::BaseStructure::getChildAt ( size_t  index) const
inherited

Returns the child at the specified index in this node's child vector.

Originally part of java's DefaultMutableTreeNode.

Parameters
indexan index into this node's child array.
Exceptions
std::out_of_rangeif index is out of bounds.
Returns
the BaseStructure in this node's child array at the specified index.

References evio::BaseStructure::children.

Referenced by evio::BaseStructure::getChildAfter(), evio::BaseStructure::getChildBefore(), evio::BaseStructure::getFirstChild(), evio::BaseStructure::getLastChild(), evio::BaseStructure::getNextNode(), and evio::BaseStructure::remove().

std::shared_ptr< BaseStructure > evio::BaseStructure::getChildBefore ( const std::shared_ptr< BaseStructure aChild)
inherited

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.

Parameters
aChildchild of this node which comes immediately after the returned child structure.
Exceptions
EvioExceptionif aChild is null or is not a child of this node.
Returns
the child of this node that immediately precedes aChild.

References evio::BaseStructure::getChildAt(), and evio::BaseStructure::getIndex().

size_t evio::BaseStructure::getChildCount ( ) const
inherited
std::vector< std::shared_ptr< BaseStructure > > evio::BaseStructure::getChildren ( ) const
inherited

Get the children of this structure.

Returns
the children of this structure.

References evio::BaseStructure::children.

std::vector< std::shared_ptr< CompositeData > > & evio::BaseStructure::getCompositeData ( )
inherited

Gets the composite data as an vector of CompositeData objects, if the content type as indicated by the header is appropriate.

Returns
the data as a vector of CompositeData objects, or null if this makes no sense for the given content type.
Exceptions
EvioExceptionif the data is internally inconsistent.

References evio::BaseStructure::byteOrder, evio::DataType::COMPOSITE, evio::BaseStructure::compositeData, evio::BaseStructure::header, evio::CompositeData::parse(), and evio::BaseStructure::rawBytes.

uint32_t evio::BaseStructure::getDepth ( )
inherited

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.

See Also
getLevel
Exceptions
EvioExceptionif internal logic error.
Returns
the depth of the tree whose root is this node.

References evio::BaseStructure::bbegin(), evio::BaseStructure::bend(), and evio::BaseStructure::getLevel().

std::vector< double > & evio::BaseStructure::getDoubleData ( )
inherited

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!

Returns
a reference to the data as a double vector.
Exceptions
EvioExceptionif contained data type is not double.

References evio::DataType::DOUBLE64, evio::BaseStructure::doubleData, evio::BaseStructure::header, evio::BaseStructure::needSwap(), evio::BaseStructure::rawBytes, and SWAP_64.

std::shared_ptr< BaseStructure > evio::BaseStructure::getFirstChild ( ) const
inherited

Returns this node's first child.

If this node has no children, throws EvioException. Originally part of java's DefaultMutableTreeNode.

Returns
the first child of this node
Exceptions
EvioExceptionif this node has no children.

References evio::BaseStructure::getChildAt(), and evio::BaseStructure::getChildCount().

std::shared_ptr< BaseStructure > evio::BaseStructure::getFirstLeaf ( )
inherited

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.

See Also
isLeaf
isNodeDescendant
Returns
the first leaf in the subtree rooted at this node.

References evio::BaseStructure::getThis().

std::vector< float > & evio::BaseStructure::getFloatData ( )
inherited

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!

Returns
a reference to the data as a float vector.
Exceptions
EvioExceptionif contained data type is not float.

References evio::DataType::FLOAT32, evio::BaseStructure::floatData, evio::BaseStructure::header, evio::BaseStructure::needSwap(), evio::BaseStructure::rawBytes, and SWAP_32.

std::shared_ptr< BaseStructureHeader > evio::BaseStructure::getHeader ( ) const
inherited

Return the header for this structure.

Returns
the header for this structure.

References evio::BaseStructure::header.

ssize_t evio::BaseStructure::getIndex ( const std::shared_ptr< BaseStructure aChild)
inherited

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.

Parameters
aChildthe BaseStructure to search for among this node's children.
Exceptions
EvioExceptionif aChild is null.
Returns
an int giving the index of the node in this node's child array, or -1 if the specified node is a not a child of this node.

References evio::BaseStructure::children, evio::BaseStructure::end(), and evio::BaseStructure::isNodeChild().

Referenced by evio::BaseStructure::getChildAfter(), evio::BaseStructure::getChildBefore(), and evio::BaseStructure::remove().

static std::shared_ptr<EvioTagSegment> evio::EvioTagSegment::getInstance ( std::shared_ptr< TagSegmentHeader > const &  head)
inlinestatic

Method to return a shared pointer to a constructed object of this class.

Parameters
headtagsegment header.
Returns
shared pointer to new EvioTagSegment.

Referenced by evio::EventBuilder::main(), and evio::StructureTransformer::transform().

static std::shared_ptr<EvioTagSegment> evio::EvioTagSegment::getInstance ( uint16_t  tag,
DataType const &  typ 
)
inlinestatic

Method to return a shared pointer to a constructed object of this class.

Parameters
tagtagsegment tag.
typtagsegment data type.
Returns
shared pointer to new EvioTagSegment.
std::vector< int32_t > & evio::BaseStructure::getIntData ( )
inherited

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!

Returns
a reference to the data as an int32_t vector.
Exceptions
EvioExceptionif contained data type is not int32_t.

References evio::BaseStructure::header, evio::DataType::INT32, evio::BaseStructure::intData, evio::BaseStructure::needSwap(), evio::BaseStructure::rawBytes, and SWAP_32.

std::shared_ptr< BaseStructure > evio::BaseStructure::getLastChild ( ) const
inherited

Returns this node's last child.

If this node has no children, throws EvioException. Originally part of java's DefaultMutableTreeNode.

Returns
the last child of this node.
Exceptions
EvioExceptionif this node has no children.

References evio::BaseStructure::getChildAt(), and evio::BaseStructure::getChildCount().

std::shared_ptr< BaseStructure > evio::BaseStructure::getLastLeaf ( )
inherited

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.

See Also
isLeaf
isNodeDescendant
Returns
the last leaf in the subtree rooted at this node.

References evio::BaseStructure::getThis().

ssize_t evio::BaseStructure::getLeafCount ( )
inherited

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.

See Also
isNodeAncestor
Exceptions
EvioExceptionif tree has zero leaves.
Returns
the number of leaves beneath this node.

References evio::BaseStructure::bbegin(), and evio::BaseStructure::bend().

bool evio::BaseStructure::getLengthsUpToDate ( ) const
protectedinherited

Get whether the lengths of all header fields for this structure and all it descendants are up to date or not.

Returns
whether the lengths of all header fields for this structure and all it descendants are up to date or not.

References evio::BaseStructure::lengthsUpToDate.

uint32_t evio::BaseStructure::getLevel ( ) const
inherited

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.

See Also
getDepth
Returns
the number of levels above this node.

References evio::BaseStructure::getThisConst().

Referenced by evio::BaseStructure::getDepth(), and evio::BaseStructure::getSharedAncestor().

std::vector< int64_t > & evio::BaseStructure::getLongData ( )
inherited

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!

Returns
a reference to the data as an int64_t vector.
Exceptions
EvioExceptionif contained data type is not int64_t.

References evio::BaseStructure::header, evio::DataType::LONG64, evio::BaseStructure::longData, evio::BaseStructure::needSwap(), evio::BaseStructure::rawBytes, and SWAP_64.

void evio::BaseStructure::getMatchingStructures ( std::shared_ptr< IEvioFilter filter,
std::vector< std::shared_ptr< BaseStructure >> &  vec 
)
inherited

Visit all the descendant structures, and collect those that pass a filter.

Parameters
filterthe filter that must be passed. If null, this will return all the structures.
vecvector provided to contain all structures that are accepted by the filter.

References evio::BaseStructure::visitAllStructures().

std::shared_ptr< BaseStructure > evio::BaseStructure::getNextLeaf ( )
inherited

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.

See Also
nodeIterator
isLeaf
Returns
returns the next leaf past this node.

References evio::BaseStructure::getNextSibling(), and evio::BaseStructure::getParent().

std::shared_ptr< BaseStructure > evio::BaseStructure::getNextNode ( )
inherited

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.

Returns
the node that follows this node in a preorder traversal, or null if this node is last.

References evio::BaseStructure::getChildAt(), evio::BaseStructure::getChildCount(), evio::BaseStructure::getNextSibling(), and evio::BaseStructure::getParent().

std::shared_ptr< BaseStructure > evio::BaseStructure::getNextSibling ( )
inherited

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.

See Also
children.
Exceptions
EvioExceptionif child of parent is not a sibling.
Returns
the sibling of this node that immediately follows this node.

References evio::BaseStructure::getParent(), evio::BaseStructure::getThis(), and evio::BaseStructure::isNodeSibling().

Referenced by evio::BaseStructure::getNextLeaf(), and evio::BaseStructure::getNextNode().

uint32_t evio::BaseStructure::getNumberDataItems ( )
inherited

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.

Returns
number of stored data items (not size or length), or number of words if container.

References evio::DataType::CHARSTAR8, evio::DataType::COMPOSITE, evio::BaseStructure::compositeData, evio::DataType::getBytes(), evio::BaseStructure::getStringData(), evio::BaseStructure::header, evio::BaseStructure::isContainer(), evio::BaseStructure::numberDataItems, and evio::BaseStructure::rawBytes.

Referenced by evio::BaseStructure::dataLength().

std::shared_ptr< BaseStructure > evio::BaseStructure::getParent ( ) const
inherited
std::vector< std::shared_ptr< BaseStructure > > evio::BaseStructure::getPath ( )
inherited

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.

Returns
an vector of BaseStructure shared pointer giving the path, where the first element in the path is the root and the last element is this node.

References evio::BaseStructure::getPathToRoot(), and evio::BaseStructure::getThis().

std::vector< std::shared_ptr< BaseStructure > > evio::BaseStructure::getPathToRoot ( const std::shared_ptr< BaseStructure > &  aNode,
int  depth 
) const
protectedinherited

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.

Parameters
aNodethe BaseStructure to get the path for.
depthan int giving the number of steps already taken towards the root (on recursive calls), used to size the returned vector.
Returns
a vector of BaseStructure shared pointer giving the path from the root to the specified node.

Referenced by evio::BaseStructure::getPath().

std::shared_ptr< BaseStructure > evio::BaseStructure::getPreviousLeaf ( )
inherited

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.

See Also
nodeIterator
isLeaf
Returns
returns the leaf before this node.

References evio::BaseStructure::getParent(), and evio::BaseStructure::getPreviousSibling().

std::shared_ptr< BaseStructure > evio::BaseStructure::getPreviousNode ( )
inherited

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.

Returns
the node that precedes this node in a preorder traversal, or null if this node is the first.

References evio::BaseStructure::getParent(), and evio::BaseStructure::getPreviousSibling().

std::shared_ptr< BaseStructure > evio::BaseStructure::getPreviousSibling ( )
inherited

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.

Exceptions
EvioExceptionif child of parent is not a sibling.
Returns
the sibling of this node that immediately precedes this node.

References evio::BaseStructure::getParent(), evio::BaseStructure::getThis(), and evio::BaseStructure::isNodeSibling().

Referenced by evio::BaseStructure::getPreviousLeaf(), and evio::BaseStructure::getPreviousNode().

std::vector< uint8_t > & evio::BaseStructure::getRawBytes ( )
inherited

Get the raw data of the structure.

Returns
the raw data of the structure.

References evio::BaseStructure::rawBytes.

std::shared_ptr< BaseStructure > evio::BaseStructure::getRoot ( )
inherited

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.

See Also
isNodeAncestor
Returns
the root of the tree that contains this node.

References evio::BaseStructure::getThis().

Referenced by evio::BaseStructure::isNodeRelated().

std::shared_ptr< BaseStructure > evio::BaseStructure::getSharedAncestor ( std::shared_ptr< BaseStructure aNode)
inherited

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.

See Also
isNodeAncestor
isNodeDescendant
Parameters
aNodenode to find common ancestor with.
Exceptions
EvioExceptionif internal logic error.
Returns
nearest ancestor common to this node and aNode, or null if none.

References evio::BaseStructure::getLevel(), and evio::BaseStructure::getThis().

std::vector< int16_t > & evio::BaseStructure::getShortData ( )
inherited

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!

Returns
a reference to the data as an int16_t vector.
Exceptions
EvioExceptionif contained data type is not int16_t.

References evio::BaseStructure::header, evio::BaseStructure::needSwap(), evio::BaseStructure::rawBytes, evio::DataType::SHORT16, evio::BaseStructure::shortData, and SWAP_16.

size_t evio::BaseStructure::getSiblingCount ( ) const
inherited

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.

Returns
the number of siblings of this node.

References evio::BaseStructure::getParent().

std::vector< std::string > & evio::BaseStructure::getStringData ( )
inherited

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:

  • Each string IS immediately followed by an ending null (0).
  • All string data are further padded/ended with at least one 0x4 valued ASCII char (up to 4 possible).
  • The presence of 1 to 4 ending 4's distinguishes the recent string array version from the original, single string version.
  • The original version string may be padded with anything after its ending null.
Returns
the data as a vector of string objects if DataType is CHARSTAR8, or null if this makes no sense for the given type.

References evio::DataType::CHARSTAR8, evio::BaseStructure::header, evio::BaseStructure::rawBytes, evio::BaseStructure::stringList, and evio::BaseStructure::unpackRawBytesToStrings().

Referenced by evio::BaseStructure::getNumberDataItems().

StructureType evio::EvioTagSegment::getStructureType ( ) const
inlineoverridevirtual

This implements the virtual method from BaseStructure.

This returns the type of this structure, not the type of data this structure holds.

Returns
the StructureType of this structure, which is a StructureType::STRUCT_TAGSEGMENT.
See Also
StructureType

Reimplemented from evio::BaseStructure.

References evio::StructureType::STRUCT_TAGSEGMENT.

std::shared_ptr<const BaseStructure> evio::BaseStructure::getThisConst ( ) const
inlineinherited
uint32_t evio::BaseStructure::getTotalBytes ( ) const
inherited

Get the length of this structure in bytes, including the header.

Returns
the length of this structure in bytes, including the header.

References evio::BaseStructure::header.

Referenced by evio::BaseStructure::write().

std::vector< unsigned char > & evio::BaseStructure::getUCharData ( )
inherited

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!

Returns
the data as an unsigned char vector, or null if this makes no sense for the given contents type.

References evio::BaseStructure::header, evio::BaseStructure::rawBytes, evio::DataType::UCHAR8, and evio::BaseStructure::ucharData.

std::vector< uint32_t > & evio::BaseStructure::getUIntData ( )
inherited

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!

Returns
a reference to the data as an uint32_t vector.
Exceptions
EvioExceptionif contained data type is not uint32_t.

References evio::BaseStructure::header, evio::BaseStructure::needSwap(), evio::BaseStructure::rawBytes, SWAP_32, evio::DataType::UINT32, and evio::BaseStructure::uintData.

std::vector< uint64_t > & evio::BaseStructure::getULongData ( )
inherited

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!

Returns
a reference to the data as an uint64_t vector.
Exceptions
EvioExceptionif contained data type is not uint64_t.

References evio::BaseStructure::header, evio::BaseStructure::needSwap(), evio::BaseStructure::rawBytes, SWAP_64, evio::DataType::ULONG64, and evio::BaseStructure::ulongData.

std::vector< uint16_t > & evio::BaseStructure::getUShortData ( )
inherited

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!

Returns
a reference to the data as an uint16_t vector.
Exceptions
EvioExceptionif contained data type is not uint16_t.

References evio::BaseStructure::header, evio::BaseStructure::needSwap(), evio::BaseStructure::rawBytes, SWAP_16, evio::DataType::USHORT16, and evio::BaseStructure::ushortData.

void evio::BaseStructure::insert ( const std::shared_ptr< BaseStructure newChild,
size_t  childIndex 
)
inherited

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.

Parameters
newChildthe BaseStructure to insert under this node.
childIndexthe index in this node's child array. where this node is to be inserted.
Exceptions
std::out_of_rangeif childIndex is out of bounds.
EvioExceptionif newChild is null, is an ancestor of this node, or this node does not allow children.
See Also
isNodeDescendant

References evio::BaseStructure::allowsChildren, evio::BaseStructure::children, evio::BaseStructure::getThis(), evio::BaseStructure::isNodeAncestor(), and evio::BaseStructure::setLengthsUpToDate().

Referenced by evio::BaseStructure::add().

bool evio::BaseStructure::isContainer ( ) const
inherited

Checks whether this structure is a container, i.e.

a structure of structures.

Returns
true if this structure is a container. This is the same check as getAllowsChildren.

References evio::BaseStructure::header.

Referenced by evio::BaseStructure::getNumberDataItems().

bool evio::BaseStructure::isLeaf ( ) const
inherited

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.

See Also
getAllowsChildren
Returns
true if this node has no children.

References evio::BaseStructure::getChildCount().

Referenced by evio::BaseStructure::dataLength(), evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::treeToString(), and evio::BaseStructure::write().

bool evio::BaseStructure::isNodeAncestor ( const std::shared_ptr< BaseStructure anotherNode) const
inherited

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.

See Also
isNodeDescendant
getSharedAncestor
Parameters
anotherNodenode to test as an ancestor of this node
Returns
true if this node is a descendant of anotherNode

References evio::BaseStructure::getThisConst().

Referenced by evio::BaseStructure::insert().

bool evio::BaseStructure::isNodeChild ( const std::shared_ptr< BaseStructure aNode) const
inherited

Returns true if aNode is a child of this node.

If aNode is null, this method returns false. Originally part of java's DefaultMutableTreeNode.

Parameters
aNodestructure to test if it's a child of this one.
Returns
true if aNode is a child of this node; false if aNode is null.

References evio::BaseStructure::getChildCount(), and evio::BaseStructure::getThisConst().

Referenced by evio::BaseStructure::getIndex(), and evio::BaseStructure::remove().

bool evio::BaseStructure::isNodeDescendant ( std::shared_ptr< BaseStructure anotherNode)
inherited

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.

See Also
isNodeAncestor
getSharedAncestor
Parameters
anotherNodenode to test as descendant of this node
Returns
true if this node is an ancestor of anotherNode

References evio::BaseStructure::getThis().

bool evio::BaseStructure::isNodeRelated ( std::shared_ptr< BaseStructure aNode)
inherited

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.

See Also
getSharedAncestor
getRoot
Parameters
aNodestructure to test if it's in the same tree as this one.
Returns
true if aNode is in the same tree as this node; false if aNode is null

References evio::BaseStructure::getRoot().

bool evio::BaseStructure::isNodeSibling ( const std::shared_ptr< BaseStructure anotherNode) const
inherited

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.

Parameters
anotherNodenode to test as sibling of this node.
Exceptions
EvioExceptionif sibling has different parent.
Returns
true if anotherNode is a sibling of this node.

References evio::BaseStructure::getParent(), and evio::BaseStructure::getThisConst().

Referenced by evio::BaseStructure::getNextSibling(), and evio::BaseStructure::getPreviousSibling().

bool evio::BaseStructure::isRoot ( ) const
inherited

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.

Returns
true if this node is the root of its tree.

References evio::BaseStructure::getParent().

bool evio::BaseStructure::needSwap ( ) const
inherited
void evio::BaseStructure::remove ( size_t  childIndex)
inherited

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.

Parameters
childIndexthe index of the child to remove
Exceptions
std::out_of_rangeif childIndex is out of bounds

References evio::BaseStructure::children, evio::BaseStructure::end(), evio::BaseStructure::getChildAt(), and evio::BaseStructure::setLengthsUpToDate().

void evio::BaseStructure::remove ( const std::shared_ptr< BaseStructure aChild)
inherited

Removes aChild from this node's child vector, giving it a null parent.

Originally part of java's DefaultMutableTreeNode.

Parameters
aChilda child of this node to remove
Exceptions
EvioExceptionif aChild is not a child of this node

References evio::BaseStructure::getIndex(), and evio::BaseStructure::isNodeChild().

void evio::BaseStructure::removeAllChildren ( )
inherited

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 evio::BaseStructure::getChildCount().

Referenced by evio::BaseStructure::setAllowsChildren().

void evio::BaseStructure::removeFromParent ( )
inherited

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 evio::BaseStructure::getParent(), and evio::BaseStructure::getThis().

void evio::BaseStructure::setAllowsChildren ( bool  allows)
inherited

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.

Parameters
allowstrue if this node is allowed to have children.

References evio::BaseStructure::allowsChildren, and evio::BaseStructure::removeAllChildren().

void evio::BaseStructure::setByteOrder ( ByteOrder const &  order)
inherited

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.

Parameters
orderByteOrder#ENDIAN_BIG or ByteOrder#ENDIAN_LITTLE.

References evio::BaseStructure::byteOrder.

void evio::BaseStructure::setParent ( const std::shared_ptr< BaseStructure > &  newParent)
protectedinherited

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.

Parameters
newParentthis node's new parent.

References evio::BaseStructure::parent.

void evio::BaseStructure::setRawBytes ( uint8_t *  bytes,
uint32_t  len 
)
protectedinherited

Set the data for the structure.

Parameters
bytespointer to the data to be copied.
lennumber of bytes to be copied.

References evio::BaseStructure::rawBytes.

void evio::BaseStructure::setRawBytes ( std::vector< uint8_t > &  bytes)
protectedinherited

Set the data for the structure.

Parameters
bytesvector of data to be copied.

References evio::BaseStructure::rawBytes.

void evio::BaseStructure::stringsToRawBytes ( )
protectedinherited

This method transforms the internal vector of strings into internal rawBytes vector of evio format data not including header.

References evio::BaseStructure::header, evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::stringList, and evio::Util::stringsToRawSize().

Referenced by evio::BaseStructure::updateStringData().

void evio::BaseStructure::stringsToRawBytes ( std::vector< std::string > &  strings,
std::vector< uint8_t > &  bytes 
)
staticinherited

This method transforms a vector of strings into raw evio format data, not including header.

Parameters
stringsvector of strings to transform.
bytesvector of bytes to contain evio formatted strings.

References evio::BaseStructure::stringsToRawSize().

uint32_t evio::BaseStructure::stringsToRawSize ( std::vector< std::string > const &  strings)
staticinherited

This method returns the number of bytes in a raw evio format of the given string vector, not including header.

Parameters
stringsvector of strings to size.
Returns
the number of bytes in a raw evio format of the given strings.
0 if vector empty.

Referenced by evio::BaseStructure::stringsToRawBytes().

uint32_t evio::BaseStructure::stringToRawSize ( const std::string &  str)
staticinherited

This method returns the number of bytes in a raw evio format of the given string vector, not including header.

Parameters
strvector of strings to size.
Returns
the number of bytes in a raw evio format of the given strings.
0 if vector empty.
std::string evio::BaseStructure::toString ( ) const
virtualinherited
void evio::BaseStructure::transform ( std::shared_ptr< BaseStructure > const &  structure)
inherited

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.

Parameters
structureBaseStructure from which to copy data.

References evio::BaseStructure::children, evio::DataType::getDataType(), evio::DataType::isStructure(), and evio::BaseStructure::lengthsUpToDate.

std::string evio::BaseStructure::treeToString ( std::string const &  indent) const
inherited

Recursive method to obtain a string representation of the entire tree structure rooted at this structure.

Parameters
indentstring containing indentation for this structure. Generally called with "".
Returns
a string representation of the entire tree structure rooted at this structure.

References evio::BaseStructure::children, evio::BaseStructure::getChildCount(), evio::BaseStructure::isLeaf(), and evio::BaseStructure::toString().

uint32_t evio::BaseStructure::unpackRawBytesToStrings ( )
inherited
void evio::BaseStructure::unpackRawBytesToStrings ( std::vector< uint8_t > &  bytes,
size_t  offset,
std::vector< std::string > &  strData 
)
staticinherited

This method extracts a vector of strings from bytes of raw evio string data.

Parameters
bytesraw evio string data.
offsetoffset into raw data array.
strDatavector in which to place extracted strings.

References evio::BaseStructure::unpackRawBytesToStrings().

void evio::BaseStructure::unpackRawBytesToStrings ( std::vector< uint8_t > &  bytes,
size_t  offset,
size_t  maxLength,
std::vector< std::string > &  strData 
)
staticinherited

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.

Parameters
bytesraw evio string data.
offsetoffset into raw data vector.
maxLengthmax length in bytes of valid data in bytes vector.
strDatavector in which to place extracted strings.
void evio::BaseStructure::unpackRawBytesToStrings ( uint8_t *  bytes,
size_t  length,
std::vector< std::string > &  strData 
)
staticinherited

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.

Parameters
bytesraw evio string data.
lengthlength in bytes of valid data at bytes pointer.
strDatavector in which to place extracted strings.
void evio::BaseStructure::unpackRawBytesToStrings ( ByteBuffer buffer,
size_t  pos,
size_t  length,
std::vector< std::string > &  strData 
)
staticinherited

This method extracts a vector of strings from buffer containing raw evio string data.

Parameters
bufferbuffer containing evio string data.
posposition of string data in buffer.
lengthlength of string data in buffer in bytes.
strDatavector in which to place extracted strings.

References evio::ByteBuffer::array(), and evio::ByteBuffer::arrayOffset().

void evio::BaseStructure::updateCharData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::DataType::CHAR8, evio::BaseStructure::charData, evio::BaseStructure::header, evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), and evio::DataType::toString().

void evio::BaseStructure::updateCompositeData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::DataType::COMPOSITE, evio::BaseStructure::compositeData, evio::CompositeData::generateRawBytes(), evio::BaseStructure::header, evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), and evio::DataType::toString().

void evio::BaseStructure::updateDoubleData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::ByteOrder::byteSwap64(), evio::DataType::DOUBLE64, evio::BaseStructure::doubleData, evio::BaseStructure::header, evio::ByteOrder::needToSwap(), evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), and evio::DataType::toString().

void evio::BaseStructure::updateFloatData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::ByteOrder::byteSwap32(), evio::DataType::FLOAT32, evio::BaseStructure::floatData, evio::BaseStructure::header, evio::ByteOrder::needToSwap(), evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), and evio::DataType::toString().

void evio::BaseStructure::updateIntData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::ByteOrder::byteSwap32(), evio::BaseStructure::header, evio::DataType::INT32, evio::BaseStructure::intData, evio::ByteOrder::needToSwap(), evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), and evio::DataType::toString().

void evio::BaseStructure::updateLongData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::ByteOrder::byteSwap64(), evio::BaseStructure::header, evio::DataType::LONG64, evio::BaseStructure::longData, evio::ByteOrder::needToSwap(), evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), and evio::DataType::toString().

void evio::BaseStructure::updateShortData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::ByteOrder::byteSwap16(), evio::BaseStructure::header, evio::ByteOrder::needToSwap(), evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), evio::DataType::SHORT16, evio::BaseStructure::shortData, and evio::DataType::toString().

void evio::BaseStructure::updateStringData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::DataType::CHARSTAR8, evio::BaseStructure::header, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), evio::BaseStructure::stringsToRawBytes(), and evio::DataType::toString().

void evio::BaseStructure::updateUCharData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::header, evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), evio::DataType::toString(), evio::DataType::UCHAR8, and evio::BaseStructure::ucharData.

void evio::BaseStructure::updateUIntData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::ByteOrder::byteSwap32(), evio::BaseStructure::header, evio::ByteOrder::needToSwap(), evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), evio::DataType::toString(), evio::DataType::UINT32, and evio::BaseStructure::uintData.

void evio::BaseStructure::updateULongData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::ByteOrder::byteSwap64(), evio::BaseStructure::header, evio::ByteOrder::needToSwap(), evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), evio::DataType::toString(), evio::DataType::ULONG64, and evio::BaseStructure::ulongData.

void evio::BaseStructure::updateUShortData ( )
inherited

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.

Exceptions
EvioExceptionif this object corresponds to a different data type.

References evio::BaseStructure::byteOrder, evio::ByteOrder::byteSwap16(), evio::BaseStructure::header, evio::ByteOrder::needToSwap(), evio::BaseStructure::numberDataItems, evio::BaseStructure::rawBytes, evio::BaseStructure::setAllHeaderLengths(), evio::BaseStructure::setLengthsUpToDate(), evio::DataType::toString(), evio::DataType::USHORT16, and evio::BaseStructure::ushortData.

void evio::BaseStructure::visitAllStructures ( std::shared_ptr< IEvioListener listener)
inherited

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.

Parameters
listenera listener to notify as each structure is visited.

References evio::BaseStructure::getThis().

Referenced by evio::BaseStructure::getMatchingStructures().

void evio::BaseStructure::visitAllStructures ( std::shared_ptr< IEvioListener listener,
std::shared_ptr< IEvioFilter filter 
)
inherited

Visit all the structures in this structure (including the structure itself – which is considered its own descendant) in a depth first manner.

Parameters
listenera listener to notify as each structure is visited.
filteran 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 evio::BaseStructure::getThis().

size_t evio::BaseStructure::write ( ByteBuffer byteBuffer)
inherited

Write myself out into a byte buffer with fastest algorithm I could find.

Parameters
byteBufferthe byteBuffer to write to.
Returns
the number of bytes written.
Exceptions
overflow_errorif too little space in byteBuffer.

References evio::ByteBuffer::array(), evio::ByteBuffer::arrayOffset(), evio::BaseStructure::getTotalBytes(), evio::ByteBuffer::order(), evio::ByteBuffer::position(), and evio::ByteBuffer::remaining().

size_t evio::BaseStructure::writeQuick ( uint8_t *  dest)
inherited

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.

Parameters
destpointer at which to write evio format data of this bank in currently set byte order.
Returns
the number of bytes written.

References evio::BaseStructure::byteOrder, evio::BaseStructure::header, and evio::BaseStructure::rawBytes.

size_t evio::BaseStructure::writeQuick ( ByteBuffer dest)
inherited

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.

Parameters
destdestination ByteBuffer to contain evio format data of this bank in currently set byte order.
Returns
the number of bytes written.

References evio::BaseStructure::getByteOrder(), evio::BaseStructure::header, evio::ByteBuffer::order(), evio::ByteBuffer::put(), and evio::BaseStructure::rawBytes.

Member Data Documentation

bool evio::BaseStructure::allowsChildren = true
protectedinherited
bool evio::BaseStructure::badStringFormat = false
protectedinherited

True if char data has non-ascii or non-printable characters, or has too little data to be in proper format.

Referenced by evio::BaseStructure::BaseStructure(), evio::BaseStructure::operator=(), and evio::BaseStructure::unpackRawBytesToStrings().

std::vector<signed char> evio::BaseStructure::charData
protectedinherited

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 evio::BaseStructure::BaseStructure(), evio::BaseStructure::getCharData(), evio::BaseStructure::operator=(), evio::BaseStructure::updateCharData(), and evio::BaseStructure::write().

std::vector<std::shared_ptr<CompositeData> > evio::BaseStructure::compositeData
protectedinherited
std::vector<double> evio::BaseStructure::doubleData
protectedinherited
std::vector<float> evio::BaseStructure::floatData
protectedinherited
std::shared_ptr<BaseStructureHeader> evio::BaseStructure::header
protectedinherited
std::vector<int32_t> evio::BaseStructure::intData
protectedinherited
bool evio::BaseStructure::lengthsUpToDate = false
protectedinherited
std::vector<int64_t> evio::BaseStructure::longData
protectedinherited
size_t evio::BaseStructure::numberDataItems = 0
protectedinherited
std::shared_ptr<BaseStructure> evio::BaseStructure::parent = nullptr
protectedinherited
std::vector<int16_t> evio::BaseStructure::shortData
protectedinherited
int evio::BaseStructure::stringEnd = 0
protectedinherited

Keep track of end of the last string added to stringData (including null but not padding).

Referenced by evio::BaseStructure::BaseStructure(), evio::BaseStructure::operator=(), and evio::BaseStructure::unpackRawBytesToStrings().

std::vector<std::string > evio::BaseStructure::stringList
protectedinherited
std::vector<unsigned char> evio::BaseStructure::ucharData
protectedinherited
std::vector<uint32_t> evio::BaseStructure::uintData
protectedinherited
std::vector<uint64_t> evio::BaseStructure::ulongData
protectedinherited
std::vector<uint16_t> evio::BaseStructure::ushortData
protectedinherited

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