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

This the header for the base structure (BaseStructure). More...

#include <BaseStructureHeader.h>

Public Member Functions

 BaseStructureHeader ()=default
 
 BaseStructureHeader (uint16_t tag, DataType const &dataType, uint8_t num=0)
 Constructor. More...
 
virtual ~BaseStructureHeader ()=default
 
uint8_t getNumber () const
 Get the number. More...
 
void setNumber (uint8_t number)
 Set the number. More...
 
uint32_t getDataTypeValue () const
 Get the data type for the structure. More...
 
void setDataType (uint32_t type)
 Set the numeric data type for the structure. More...
 
void setDataType (DataType const &type)
 Set the numeric data type for the structure. More...
 
DataType getDataType () const
 Returns the data type for data stored in this structure as a DataType enum. More...
 
std::string getDataTypeName () const
 Returns the data type as a string. More...
 
uint8_t getPadding () const
 Get the amount of padding bytes when storing short or byte data. More...
 
uint32_t getLength () const
 Get the length of the structure in 32 bit ints, not counting the length word. More...
 
void setLength (uint32_t len)
 Set the length of the structure in 32 bit ints, not counting the length word. More...
 
uint16_t getTag () const
 Get the structure tag. More...
 
void setTag (uint16_t tag)
 Set the structure tag. More...
 
virtual uint32_t getDataLength ()
 Get the length of the structure's data in 32 bit ints (not counting the header words). More...
 
virtual uint32_t getHeaderLength ()
 Get the length of the structure's header in ints. More...
 
virtual std::string toString ()
 Obtain a string representation of the base structure header. More...
 
virtual size_t write (std::shared_ptr< ByteBuffer > &dest)
 Write myself out into a byte buffer. More...
 
virtual size_t write (ByteBuffer &dest)
 Write myself out into a byte buffer. More...
 
virtual size_t write (uint8_t *dest, ByteOrder const &order)
 Write myself out as evio format data into the given byte array in the specified byte order. More...
 

Protected Member Functions

void setPadding (uint8_t pad)
 Set the amount of padding bytes when storing short or byte data. More...
 
void copy (std::shared_ptr< BaseStructureHeader > head)
 Method to copy data from the fiven header to this one. More...
 

Protected Attributes

uint32_t length = 0
 The length of the structure in 32-bit words. More...
 
uint32_t tag = 0
 The structure tag. More...
 
DataType dataType {DataType::UNKNOWN32}
 The data type of the structure. More...
 
uint8_t padding = 0
 The amount of padding bytes when storing short or byte data. More...
 
uint8_t number = 0
 The number represents an unsigned byte. More...
 

Friends

class BaseStructure
 
class CompositeData
 
class EvioReader
 
class EvioReaderV4
 
class EventHeaderParser
 
class StructureTransformer
 

Detailed Description

This the header for the base structure (BaseStructure).

It does not contain the raw data, just the header. The three headers for the actual structures found in evio (BANK, SEGMENT, and TAGSEMENT) all extend this.

Author
heddle (original Java version)
timmer
Date
4/2/2020

Constructor & Destructor Documentation

◆ BaseStructureHeader() [1/2]

evio::BaseStructureHeader::BaseStructureHeader ( )
default

◆ BaseStructureHeader() [2/2]

evio::BaseStructureHeader::BaseStructureHeader ( uint16_t  tag,
DataType const &  dataType,
uint8_t  num = 0 
)

Constructor.

Parameters
tagthe tag for the header.
dataTypethe data type for the content of the structure.
numsometimes, but not necessarily, an ordinal enumeration.

References dataType, number, and tag.

◆ ~BaseStructureHeader()

virtual evio::BaseStructureHeader::~BaseStructureHeader ( )
virtualdefault

Member Function Documentation

◆ copy()

void evio::BaseStructureHeader::copy ( std::shared_ptr< BaseStructureHeader head)
protected

Method to copy data from the fiven header to this one.

Parameters
headheader to copy data from (source).

References dataType, length, number, padding, and tag.

◆ getDataLength()

virtual uint32_t evio::BaseStructureHeader::getDataLength ( )
inlinevirtual

Get the length of the structure's data in 32 bit ints (not counting the header words).

Returns
Get the length of the structure's data in 32 bit ints (not counting the header words).

Reimplemented in evio::TagSegmentHeader, evio::SegmentHeader, and evio::BankHeader.

◆ getDataType()

DataType evio::BaseStructureHeader::getDataType ( ) const

Returns the data type for data stored in this structure as a DataType enum.

Returns
the data type for data stored in this structure as a DataType enum.
See also
DataType

References dataType.

◆ getDataTypeName()

std::string evio::BaseStructureHeader::getDataTypeName ( ) const

Returns the data type as a string.

Returns
the data type as a string.

References dataType, and evio::DataType::getName().

Referenced by evio::BankHeader::toString(), evio::SegmentHeader::toString(), and evio::TagSegmentHeader::toString().

◆ getDataTypeValue()

uint32_t evio::BaseStructureHeader::getDataTypeValue ( ) const

Get the data type for the structure.

Returns
the data type for the structure.

References dataType, and evio::DataType::getValue().

◆ getHeaderLength()

virtual uint32_t evio::BaseStructureHeader::getHeaderLength ( )
inlinevirtual

Get the length of the structure's header in ints.

This includes the first header word itself (which contains the length) and in the case of banks, it also includes the second header word.

Returns
length of the structure's header in ints (2 for banks, 1 for segments and tagsegments).

Reimplemented in evio::TagSegmentHeader, evio::SegmentHeader, and evio::BankHeader.

◆ getLength()

uint32_t evio::BaseStructureHeader::getLength ( ) const

Get the length of the structure in 32 bit ints, not counting the length word.

Returns
Get the length of the structure in 32 bit ints (not counting the length word).

References length.

◆ getNumber()

uint8_t evio::BaseStructureHeader::getNumber ( ) const

Get the number.

Only Banks have a number field in their header, so this is only relevant for Banks.

Returns
the number.

References number.

◆ getPadding()

uint8_t evio::BaseStructureHeader::getPadding ( ) const

Get the amount of padding bytes when storing short or byte data.

Value is 0, 1, 2, or 3 for bytes and 0 or 2 for shorts.

Returns
number of padding bytes

References padding.

◆ getTag()

uint16_t evio::BaseStructureHeader::getTag ( ) const

Get the structure tag.

Returns
the structure tag.

References tag.

◆ setDataType() [1/2]

void evio::BaseStructureHeader::setDataType ( DataType const &  type)

Set the numeric data type for the structure.

Parameters
typethe numeric data type for the structure.

References dataType.

◆ setDataType() [2/2]

void evio::BaseStructureHeader::setDataType ( uint32_t  type)

Set the numeric data type for the structure.

Parameters
typethe numeric data type for the structure.

References dataType, and evio::DataType::getDataType().

◆ setLength()

void evio::BaseStructureHeader::setLength ( uint32_t  len)

Set the length of the structure in 32 bit ints, not counting the length word.

Parameters
lenthe length of the structure in 32 bit ints, not counting the length word.

References length.

◆ setNumber()

void evio::BaseStructureHeader::setNumber ( uint8_t  num)

Set the number.

Only Banks have a number field in their header, so this is only relevant for Banks.

Parameters
numthe number.

References number.

◆ setPadding()

void evio::BaseStructureHeader::setPadding ( uint8_t  pad)
protected

Set the amount of padding bytes when storing short or byte data.

Allowed value is 0, 1, 2, or 3 for bytes and 0 or 2 for shorts.

Parameters
padamount of padding bytes when storing short or byte data (0-3).

References padding.

◆ setTag()

void evio::BaseStructureHeader::setTag ( uint16_t  t)

Set the structure tag.

Parameters
tthe structure tag.

References tag.

◆ toString()

virtual std::string evio::BaseStructureHeader::toString ( )
inlinevirtual

Obtain a string representation of the base structure header.

Returns
a string representation of the base structure header.

Reimplemented in evio::TagSegmentHeader, evio::SegmentHeader, and evio::BankHeader.

◆ write() [1/3]

virtual size_t evio::BaseStructureHeader::write ( ByteBuffer dest)
inlinevirtual

Write myself out into a byte buffer.

This write is relative - i.e., it uses the current position of the buffer.

Parameters
destthe byteBuffer to write to.
Returns
the number of bytes written, which for a BankHeader is 8 and for a SegmentHeader or TagSegmentHeader is 4.

Reimplemented in evio::TagSegmentHeader, evio::SegmentHeader, and evio::BankHeader.

◆ write() [2/3]

virtual size_t evio::BaseStructureHeader::write ( std::shared_ptr< ByteBuffer > &  dest)
inlinevirtual

Write myself out into a byte buffer.

This write is relative - i.e., it uses the current position of the buffer.

Parameters
destthe byteBuffer to write to.
Returns
the number of bytes written, which for a BankHeader is 8 and for a SegmentHeader or TagSegmentHeader is 4.

Reimplemented in evio::TagSegmentHeader, evio::SegmentHeader, and evio::BankHeader.

◆ write() [3/3]

virtual size_t evio::BaseStructureHeader::write ( uint8_t *  dest,
ByteOrder const &  order 
)
inlinevirtual

Write myself out as evio format data into the given byte array in the specified byte order.

Parameters
destarray into which evio data is written (destination).
orderbyte order in which to write the data.
Returns
the number of bytes written, which for a BankHeader is 8 and for a SegmentHeader or TagSegmentHeader is 4.
Exceptions
EvioExceptionif destination array too small to hold data.

Reimplemented in evio::TagSegmentHeader, evio::SegmentHeader, and evio::BankHeader.

Friends And Related Function Documentation

◆ BaseStructure

friend class BaseStructure
friend

◆ CompositeData

friend class CompositeData
friend

◆ EventHeaderParser

friend class EventHeaderParser
friend

◆ EvioReader

friend class EvioReader
friend

◆ EvioReaderV4

friend class EvioReaderV4
friend

◆ StructureTransformer

friend class StructureTransformer
friend

Member Data Documentation

◆ dataType

◆ length

◆ number

uint8_t evio::BaseStructureHeader::number = 0
protected

The number represents an unsigned byte.

Only Banks have a number field in their header, so this is only relevant for Banks.

Referenced by BaseStructureHeader(), copy(), getNumber(), setNumber(), evio::BankHeader::toString(), and evio::BankHeader::write().

◆ padding

uint8_t evio::BaseStructureHeader::padding = 0
protected

The amount of padding bytes when storing short or byte data.

Allowed value is 0, 1, 2, or 3 (0,2 for shorts and 0-3 for bytes) and is stored in the upper 2 bits of the dataType when written out.

Referenced by copy(), getPadding(), setPadding(), evio::BankHeader::toString(), evio::SegmentHeader::toString(), evio::BankHeader::write(), and evio::SegmentHeader::write().

◆ tag


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