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

Represents a HIPO event, a container for multiple structures/banks. More...

#include <event.h>

Public Member Functions

 event ()
 Default constructor. Creates an empty event. More...
 
 event (int size)
 Construct an event with a pre-allocated buffer. More...
 
virtual ~event ()
 Destructor. More...
 
void show ()
 Display the event contents to standard output. More...
 
void init (std::vector< char > &buffer)
 Initialize the event from an existing buffer. More...
 
void init (const char *buffer, int size)
 Initialize the event from a raw byte buffer. More...
 
void getStructure (hipo::structure &str, int group, int item)
 Extract a structure from the event by group and item identifiers. More...
 
void getStructure4 (hipo::structure &str, int group, int item)
 Extract a structure using 4-byte header format. More...
 
int getTag ()
 
void setTag (int tag)
 
void getStructure (hipo::bank &b)
 Read a bank from this event using the bank's schema definition. More...
 
void read (hipo::bank &b)
 Read a bank from this event (alias for getStructure). More...
 
void addStructure (hipo::structure &str)
 Add a structure to the event. More...
 
void override (hipo::structure &str)
 Override an existing structure in the event. More...
 
void remove (hipo::bank &str)
 Remove a bank from the event. More...
 
void remove (int group, int item)
 Remove a structure from the event by group and item identifiers. More...
 
void replace (hipo::bank &bank)
 Replace an existing bank in the event. More...
 
void add (hipo::node &_n)
 Add a node to the event. More...
 
void get (hipo::node &_n, int group, int item)
 Get a node from the event by group and item identifiers. More...
 
std::pair< int, int > getStructurePosition (int group, int item)
 Find the position and length of a structure in the event buffer. More...
 
std::pair< int, int > getStructurePosition4 (int group, int item)
 Find the position and length of a structure using 4-byte header format. More...
 
std::vector< char > & getEventBuffer ()
 
int getSize ()
 
void reset ()
 Reset the event to an empty state. More...
 
void write (hipo::node &node)
 Write a node into this event. More...
 
void read (hipo::node &node, int group, int item)
 Read a node from this event by group and item identifiers. More...
 

Static Public Member Functions

Static Methods

Static methods for reading structures from an event buffer in memory. These do not require copying the event into a separate buffer.

static std::pair< int, int > getStructurePosition (const char *buffer, int group, int item)
 Find the position and length of a structure in a raw buffer. More...
 
static void getStructure (const char *buffer, hipo::structure &str, int group, int item)
 Extract a structure from a raw buffer by group and item. More...
 
static void get (const char *buffer, hipo::node &_n, int group, int item)
 Get a node from a raw buffer by group and item. More...
 
static void getStructureNoCopy (const char *buffer, hipo::structure &str, int group, int item)
 Extract a structure from a raw buffer without copying the data. More...
 

Detailed Description

Represents a HIPO event, a container for multiple structures/banks.

Events are read from records and can be written to files. An event holds an internal byte buffer that contains serialized HIPO structures (banks), which can be extracted, added, removed, or replaced.

Definition at line 77 of file event.h.

Constructor & Destructor Documentation

◆ event() [1/2]

hipo::event::event ( )

Default constructor. Creates an empty event.

Definition at line 47 of file event.cpp.

◆ event() [2/2]

hipo::event::event ( int  size)

Construct an event with a pre-allocated buffer.

Parameters
sizethe number of bytes to pre-allocate for the internal buffer.

Definition at line 56 of file event.cpp.

◆ ~event()

hipo::event::~event ( )
virtualdefault

Destructor.

Member Function Documentation

◆ add()

void hipo::event::add ( hipo::node _n)

Add a node to the event.

Parameters
_nreference to the node to add.

Definition at line 184 of file event.cpp.

◆ addStructure()

void hipo::event::addStructure ( hipo::structure str)

Add a structure to the event.

Parameters
strreference to the structure to add.

Definition at line 161 of file event.cpp.

◆ get() [1/2]

void hipo::event::get ( const char *  buffer,
hipo::node _n,
int  group,
int  item 
)
static

Get a node from a raw buffer by group and item.

Parameters
bufferpointer to the raw event buffer.
_nreference to the node to populate.
groupthe group identifier.
itemthe item identifier.

Definition at line 360 of file event.cpp.

◆ get() [2/2]

void hipo::event::get ( hipo::node _n,
int  group,
int  item 
)

Get a node from the event by group and item identifiers.

Parameters
_nreference to the node to populate.
groupthe group identifier.
itemthe item identifier.

Definition at line 209 of file event.cpp.

◆ getEventBuffer()

std::vector< char > & hipo::event::getEventBuffer ( )

Get a reference to the internal event buffer.

Returns
reference to the internal vector of chars.

Definition at line 329 of file event.cpp.

◆ getSize()

int hipo::event::getSize ( )

Get the size of the event in bytes.

Returns
the event size.

Definition at line 315 of file event.cpp.

◆ getStructure() [1/3]

void hipo::event::getStructure ( const char *  buffer,
hipo::structure str,
int  group,
int  item 
)
static

Extract a structure from a raw buffer by group and item.

Parameters
bufferpointer to the raw event buffer.
strreference to the structure to populate.
groupthe group identifier.
itemthe item identifier.

Definition at line 108 of file event.cpp.

◆ getStructure() [2/3]

void hipo::event::getStructure ( hipo::bank b)

Read a bank from this event using the bank's schema definition.

Parameters
breference to the bank to populate.

Definition at line 63 of file event.cpp.

◆ getStructure() [3/3]

void hipo::event::getStructure ( hipo::structure str,
int  group,
int  item 
)

Extract a structure from the event by group and item identifiers.

Parameters
strreference to the structure to populate.
groupthe group identifier of the structure.
itemthe item identifier of the structure.

Definition at line 72 of file event.cpp.

◆ getStructure4()

void hipo::event::getStructure4 ( hipo::structure str,
int  group,
int  item 
)

Extract a structure using 4-byte header format.

Parameters
strreference to the structure to populate.
groupthe group identifier of the structure.
itemthe item identifier of the structure.

Definition at line 84 of file event.cpp.

◆ getStructureNoCopy()

void hipo::event::getStructureNoCopy ( const char *  buffer,
hipo::structure str,
int  group,
int  item 
)
static

Extract a structure from a raw buffer without copying the data.

The structure will reference the original buffer memory directly.

Parameters
bufferpointer to the raw event buffer.
strreference to the structure to populate.
groupthe group identifier.
itemthe item identifier.

Definition at line 97 of file event.cpp.

◆ getStructurePosition() [1/2]

std::pair< int, int > hipo::event::getStructurePosition ( const char *  buffer,
int  group,
int  item 
)
static

Find the position and length of a structure in a raw buffer.

Parameters
bufferpointer to the raw event buffer.
groupthe group identifier.
itemthe item identifier.
Returns
a pair where first is the byte offset and second is the length.

Definition at line 239 of file event.cpp.

◆ getStructurePosition() [2/2]

std::pair< int, int > hipo::event::getStructurePosition ( int  group,
int  item 
)

Find the position and length of a structure in the event buffer.

Parameters
groupthe group identifier.
itemthe item identifier.
Returns
a pair where first is the byte offset and second is the length.

Definition at line 256 of file event.cpp.

◆ getStructurePosition4()

std::pair< int, int > hipo::event::getStructurePosition4 ( int  group,
int  item 
)

Find the position and length of a structure using 4-byte header format.

Parameters
groupthe group identifier.
itemthe item identifier.
Returns
a pair where first is the byte offset and second is the length.

Definition at line 274 of file event.cpp.

◆ getTag()

int hipo::event::getTag ( )

Get the event tag.

Returns
the tag value associated with this event.

Definition at line 223 of file event.cpp.

◆ init() [1/2]

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

Initialize the event from a raw byte buffer.

Parameters
bufferpointer to the raw byte buffer.
sizenumber of bytes in the buffer.

Definition at line 306 of file event.cpp.

◆ init() [2/2]

void hipo::event::init ( std::vector< char > &  buffer)

Initialize the event from an existing buffer.

Parameters
bufferreference to a vector of chars containing the event data.

Definition at line 234 of file event.cpp.

◆ override()

void hipo::event::override ( hipo::structure str)

Override an existing structure in the event.

If a structure with the same group and item already exists, it is replaced; otherwise the structure is appended.

Parameters
strreference to the structure to override.

Definition at line 119 of file event.cpp.

◆ read() [1/2]

void hipo::event::read ( hipo::bank b)

Read a bank from this event (alias for getStructure).

Parameters
breference to the bank to populate.

Definition at line 67 of file event.cpp.

◆ read() [2/2]

void hipo::event::read ( hipo::node node,
int  group,
int  item 
)

Read a node from this event by group and item identifiers.

Parameters
nodereference to the node to populate.
groupthe group identifier.
itemthe item identifier.

Definition at line 205 of file event.cpp.

◆ remove() [1/2]

void hipo::event::remove ( hipo::bank str)

Remove a bank from the event.

Parameters
strreference to the bank to remove.

Definition at line 136 of file event.cpp.

◆ remove() [2/2]

void hipo::event::remove ( int  group,
int  item 
)

Remove a structure from the event by group and item identifiers.

Parameters
groupthe group identifier of the structure to remove.
itemthe item identifier of the structure to remove.

Definition at line 140 of file event.cpp.

◆ replace()

void hipo::event::replace ( hipo::bank bank)

Replace an existing bank in the event.

Parameters
bankreference to the bank that will replace the current one.

Definition at line 123 of file event.cpp.

◆ reset()

void hipo::event::reset ( )

Reset the event to an empty state.

Definition at line 321 of file event.cpp.

◆ setTag()

void hipo::event::setTag ( int  tag)

Set the event tag.

Parameters
tagthe tag value to assign to this event.

Definition at line 229 of file event.cpp.

◆ show()

void hipo::event::show ( )

Display the event contents to standard output.

Definition at line 336 of file event.cpp.

◆ write()

void hipo::event::write ( hipo::node node)

Write a node into this event.

Parameters
nodereference to the node to write.

Definition at line 201 of file event.cpp.


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