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

Builds HIPO records by accumulating events and compressing them. More...

#include <recordbuilder.h>

Public Member Functions

 recordbuilder (int maxEvents, int maxLength)
 Constructs a record builder with specified capacity. More...
 
 recordbuilder ()
 Default constructor with default capacity. More...
 
virtual ~recordbuilder ()
 Virtual destructor. More...
 
bool addEvent (std::vector< char > &vec, int start, int length)
 Adds an event from a raw byte vector. More...
 
bool addEvent (hipo::event &evnt)
 Adds an event object to the record. More...
 
long getUserWordOne ()
 Returns the first user-defined word stored in the record header. More...
 
long getUserWordTwo ()
 Returns the second user-defined word stored in the record header. More...
 
void setUserWordOne (long userWordOne)
 Sets the first user-defined word in the record header. More...
 
void setUserWordTwo (long userWordTwo)
 Sets the second user-defined word in the record header. More...
 
int getRecordSize ()
 Returns the total size of the built record in bytes. More...
 
int getEntries ()
 Returns the number of events currently in the record. More...
 
std::vector< char > & getRecordBuffer ()
 Returns a reference to the internal record buffer. More...
 
void reset ()
 Resets the builder, clearing all accumulated events. More...
 
void build ()
 Compresses accumulated events and builds the final record. More...
 

Detailed Description

Builds HIPO records by accumulating events and compressing them.

Events are added sequentially into internal buffers. Once all desired events have been added, build() compresses them into a single record that can be written to a HIPO file.

Definition at line 45 of file recordbuilder.h.

Constructor & Destructor Documentation

◆ recordbuilder() [1/2]

hipo::recordbuilder::recordbuilder ( int  maxEvents,
int  maxLength 
)

Constructs a record builder with specified capacity.

Parameters
maxEventsMaximum number of events the record can hold.
maxLengthMaximum total byte length of event data.

Constructor with custom max event size and maximum record size provided by user.

Definition at line 36 of file recordbuilder.cpp.

◆ recordbuilder() [2/2]

hipo::recordbuilder::recordbuilder ( )

Default constructor with default capacity.

Default constructor sets number of max events to 100000 and the buffer size to 8MB.

Definition at line 24 of file recordbuilder.cpp.

◆ ~recordbuilder()

virtual hipo::recordbuilder::~recordbuilder ( )
inlinevirtual

Virtual destructor.

Definition at line 77 of file recordbuilder.h.

Member Function Documentation

◆ addEvent() [1/2]

bool hipo::recordbuilder::addEvent ( hipo::event evnt)

Adds an event object to the record.

Parameters
evntThe HIPO event to add.
Returns
True if the event was added, false if the record is full.

add event object to the record builder buffer.

Definition at line 48 of file recordbuilder.cpp.

◆ addEvent() [2/2]

bool hipo::recordbuilder::addEvent ( std::vector< char > &  vec,
int  start,
int  length 
)

Adds an event from a raw byte vector.

Parameters
vecSource byte vector containing event data.
startStarting offset within the vector.
lengthNumber of bytes to copy.
Returns
True if the event was added, false if the record is full.

add a content of a vector to the record builder buffer. offset in the buffer and number of bytes to add provided by user.

Definition at line 56 of file recordbuilder.cpp.

◆ build()

void hipo::recordbuilder::build ( )

Compresses accumulated events and builds the final record.

Definition at line 117 of file recordbuilder.cpp.

◆ getEntries()

int hipo::recordbuilder::getEntries ( )

Returns the number of events currently in the record.

Returns number of events in the record.

Definition at line 87 of file recordbuilder.cpp.

◆ getRecordBuffer()

std::vector<char>& hipo::recordbuilder::getRecordBuffer ( )
inline

Returns a reference to the internal record buffer.

Definition at line 117 of file recordbuilder.h.

◆ getRecordSize()

int hipo::recordbuilder::getRecordSize ( )

Returns the total size of the built record in bytes.

returns the size of the record.

Definition at line 94 of file recordbuilder.cpp.

◆ getUserWordOne()

long hipo::recordbuilder::getUserWordOne ( )

Returns the first user-defined word stored in the record header.

Definition at line 99 of file recordbuilder.cpp.

◆ getUserWordTwo()

long hipo::recordbuilder::getUserWordTwo ( )

Returns the second user-defined word stored in the record header.

Definition at line 104 of file recordbuilder.cpp.

◆ reset()

void hipo::recordbuilder::reset ( )

Resets the builder, clearing all accumulated events.

Resets the counters for number of events and sets the position for writing new events to the begining of the event buffer.

Definition at line 70 of file recordbuilder.cpp.

◆ setUserWordOne()

void hipo::recordbuilder::setUserWordOne ( long  userWordOne)

Sets the first user-defined word in the record header.

Parameters
userWordOneThe value to set.

Definition at line 109 of file recordbuilder.cpp.

◆ setUserWordTwo()

void hipo::recordbuilder::setUserWordTwo ( long  userWordTwo)

Sets the second user-defined word in the record header.

Parameters
userWordTwoThe value to set.

Definition at line 113 of file recordbuilder.cpp.


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