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

Schema definition for a HIPO bank. More...

#include <dictionary.h>

Public Member Functions

 schema ()
 Default constructor. Initializes an empty schema with zero group/item IDs. More...
 
 schema (const char *name, int __group, int __item)
 Construct a schema with a name, group ID, and item ID. More...
 
 schema (const schema &s)
 Copy constructor. More...
 
virtual ~schema ()=default
 Virtual destructor (defaulted). More...
 
void parse (const std::string &schString)
 Parse a schema definition string and populate entries. More...
 
std::string getName () const
 Get the schema name. More...
 
int getGroup ()
 Get the group identifier. More...
 
int getItem ()
 Get the item identifier. More...
 
int getSizeForRows (int rows)
 Compute the total buffer size needed for a given number of rows. More...
 
int getRowLength () const noexcept
 Get the size of a single row in bytes. More...
 
int getEntryOrder (const char *name) const
 Get the column index for a given column name. More...
 
bool exists (const char *name) const
 Check whether a column with the given name exists. More...
 
int getOffset (int item, int order, int rows) const
 Compute the byte offset for a column value by column index. More...
 
int getOffset (const char *name, int order, int rows) const
 Compute the byte offset for a column value by column name. More...
 
int getEntryType (int item) const noexcept
 Get the type identifier of a column by index. More...
 
int getEntryType (const char *name) const noexcept
 Get the type identifier of a column by name. More...
 
std::string getEntryName (int item) const noexcept
 Get the name of a column by index. More...
 
int getEntries () const noexcept
 Get the number of columns in the schema. More...
 
void show ()
 Print the schema to standard output. More...
 
std::string getSchemaString ()
 Serialize the schema to a definition string (e.g. "pid/I,px/F"). More...
 
std::string getSchemaStringJson ()
 Serialize the schema to a JSON-formatted string. More...
 
void operator= (const schema &D)
 Copy-assignment operator. More...
 

Detailed Description

Schema definition for a HIPO bank.

Defines the column names, types, and layout for a bank. Each column has a name, a type (B=byte, S=short, I=int, F=float, D=double, L=long), and an offset computed from the column order.

hipo::schema s("REC::Particle", 300, 1);
s.parse("pid/I,px/F,py/F,pz/F");
int col = s.getEntryOrder("pid"); // returns column index
Schema definition for a HIPO bank.
Definition: dictionary.h:73

Definition at line 73 of file dictionary.h.

Constructor & Destructor Documentation

◆ schema() [1/3]

hipo::schema::schema ( )
inline

Default constructor. Initializes an empty schema with zero group/item IDs.

Definition at line 92 of file dictionary.h.

◆ schema() [2/3]

hipo::schema::schema ( const char *  name,
int  __group,
int  __item 
)
inline

Construct a schema with a name, group ID, and item ID.

Parameters
nameSchema name (e.g. "REC::Particle").
__groupGroup identifier used in the bank header.
__itemItem identifier used in the bank header.

Definition at line 99 of file dictionary.h.

◆ schema() [3/3]

hipo::schema::schema ( const schema s)
inline

Copy constructor.

Parameters
sSchema to copy from.

Definition at line 104 of file dictionary.h.

◆ ~schema()

virtual hipo::schema::~schema ( )
virtualdefault

Virtual destructor (defaulted).

Member Function Documentation

◆ exists()

bool hipo::schema::exists ( const char *  name) const
inline

Check whether a column with the given name exists.

Parameters
nameColumn name to check.
Returns
True if the column exists, false otherwise.

Definition at line 159 of file dictionary.h.

◆ getEntries()

int hipo::schema::getEntries ( ) const
inlinenoexcept

Get the number of columns in the schema.

Returns
Number of columns.

Definition at line 217 of file dictionary.h.

◆ getEntryName()

std::string hipo::schema::getEntryName ( int  item) const
inlinenoexcept

Get the name of a column by index.

Parameters
itemZero-based column index.
Returns
Column name string.

Definition at line 214 of file dictionary.h.

◆ getEntryOrder()

int hipo::schema::getEntryOrder ( const char *  name) const
inline

Get the column index for a given column name.

Parameters
nameColumn name to look up.
Returns
Zero-based column index, or -1 if not found.

Definition at line 239 of file dictionary.h.

◆ getEntryType() [1/2]

int hipo::schema::getEntryType ( const char *  name) const
inlinenoexcept

Get the type identifier of a column by name.

Parameters
nameColumn name.
Returns
Numeric type identifier, or -1 if not found.

Definition at line 201 of file dictionary.h.

◆ getEntryType() [2/2]

int hipo::schema::getEntryType ( int  item) const
inlinenoexcept

Get the type identifier of a column by index.

Parameters
itemZero-based column index.
Returns
Numeric type identifier (see Type).

Definition at line 193 of file dictionary.h.

◆ getGroup()

int hipo::schema::getGroup ( )
inline

Get the group identifier.

Returns
Group ID.

Definition at line 128 of file dictionary.h.

◆ getItem()

int hipo::schema::getItem ( )
inline

Get the item identifier.

Returns
Item ID.

Definition at line 131 of file dictionary.h.

◆ getName()

std::string hipo::schema::getName ( ) const
inline

Get the schema name.

Returns
Schema name string.

Definition at line 125 of file dictionary.h.

◆ getOffset() [1/2]

int hipo::schema::getOffset ( const char *  name,
int  order,
int  rows 
) const
inline

Compute the byte offset for a column value by column name.

Parameters
nameColumn name.
orderRow number (zero-based).
rowsTotal number of rows in the bank.
Returns
Byte offset into the bank data buffer.

Definition at line 183 of file dictionary.h.

◆ getOffset() [2/2]

int hipo::schema::getOffset ( int  item,
int  order,
int  rows 
) const
inline

Compute the byte offset for a column value by column index.

Parameters
itemZero-based column index.
orderRow number (zero-based).
rowsTotal number of rows in the bank.
Returns
Byte offset into the bank data buffer.

Definition at line 171 of file dictionary.h.

◆ getRowLength()

int hipo::schema::getRowLength ( ) const
inlinenoexcept

Get the size of a single row in bytes.

Returns
Row length in bytes.

Definition at line 141 of file dictionary.h.

◆ getSchemaString()

std::string hipo::schema::getSchemaString ( )

Serialize the schema to a definition string (e.g. "pid/I,px/F").

Returns
Schema definition string.

Definition at line 86 of file dictionary.cpp.

◆ getSchemaStringJson()

std::string hipo::schema::getSchemaStringJson ( )

Serialize the schema to a JSON-formatted string.

Returns
JSON representation of the schema.

Definition at line 100 of file dictionary.cpp.

◆ getSizeForRows()

int hipo::schema::getSizeForRows ( int  rows)

Compute the total buffer size needed for a given number of rows.

Parameters
rowsNumber of rows.
Returns
Total size in bytes.

Definition at line 80 of file dictionary.cpp.

◆ operator=()

void hipo::schema::operator= ( const schema D)
inline

Copy-assignment operator.

Parameters
DSchema to copy from.

Definition at line 230 of file dictionary.h.

◆ parse()

void hipo::schema::parse ( const std::string &  schString)

Parse a schema definition string and populate entries.

The string format is comma-separated "name/type" pairs, e.g. "pid/I,px/F,py/F,pz/F".

Parameters
schStringThe schema definition string to parse.

Definition at line 17 of file dictionary.cpp.

◆ show()

void hipo::schema::show ( )

Print the schema to standard output.

Definition at line 67 of file dictionary.cpp.


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