HIPO  4.3.0
High Performance Output data format for experimental physics
hipo::structure Class Reference

Low-level data structure representing a HIPO structure. More...

#include <bank.h>

+ Inheritance diagram for hipo::structure:

Public Member Functions

 structure ()
 Default constructor. Sets the structure address to nullptr. More...
 
 structure (int size)
 
 structure (int __group, int __item, std::string &str)
 Construct a structure from a group, item, and string payload. More...
 
virtual ~structure ()=default
 
bool allocate (int size)
 
int getSize () const noexcept
 
int getHeaderSize () const noexcept
 
int getDataSize () const noexcept
 
int getType () const
 
int getGroup () const
 
int getItem () const
 
void init (const char *buffer, int size)
 
void initNoCopy (const char *buffer, int size)
 
const char * getAddress ()
 
virtual void show () const
 Display the structure contents to standard output. More...
 
void setSize (int size)
 
void setHeaderSize (int size)
 
void setDataSize (int size)
 
int getIntAt (int index) const noexcept
 
int16_t getShortAt (int index) const noexcept
 
int8_t getByteAt (int index) const noexcept
 
float getFloatAt (int index) const noexcept
 
double getDoubleAt (int index) const noexcept
 
long getLongAt (int index) const noexcept
 
std::string getStringAt (int index)
 
void putIntAt (int index, int value)
 
void putShortAt (int index, int16_t value)
 
void putByteAt (int index, int8_t value)
 
void putFloatAt (int index, float value)
 
void putDoubleAt (int index, double value)
 
void putLongAt (int index, int64_t value)
 
void putStringAt (int index, std::string &str)
 
virtual void notify ()
 Called when the structure is updated (e.g., after reading an event). More...
 

Protected Member Functions

void initStructureBySize (int __group, int __item, int __type, int __size)
 Initialize the structure buffer with the given group, item, type, and data size. More...
 
std::vector< char > & getStructureBuffer ()
 
int getStructureBufferSize ()
 

Protected Attributes

int dataOffset = 8
 

Friends

class tuple
 
class event
 

Detailed Description

Low-level data structure representing a HIPO structure.

A structure stores binary data with an 8-byte header containing group, item, type, and size information, followed by the payload data.

Definition at line 64 of file bank.h.

Constructor & Destructor Documentation

◆ structure() [1/3]

hipo::structure::structure ( )
inline

Default constructor. Sets the structure address to nullptr.

Definition at line 87 of file bank.h.

◆ structure() [2/3]

hipo::structure::structure ( int  size)
inline

Construct a structure and allocate the given number of bytes.

Parameters
sizethe number of bytes to allocate

Definition at line 90 of file bank.h.

◆ structure() [3/3]

hipo::structure::structure ( int  __group,
int  __item,
std::string &  str 
)

Construct a structure from a group, item, and string payload.

Parameters
__groupthe group identifier
__itemthe item identifier
strthe string to store in the structure

Definition at line 54 of file bank.cpp.

◆ ~structure()

virtual hipo::structure::~structure ( )
virtualdefault

Member Function Documentation

◆ allocate()

bool hipo::structure::allocate ( int  size)

Allocate the internal buffer with the given size.

Parameters
sizethe number of bytes to allocate
Returns
true on success

Definition at line 60 of file bank.cpp.

◆ getAddress()

const char * hipo::structure::getAddress ( )
Returns
a pointer to the internal structure address.

Definition at line 142 of file bank.cpp.

◆ getByteAt()

int8_t hipo::structure::getByteAt ( int  index) const
inlinenoexcept
Returns
the 8-bit integer at the given byte offset.
Parameters
indexbyte offset relative to the data section

Definition at line 165 of file bank.h.

◆ getDataSize()

int hipo::structure::getDataSize ( ) const
inlinenoexcept
Returns
the data size in bytes (total size minus header size).

Definition at line 119 of file bank.h.

◆ getDoubleAt()

double hipo::structure::getDoubleAt ( int  index) const
inlinenoexcept
Returns
the double at the given byte offset.
Parameters
indexbyte offset relative to the data section

Definition at line 175 of file bank.h.

◆ getFloatAt()

float hipo::structure::getFloatAt ( int  index) const
inlinenoexcept
Returns
the float at the given byte offset.
Parameters
indexbyte offset relative to the data section

Definition at line 170 of file bank.h.

◆ getGroup()

int hipo::structure::getGroup ( ) const
Returns
the group identifier from the structure header.

Definition at line 103 of file bank.cpp.

◆ getHeaderSize()

int hipo::structure::getHeaderSize ( ) const
inlinenoexcept
Returns
the header size in bytes.

Definition at line 113 of file bank.h.

◆ getIntAt()

int hipo::structure::getIntAt ( int  index) const
inlinenoexcept
Returns
the 32-bit integer at the given byte offset.
Parameters
indexbyte offset relative to the data section

Definition at line 154 of file bank.h.

◆ getItem()

int hipo::structure::getItem ( ) const
Returns
the item identifier from the structure header.

Definition at line 108 of file bank.cpp.

◆ getLongAt()

long hipo::structure::getLongAt ( int  index) const
inlinenoexcept
Returns
the 64-bit integer at the given byte offset.
Parameters
indexbyte offset relative to the data section

Definition at line 180 of file bank.h.

◆ getShortAt()

int16_t hipo::structure::getShortAt ( int  index) const
inlinenoexcept
Returns
the 16-bit integer at the given byte offset.
Parameters
indexbyte offset relative to the data section

Definition at line 160 of file bank.h.

◆ getSize()

int hipo::structure::getSize ( ) const
inlinenoexcept
Returns
the total size (header + data) from the structure header.

Definition at line 106 of file bank.h.

◆ getStringAt()

std::string hipo::structure::getStringAt ( int  index)
Returns
the string starting at the given byte offset.
Parameters
indexbyte offset relative to the data section

Definition at line 127 of file bank.cpp.

◆ getStructureBuffer()

std::vector<char>& hipo::structure::getStructureBuffer ( )
inlineprotected
Returns
a reference to the internal structure buffer.

Definition at line 77 of file bank.h.

◆ getStructureBufferSize()

int hipo::structure::getStructureBufferSize ( )
inlineprotected
Returns
the total structure buffer size (header + data).

Definition at line 79 of file bank.h.

◆ getType()

int hipo::structure::getType ( ) const
Returns
the data type code stored in the structure header.

Definition at line 98 of file bank.cpp.

◆ init()

void hipo::structure::init ( const char *  buffer,
int  size 
)

Initialize the structure by copying data from a buffer.

Parameters
bufferthe source buffer
sizethe number of bytes to copy

Definition at line 116 of file bank.cpp.

◆ initNoCopy()

void hipo::structure::initNoCopy ( const char *  buffer,
int  size 
)

Initialize the structure by pointing to an external buffer without copying.

Parameters
bufferthe source buffer
sizethe size of the buffer

Definition at line 112 of file bank.cpp.

◆ initStructureBySize()

void hipo::structure::initStructureBySize ( int  __group,
int  __item,
int  __type,
int  __size 
)
protected

Initialize the structure buffer with the given group, item, type, and data size.

Definition at line 67 of file bank.cpp.

◆ notify()

virtual void hipo::structure::notify ( )
inlinevirtual

Called when the structure is updated (e.g., after reading an event).

Reimplemented in hipo::bank.

Definition at line 236 of file bank.h.

◆ putByteAt()

void hipo::structure::putByteAt ( int  index,
int8_t  value 
)
inline

Store an 8-bit integer at the given byte offset.

Parameters
indexbyte offset relative to the data section
valuethe value to store

Definition at line 205 of file bank.h.

◆ putDoubleAt()

void hipo::structure::putDoubleAt ( int  index,
double  value 
)
inline

Store a double at the given byte offset.

Parameters
indexbyte offset relative to the data section
valuethe value to store

Definition at line 219 of file bank.h.

◆ putFloatAt()

void hipo::structure::putFloatAt ( int  index,
float  value 
)
inline

Store a float at the given byte offset.

Parameters
indexbyte offset relative to the data section
valuethe value to store

Definition at line 212 of file bank.h.

◆ putIntAt()

void hipo::structure::putIntAt ( int  index,
int  value 
)
inline

Store a 32-bit integer at the given byte offset.

Parameters
indexbyte offset relative to the data section
valuethe value to store

Definition at line 191 of file bank.h.

◆ putLongAt()

void hipo::structure::putLongAt ( int  index,
int64_t  value 
)
inline

Store a 64-bit integer at the given byte offset.

Parameters
indexbyte offset relative to the data section
valuethe value to store

Definition at line 226 of file bank.h.

◆ putShortAt()

void hipo::structure::putShortAt ( int  index,
int16_t  value 
)
inline

Store a 16-bit integer at the given byte offset.

Parameters
indexbyte offset relative to the data section
valuethe value to store

Definition at line 198 of file bank.h.

◆ putStringAt()

void hipo::structure::putStringAt ( int  index,
std::string &  str 
)

Store a string at the given byte offset.

Parameters
indexbyte offset relative to the data section
strthe string to store

Definition at line 137 of file bank.cpp.

◆ setDataSize()

void hipo::structure::setDataSize ( int  size)

Set the data size field in the structure header.

Parameters
sizethe data size value to set

Definition at line 82 of file bank.cpp.

◆ setHeaderSize()

void hipo::structure::setHeaderSize ( int  size)

Set the header size field in the structure header.

Parameters
sizethe header size value to set

Definition at line 91 of file bank.cpp.

◆ setSize()

void hipo::structure::setSize ( int  size)

Set the total size field in the structure header.

Parameters
sizethe total size value to set

Definition at line 76 of file bank.cpp.

◆ show()

void hipo::structure::show ( ) const
virtual

Display the structure contents to standard output.

Reimplemented in hipo::bank.

Definition at line 122 of file bank.cpp.

Friends And Related Function Documentation

◆ event

friend class event
friend

Definition at line 237 of file bank.h.

◆ tuple

friend class tuple
friend

Definition at line 82 of file bank.h.

Member Data Documentation

◆ dataOffset

int hipo::structure::dataOffset = 8
protected

Definition at line 80 of file bank.h.


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