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

Low-level node representing a tagged data element in a HIPO structure. More...

#include <node.h>

+ Inheritance diagram for hipo::node:

Public Member Functions

 node ()
 Default constructor; allocates an 8-byte header. More...
 
 node (std::tuple< int, int, int, int > params)
 Construct a node from a parameter tuple. More...
 
 node (int size)
 Construct a node with a pre-allocated data region. More...
 
virtual ~node ()=default
 
void assign (std::tuple< int, int, int, int > params)
 Re-initialize this node from a parameter tuple. More...
 
bool allocate (int size)
 Ensure the internal buffer can hold at least size bytes. More...
 
virtual void reset ()
 Reset the node by setting the data length to zero. More...
 
int size () const noexcept
 
int capacity () const noexcept
 
int formatLength () const noexcept
 
void setFormatLength (int length)
 Set the format descriptor length. More...
 
void setDataLength (int length)
 Set the data payload length, preserving the format length. More...
 
int dataLength () const noexcept
 
int nodeLength ()
 
void setNodeLength (int size)
 Set the total node length in the header word. More...
 
int dataOffset () const noexcept
 
int group ()
 
int item ()
 
int type ()
 
const char * pointer ()
 
virtual void show ()
 Print a summary of this node to stdout. More...
 
void setSize (int size)
 Set the total size of the node. More...
 
int getIntAt (int index) const noexcept
 Read a 32-bit integer at the given byte offset within the data region. More...
 
int16_t getShortAt (int index) const noexcept
 Read a 16-bit integer at the given byte offset within the data region. More...
 
int8_t getByteAt (int index) const noexcept
 Read an 8-bit integer at the given byte offset within the data region. More...
 
float getFloatAt (int index) const noexcept
 Read a 32-bit float at the given byte offset within the data region. More...
 
double getDoubleAt (int index) const noexcept
 Read a 64-bit double at the given byte offset within the data region. More...
 
long getLongAt (int index) const noexcept
 Read a 64-bit integer at the given byte offset within the data region. More...
 
void putIntAt (int index, int value)
 Write a 32-bit integer at the given byte offset within the data region. More...
 
void putShortAt (int index, int16_t value)
 Write a 16-bit integer at the given byte offset within the data region. More...
 
void putByteAt (int index, int8_t value)
 Write an 8-bit integer at the given byte offset within the data region. More...
 
void putFloatAt (int index, float value)
 Write a 32-bit float at the given byte offset within the data region. More...
 
void putDoubleAt (int index, double value)
 Write a 64-bit double at the given byte offset within the data region. More...
 
void putLongAt (int index, int64_t value)
 Write a 64-bit integer at the given byte offset within the data region. More...
 
virtual void notify ()
 Callback invoked when the node content is updated (e.g., after deserialization). More...
 

Protected Member Functions

void create (int group, int item, int type, int size)
 Create a node with the given header fields and allocate storage. More...
 
void init (const char *b, int length)
 Initialize the node by copying raw bytes into the internal buffer. More...
 
void initEmpty ()
 Initialize the node to an empty state. More...
 

Friends

class tuple
 
class event
 

Detailed Description

Low-level node representing a tagged data element in a HIPO structure.

A node stores a binary buffer with an 8-byte header encoding the group, item, type, and data length, followed by an optional format descriptor and the payload data. It provides typed accessors for reading and writing primitive values at byte offsets within the data region.

Nodes are the building blocks for higher-level constructs such as hipo::structure, hipo::composite, and hipo::bank.

Definition at line 68 of file node.h.

Constructor & Destructor Documentation

◆ node() [1/3]

hipo::node::node ( )
inline

Default constructor; allocates an 8-byte header.

Definition at line 99 of file node.h.

◆ node() [2/3]

hipo::node::node ( std::tuple< int, int, int, int >  params)
inline

Construct a node from a parameter tuple.

Parameters
paramsTuple of (group, item, type, size)

Definition at line 105 of file node.h.

◆ node() [3/3]

hipo::node::node ( int  size)
inline

Construct a node with a pre-allocated data region.

Parameters
sizePayload size in bytes (header is allocated in addition)

Definition at line 113 of file node.h.

◆ ~node()

virtual hipo::node::~node ( )
virtualdefault

Member Function Documentation

◆ allocate()

bool hipo::node::allocate ( int  size)
inline

Ensure the internal buffer can hold at least size bytes.

Parameters
sizeRequired capacity in bytes
Returns
Always returns true

Definition at line 128 of file node.h.

◆ assign()

void hipo::node::assign ( std::tuple< int, int, int, int >  params)

Re-initialize this node from a parameter tuple.

Parameters
paramsTuple of (group, item, type, size)

Definition at line 65 of file node.cpp.

◆ capacity()

int hipo::node::capacity ( ) const
inlinenoexcept
Returns
Total allocated buffer capacity in bytes.

Definition at line 145 of file node.h.

◆ create()

void hipo::node::create ( int  group,
int  item,
int  type,
int  size 
)
protected

Create a node with the given header fields and allocate storage.

Parameters
groupGroup identifier (16-bit)
itemItem identifier (8-bit)
typeData type identifier (8-bit)
sizePayload size in bytes

Definition at line 51 of file node.cpp.

◆ dataLength()

int hipo::node::dataLength ( ) const
inlinenoexcept
Returns
Length of the data payload in bytes (total size minus format length).

Definition at line 183 of file node.h.

◆ dataOffset()

int hipo::node::dataOffset ( ) const
inlinenoexcept
Returns
Byte offset from the start of the buffer to the data payload.

Definition at line 323 of file node.h.

◆ formatLength()

int hipo::node::formatLength ( ) const
inlinenoexcept
Returns
Length of the format descriptor in bytes (stored in the upper byte of the size word).

Definition at line 151 of file node.h.

◆ getByteAt()

int8_t hipo::node::getByteAt ( int  index) const
inlinenoexcept

Read an 8-bit integer at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region

Definition at line 245 of file node.h.

◆ getDoubleAt()

double hipo::node::getDoubleAt ( int  index) const
inlinenoexcept

Read a 64-bit double at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region

Definition at line 255 of file node.h.

◆ getFloatAt()

float hipo::node::getFloatAt ( int  index) const
inlinenoexcept

Read a 32-bit float at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region

Definition at line 250 of file node.h.

◆ getIntAt()

int hipo::node::getIntAt ( int  index) const
inlinenoexcept

Read a 32-bit integer at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region

Definition at line 234 of file node.h.

◆ getLongAt()

long hipo::node::getLongAt ( int  index) const
inlinenoexcept

Read a 64-bit integer at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region

Definition at line 260 of file node.h.

◆ getShortAt()

int16_t hipo::node::getShortAt ( int  index) const
inlinenoexcept

Read a 16-bit integer at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region

Definition at line 240 of file node.h.

◆ group()

int hipo::node::group ( )
inline
Returns
The 16-bit group identifier from the header.

Definition at line 212 of file node.h.

◆ init()

void hipo::node::init ( const char *  b,
int  length 
)
inlineprotected

Initialize the node by copying raw bytes into the internal buffer.

Parameters
bSource buffer
lengthNumber of bytes to copy

Definition at line 91 of file node.h.

◆ initEmpty()

void hipo::node::initEmpty ( )
protected

Initialize the node to an empty state.

Definition at line 79 of file node.cpp.

◆ item()

int hipo::node::item ( )
inline
Returns
The 8-bit item identifier from the header.

Definition at line 214 of file node.h.

◆ nodeLength()

int hipo::node::nodeLength ( )
inline
Returns
Total node length (format + data) from the header word.

Definition at line 190 of file node.h.

◆ notify()

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

Callback invoked when the node content is updated (e.g., after deserialization).

Reimplemented in hipo::composite.

Definition at line 317 of file node.h.

◆ pointer()

const char* hipo::node::pointer ( )
inline
Returns
Pointer to the underlying raw buffer.

Definition at line 219 of file node.h.

◆ putByteAt()

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

Write an 8-bit integer at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region
valueValue to write

Definition at line 285 of file node.h.

◆ putDoubleAt()

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

Write a 64-bit double at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region
valueValue to write

Definition at line 301 of file node.h.

◆ putFloatAt()

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

Write a 32-bit float at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region
valueValue to write

Definition at line 293 of file node.h.

◆ putIntAt()

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

Write a 32-bit integer at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region
valueValue to write

Definition at line 269 of file node.h.

◆ putLongAt()

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

Write a 64-bit integer at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region
valueValue to write

Definition at line 309 of file node.h.

◆ putShortAt()

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

Write a 16-bit integer at the given byte offset within the data region.

Parameters
indexByte offset relative to the start of the data region
valueValue to write

Definition at line 277 of file node.h.

◆ reset()

virtual void hipo::node::reset ( )
inlinevirtual

Reset the node by setting the data length to zero.

Reimplemented in hipo::composite.

Definition at line 135 of file node.h.

◆ setDataLength()

void hipo::node::setDataLength ( int  length)
inline

Set the data payload length, preserving the format length.

Parameters
lengthData length in bytes

Definition at line 171 of file node.h.

◆ setFormatLength()

void hipo::node::setFormatLength ( int  length)
inline

Set the format descriptor length.

Parameters
lengthFormat length in bytes (must be less than 128)

Definition at line 160 of file node.h.

◆ setNodeLength()

void hipo::node::setNodeLength ( int  size)
inline

Set the total node length in the header word.

Parameters
sizeTotal length in bytes (must be less than 16777215)

Definition at line 199 of file node.h.

◆ setSize()

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

Set the total size of the node.

Parameters
sizeTotal size in bytes

Definition at line 60 of file node.cpp.

◆ show()

void hipo::node::show ( )
virtual

Print a summary of this node to stdout.

Definition at line 87 of file node.cpp.

◆ size()

int hipo::node::size ( ) const
inlinenoexcept
Returns
Total size of the node (format length + data length) in bytes.

Definition at line 138 of file node.h.

◆ type()

int hipo::node::type ( )
inline
Returns
The 8-bit type identifier from the header.

Definition at line 216 of file node.h.

Friends And Related Function Documentation

◆ event

friend class event
friend

Definition at line 320 of file node.h.

◆ tuple

friend class tuple
friend

Definition at line 319 of file node.h.


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