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

Represents a HIPO bank, a tabular data structure with rows and typed columns. More...

#include <bank.h>

+ Inheritance diagram for hipo::bank:

Classes

class  rowlist
 rowlist encapsulates a list of rows for this bank, providing a way to iterate over them More...
 

Public Member Functions

 bank ()
 Default constructor. More...
 
 bank (const schema &__schema)
 Construct a bank from a schema. More...
 
 bank (const schema &__schema, int __rows)
 Construct a bank from a schema with a specified number of rows. More...
 
 ~bank () override
 
schemagetSchema ()
 
int getRows () const noexcept
 
void setRows (int rows)
 
int getInt (int item, int index) const noexcept
 
int getShort (int item, int index) const noexcept
 
int getByte (int item, int index) const noexcept
 
float getFloat (int item, int index) const noexcept
 
double getDouble (int item, int index) const noexcept
 
long getLong (int item, int index) const noexcept
 
std::vector< int > getInt (int item) const noexcept
 
std::vector< float > getFloat (int item) const noexcept
 
std::vector< double > getDouble (int item) const noexcept
 
template<typename T = double>
get (int item, int index) const noexcept
 Generic getter that returns the value at the given column and row. More...
 
int getInt (const char *name, int index) const noexcept
 
int getShort (const char *name, int index) const noexcept
 
int getByte (const char *name, int index) const noexcept
 
float getFloat (const char *name, int index) const noexcept
 
double getDouble (const char *name, int index) const noexcept
 
long getLong (const char *name, int index) const noexcept
 
std::vector< int > getInt (const char *name) const noexcept
 
std::vector< float > getFloat (const char *name) const noexcept
 
std::vector< double > getDouble (const char *name) const noexcept
 
template<typename T = double>
get (const char *name, int index) const noexcept
 Generic getter that returns the value at the given column name and row. More...
 
void putInt (const char *name, int index, int32_t value)
 
void putShort (const char *name, int index, int16_t value)
 
void putByte (const char *name, int index, int8_t value)
 
void putFloat (const char *name, int index, float value)
 
void putDouble (const char *name, int index, double value)
 
void putLong (const char *name, int index, int64_t value)
 
template<typename T >
void put (const char *name, int index, T value)
 Generic setter by column name, dispatches to the typed put method. More...
 
void putInt (int item, int index, int32_t value)
 
void putShort (int item, int index, int16_t value)
 
void putByte (int item, int index, int8_t value)
 
void putFloat (int item, int index, float value)
 
void putDouble (int item, int index, double value)
 
void putLong (int item, int index, int64_t value)
 
template<typename T >
void put (int item, int index, T value)
 Generic setter by column index, dispatches to the typed put method. More...
 
rowlist::list_t const & getRowList () const
 
rowlist::list_t const getFullRowList () const
 
rowlistgetMutableRowList ()
 
rowlist::list_t const getRowListLinked (int const row, int const column) const
 
void show () const override
 show this bank's contents; only the rows in its current rowlist instance are shown More...
 
void show (bool const showAllRows) const
 
void printValue (int schemaEntry, int row) const
 
void reset ()
 Reset the bank to an empty state (zero rows). More...
 
void notify () override
 Called when the bank is updated; recalculates the row count from the schema. More...
 
- Public Member Functions inherited from hipo::structure
 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 ()
 
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)
 

Additional Inherited Members

- Protected Member Functions inherited from hipo::structure
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 inherited from hipo::structure
int dataOffset = 8
 

Detailed Description

Represents a HIPO bank, a tabular data structure with rows and typed columns.

A bank is defined by a schema that describes its columns (entries) and their types. It extends structure to provide typed access to bank data by column name or index.

Definition at line 352 of file bank.h.

Constructor & Destructor Documentation

◆ bank() [1/3]

hipo::bank::bank ( )
default

Default constructor.

◆ bank() [2/3]

hipo::bank::bank ( const schema __schema)
inline

Construct a bank from a schema.

The bank nodes are initialized from the schema and will be filled automatically by reader.next().

Parameters
__schemathe bank schema

Definition at line 422 of file bank.h.

◆ bank() [3/3]

hipo::bank::bank ( const schema __schema,
int  __rows 
)
inline

Construct a bank from a schema with a specified number of rows.

Parameters
__schemathe bank schema
__rowsthe number of rows to allocate

Definition at line 432 of file bank.h.

◆ ~bank()

hipo::bank::~bank ( )
overridedefault

Member Function Documentation

◆ get() [1/2]

template<typename T = double>
T hipo::bank::get ( const char *  name,
int  index 
) const
inlinenoexcept

Generic getter that returns the value at the given column name and row.

Template Parameters
Tthe return type (default: double)
Parameters
namethe column name
indexthe row index
Returns
the value cast to type T

Definition at line 550 of file bank.h.

◆ get() [2/2]

template<typename T = double>
T hipo::bank::get ( int  item,
int  index 
) const
inlinenoexcept

Generic getter that returns the value at the given column and row.

Template Parameters
Tthe return type (default: double)
Parameters
itemthe column index
indexthe row index
Returns
the value cast to type T

Definition at line 492 of file bank.h.

◆ getByte() [1/2]

int hipo::bank::getByte ( const char *  name,
int  index 
) const
inlinenoexcept
Returns
the byte value (as int) for the given column name and row.
Parameters
namethe column name
indexthe row index

Definition at line 811 of file bank.h.

◆ getByte() [2/2]

int hipo::bank::getByte ( int  item,
int  index 
) const
inlinenoexcept
Returns
the byte value (as int) for the given column and row.
Parameters
itemthe column index
indexthe row index

Definition at line 758 of file bank.h.

◆ getDouble() [1/4]

std::vector< double > hipo::bank::getDouble ( const char *  name) const
inlinenoexcept
Returns
a vector of all double values for the given column name.
Parameters
namethe column name

Definition at line 888 of file bank.h.

◆ getDouble() [2/4]

double hipo::bank::getDouble ( const char *  name,
int  index 
) const
inlinenoexcept
Returns
the double value for the given column name and row.
Parameters
namethe column name
indexthe row index

Definition at line 856 of file bank.h.

◆ getDouble() [3/4]

std::vector< double > hipo::bank::getDouble ( int  item) const
inlinenoexcept
Returns
a vector of all double values for the given column.
Parameters
itemthe column index

Definition at line 869 of file bank.h.

◆ getDouble() [4/4]

double hipo::bank::getDouble ( int  item,
int  index 
) const
inlinenoexcept
Returns
the double value for the given column and row.
Parameters
itemthe column index
indexthe row index

Definition at line 694 of file bank.h.

◆ getFloat() [1/4]

std::vector< float > hipo::bank::getFloat ( const char *  name) const
inlinenoexcept
Returns
a vector of all float values for the given column name.
Parameters
namethe column name

Definition at line 832 of file bank.h.

◆ getFloat() [2/4]

float hipo::bank::getFloat ( const char *  name,
int  index 
) const
inlinenoexcept
Returns
the float value for the given column name and row.
Parameters
namethe column name
indexthe row index

Definition at line 823 of file bank.h.

◆ getFloat() [3/4]

std::vector< float > hipo::bank::getFloat ( int  item) const
inlinenoexcept
Returns
a vector of all float values for the given column.
Parameters
itemthe column index

Definition at line 845 of file bank.h.

◆ getFloat() [4/4]

float hipo::bank::getFloat ( int  item,
int  index 
) const
inlinenoexcept
Returns
the float value for the given column and row.
Parameters
itemthe column index
indexthe row index

Definition at line 686 of file bank.h.

◆ getFullRowList()

bank::rowlist::list_t const hipo::bank::getFullRowList ( ) const
Returns
an immutable list of all rows in the bank; cf. hipo::bank::rowlist::getRowList. This method may be less efficient than simply using a for loop from 0 to getRows()

Definition at line 498 of file bank.cpp.

◆ getInt() [1/4]

std::vector< int > hipo::bank::getInt ( const char *  name) const
inlinenoexcept
Returns
a vector of all integer values for the given column name.
Parameters
namethe column name

Definition at line 781 of file bank.h.

◆ getInt() [2/4]

int hipo::bank::getInt ( const char *  name,
int  index 
) const
inlinenoexcept
Returns
the integer value for the given column name and row.
Parameters
namethe column name
indexthe row index

Definition at line 768 of file bank.h.

◆ getInt() [3/4]

std::vector< int > hipo::bank::getInt ( int  item) const
inlinenoexcept
Returns
a vector of all integer values for the given column.
Parameters
itemthe column index

Definition at line 727 of file bank.h.

◆ getInt() [4/4]

int hipo::bank::getInt ( int  item,
int  index 
) const
inlinenoexcept
Returns
the integer value for the given column and row.
Parameters
itemthe column index
indexthe row index

Definition at line 714 of file bank.h.

◆ getLong() [1/2]

long hipo::bank::getLong ( const char *  name,
int  index 
) const
inlinenoexcept
Returns
the long value for the given column name and row.
Parameters
namethe column name
indexthe row index

Definition at line 908 of file bank.h.

◆ getLong() [2/2]

long hipo::bank::getLong ( int  item,
int  index 
) const
inlinenoexcept
Returns
the long value for the given column and row.
Parameters
itemthe column index
indexthe row index

Definition at line 706 of file bank.h.

◆ getMutableRowList()

bank::rowlist & hipo::bank::getMutableRowList ( )
Returns
a reference to the mutable hipo::bank::rowlist owned by this bank. For example, use this method to call hipo::bank::rowlist::filter.

Definition at line 502 of file bank.cpp.

◆ getRowList()

bank::rowlist::list_t const & hipo::bank::getRowList ( ) const
Returns
an immutable list of available rows for this bank. This list may be a subset of the full list of rows, if for example the bank was filtered (see hipo::bank::rowlist::filter); cf. hipo::bank::rowlist::getFullRowList

Definition at line 494 of file bank.cpp.

◆ getRowListLinked()

bank::rowlist::list_t const hipo::bank::getRowListLinked ( int const  row,
int const  column 
) const
Returns
a hipo::bank::rowlist for this bank, for rows r such that getInt(column,r) == row
Parameters
rowthe value to check
columnthe column to check (must be an integer-type column, e.g., that of "pindex")

Definition at line 507 of file bank.cpp.

◆ getRows()

int hipo::bank::getRows ( ) const
inlinenoexcept
Returns
the number of rows in this bank.

Definition at line 446 of file bank.h.

◆ getSchema()

schema& hipo::bank::getSchema ( )
inline
Returns
a reference to this bank's schema.

Definition at line 443 of file bank.h.

◆ getShort() [1/2]

int hipo::bank::getShort ( const char *  name,
int  index 
) const
inlinenoexcept
Returns
the short value (as int) for the given column name and row.
Parameters
namethe column name
indexthe row index

Definition at line 799 of file bank.h.

◆ getShort() [2/2]

int hipo::bank::getShort ( int  item,
int  index 
) const
inlinenoexcept
Returns
the short value (as int) for the given column and row.
Parameters
itemthe column index
indexthe row index

Definition at line 746 of file bank.h.

◆ notify()

void hipo::bank::notify ( )
overridevirtual

Called when the bank is updated; recalculates the row count from the schema.

Reimplemented from hipo::structure.

Definition at line 453 of file bank.cpp.

◆ printValue()

void hipo::bank::printValue ( int  schemaEntry,
int  row 
) const

print a stored value

Parameters
schemaEntrythe schema entry number
rowthe row number

Definition at line 540 of file bank.cpp.

◆ put() [1/2]

template<typename T >
void hipo::bank::put ( const char *  name,
int  index,
value 
)
inline

Generic setter by column name, dispatches to the typed put method.

Template Parameters
Tthe value type
Parameters
namethe column name
indexthe row index
valuethe value to store

Definition at line 591 of file bank.h.

◆ put() [2/2]

template<typename T >
void hipo::bank::put ( int  item,
int  index,
value 
)
inline

Generic setter by column index, dispatches to the typed put method.

Template Parameters
Tthe value type
Parameters
itemthe column index
indexthe row index
valuethe value to store

Definition at line 632 of file bank.h.

◆ putByte() [1/2]

void hipo::bank::putByte ( const char *  name,
int  index,
int8_t  value 
)

Store a byte value by column name and row.

Parameters
namethe column name
indexthe row index
valuethe value to store

Definition at line 472 of file bank.cpp.

◆ putByte() [2/2]

void hipo::bank::putByte ( int  item,
int  index,
int8_t  value 
)
inline

Store a byte value by column index and row.

Parameters
itemthe column index
indexthe row index
valuethe value to store

Definition at line 926 of file bank.h.

◆ putDouble() [1/2]

void hipo::bank::putDouble ( const char *  name,
int  index,
double  value 
)

Store a double value by column name and row.

Parameters
namethe column name
indexthe row index
valuethe value to store

Definition at line 482 of file bank.cpp.

◆ putDouble() [2/2]

void hipo::bank::putDouble ( int  item,
int  index,
double  value 
)
inline

Store a double value by column index and row.

Parameters
itemthe column index
indexthe row index
valuethe value to store

Definition at line 937 of file bank.h.

◆ putFloat() [1/2]

void hipo::bank::putFloat ( const char *  name,
int  index,
float  value 
)

Store a float value by column name and row.

Parameters
namethe column name
indexthe row index
valuethe value to store

Definition at line 477 of file bank.cpp.

◆ putFloat() [2/2]

void hipo::bank::putFloat ( int  item,
int  index,
float  value 
)
inline

Store a float value by column index and row.

Parameters
itemthe column index
indexthe row index
valuethe value to store

Definition at line 931 of file bank.h.

◆ putInt() [1/2]

void hipo::bank::putInt ( const char *  name,
int  index,
int32_t  value 
)

Store an integer value by column name and row.

Parameters
namethe column name
indexthe row index
valuethe value to store

Definition at line 462 of file bank.cpp.

◆ putInt() [2/2]

void hipo::bank::putInt ( int  item,
int  index,
int32_t  value 
)
inline

Store an integer value by column index and row.

Parameters
itemthe column index
indexthe row index
valuethe value to store

Definition at line 916 of file bank.h.

◆ putLong() [1/2]

void hipo::bank::putLong ( const char *  name,
int  index,
int64_t  value 
)

Store a long value by column name and row.

Parameters
namethe column name
indexthe row index
valuethe value to store

Definition at line 488 of file bank.cpp.

◆ putLong() [2/2]

void hipo::bank::putLong ( int  item,
int  index,
int64_t  value 
)
inline

Store a long value by column index and row.

Parameters
itemthe column index
indexthe row index
valuethe value to store

Definition at line 942 of file bank.h.

◆ putShort() [1/2]

void hipo::bank::putShort ( const char *  name,
int  index,
int16_t  value 
)

Store a short value by column name and row.

Parameters
namethe column name
indexthe row index
valuethe value to store

Definition at line 467 of file bank.cpp.

◆ putShort() [2/2]

void hipo::bank::putShort ( int  item,
int  index,
int16_t  value 
)
inline

Store a short value by column index and row.

Parameters
itemthe column index
indexthe row index
valuethe value to store

Definition at line 921 of file bank.h.

◆ reset()

void hipo::bank::reset ( )

Reset the bank to an empty state (zero rows).

Definition at line 447 of file bank.cpp.

◆ setRows()

void hipo::bank::setRows ( int  rows)

Set the number of rows and resize the underlying structure.

Parameters
rowsthe new number of rows

Definition at line 439 of file bank.cpp.

◆ show() [1/2]

void hipo::bank::show ( ) const
overridevirtual

show this bank's contents; only the rows in its current rowlist instance are shown

Reimplemented from hipo::structure.

Definition at line 516 of file bank.cpp.

◆ show() [2/2]

void hipo::bank::show ( bool const  showAllRows) const

show this bank's contents

Parameters
showAllRowsif true, show all this bank's rows, otherwise just the rows in its rowlist instance, which may have been reduced by, e.g., hipo::bank::rowlist::filter

Definition at line 520 of file bank.cpp.


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