68 std::vector<char> structureBuffer;
69 char *structureAddress{};
70 void setAddress(
const char *address);
97 structure(
int __group,
int __item, std::string &str);
107 int length = *
reinterpret_cast<uint32_t *
>(structureAddress+4);
114 int length = *
reinterpret_cast<uint32_t *
>(structureAddress+4);
132 void init(
const char *buffer,
int size);
136 void initNoCopy(
const char *buffer,
int size);
141 virtual void show()
const;
155 return *
reinterpret_cast<int32_t*
>(&structureAddress[index+
dataOffset]);
161 return *
reinterpret_cast<int16_t*
>(&structureAddress[index+
dataOffset]);
166 return *
reinterpret_cast<int8_t*
>(&structureAddress[index+
dataOffset]);
171 return *
reinterpret_cast<float*
>(&structureAddress[index+
dataOffset]);
176 return *
reinterpret_cast<double*
>(&structureAddress[index+
dataOffset]);
181 return *
reinterpret_cast<int64_t*
>(&structureAddress[index+
dataOffset]);
192 *
reinterpret_cast<int32_t*
>(&structureAddress[index+
dataOffset]) = value;
199 *
reinterpret_cast<int16_t*
>(&structureAddress[index+
dataOffset]) = value;
206 *
reinterpret_cast<int8_t*
>(&structureAddress[index+
dataOffset]) = value;
213 *
reinterpret_cast<float*
>(&structureAddress[index+
dataOffset]) = value;
220 *
reinterpret_cast<double*
>(&structureAddress[index+
dataOffset]) = value;
227 *
reinterpret_cast<int64_t*
>(&structureAddress[index+
dataOffset]) = value;
249 std::vector<char> typeChars;
250 std::vector<int> offsets;
251 std::vector<int> types;
255 int getTypeSize(
int type);
283 void parse(std::string format);
312 int getInt (
int element,
int row)
const noexcept;
316 int64_t
getLong (
int element,
int row)
const noexcept;
320 float getFloat (
int element,
int row)
const noexcept;
325 void putInt (
int element,
int row,
int value);
330 void putLong (
int element,
int row, int64_t value);
335 void putFloat (
int element,
int row,
float value);
367 void reset(
int numRows = -1);
378 void filter(std::function<
bool(
bank&,
int)> func);
381 void filter(
char const* expression);
396 bank* m_owner_bank{
nullptr};
398 static list_t s_number_list_init(list_t::size_type num = 500);
399 static list_t s_number_list;
401 bool ownerBankIsUnknown(std::string_view caller =
"");
423 bankSchema = __schema;
433 bankSchema = __schema;
435 int size = bankSchema.getSizeForRows(__rows);
437 bankRowList.reset(bankRows);
446 int getRows() const noexcept{
return bankRows;}
453 int getInt(
int item,
int index)
const noexcept;
457 int getShort(
int item,
int index)
const noexcept;
461 int getByte(
int item,
int index)
const noexcept;
465 float getFloat(
int item,
int index)
const noexcept;
469 double getDouble(
int item,
int index)
const noexcept;
473 long getLong(
int item,
int index)
const noexcept;
477 std::vector<int>
getInt(
int item)
const noexcept;
480 std::vector<float>
getFloat(
int item)
const noexcept;
483 std::vector<double>
getDouble(
int item)
const noexcept;
492 template<
typename T =
double> T
get(
int item,
int index)
const noexcept {
493 auto type = bankSchema.getEntryType(item);
494 auto offset = bankSchema.getOffset(item, index, bankRows);
503 printf(
"---> error(get) : unknown type for [%s] type = %d\n", bankSchema.getEntryName(item).c_str(), type);
511 int getInt(
const char *name,
int index)
const noexcept;
515 int getShort(
const char *name,
int index)
const noexcept;
519 int getByte(
const char *name,
int index)
const noexcept;
523 float getFloat(
const char *name,
int index)
const noexcept;
527 double getDouble(
const char *name,
int index)
const noexcept;
531 long getLong(
const char *name,
int index)
const noexcept;
535 std::vector<int>
getInt(
const char *name)
const noexcept;
538 std::vector<float>
getFloat(
const char *name)
const noexcept;
541 std::vector<double>
getDouble(
const char *name)
const noexcept;
550 template<
typename T =
double> T
get(
const char *name,
int index)
const noexcept {
551 return get<T>(bankSchema.getEntryOrder(name), index);
558 void putInt(
const char *name,
int index, int32_t value);
563 void putShort(
const char *name,
int index, int16_t value);
568 void putByte(
const char *name,
int index, int8_t value);
573 void putFloat(
const char *name,
int index,
float value);
578 void putDouble(
const char *name,
int index,
double value);
583 void putLong(
const char *name,
int index, int64_t value);
591 template<
typename T>
void put(
const char *name,
int index, T value) {
592 put(bankSchema.getEntryOrder(name), index, value);
599 void putInt(
int item,
int index, int32_t value);
604 void putShort(
int item,
int index, int16_t value);
609 void putByte(
int item,
int index, int8_t value);
614 void putFloat(
int item,
int index,
float value);
619 void putDouble(
int item,
int index,
double value);
624 void putLong(
int item,
int index, int64_t value);
632 template<
typename T>
void put(
int item,
int index, T value) {
633 auto type = bankSchema.getEntryType(item);
635 case kByte:
putByte(item, index,
static_cast<int8_t
>(value));
break;
636 case kShort:
putShort(item, index,
static_cast<int16_t
>(value));
break;
637 case kInt:
putInt(item, index,
static_cast<int32_t
>(value));
break;
638 case kFloat:
putFloat(item, index,
static_cast<float>(value));
break;
640 case kLong:
putLong(item, index,
static_cast<int64_t
>(value));
break;
642 printf(
"---> error(put) : unknown type for [%s] type = %d\n", bankSchema.getEntryName(item).c_str(), type);
664 void show()
const override;
669 void show(
bool const showAllRows)
const;
674 void printValue(
int schemaEntry,
int row)
const;
687 if(bankSchema.getEntryType(item)==
kFloat){
688 int offset = bankSchema.getOffset(item, index, bankRows);
689 return getFloatAt(offset);
695 if(bankSchema.getEntryType(item)==
kDouble){
696 int offset = bankSchema.getOffset(item, index, bankRows);
697 return getDoubleAt(offset);
699 if(bankSchema.getEntryType(item)==
kFloat){
700 int offset = bankSchema.getOffset(item, index, bankRows);
701 return getFloatAt(offset);
707 if(bankSchema.getEntryType(item)==
kLong){
708 int offset = bankSchema.getOffset(item, index, bankRows);
709 return getLongAt(offset);
715 int type = bankSchema.getEntryType(item);
716 int offset = bankSchema.getOffset(item, index, bankRows);
718 case kByte:
return (
int) getByteAt(offset);
719 case kShort:
return (
int) getShortAt(offset);
720 case kInt:
return getIntAt(offset);
721 default: printf(
"---> error : requested INT for [%s] type = %d\n",
722 bankSchema.getEntryName(item).c_str(),type);
break;
728 int type = bankSchema.getEntryType(item);
730 std::vector<int> row;
731 int nrows = getRows();
733 for(
int j = 0; j < nrows; j++){
734 int offset = bankSchema.getOffset(item, j, bankRows);
736 case kByte: row.push_back((
int) getByteAt(offset));
break;
737 case kShort: row.push_back((
int) getShortAt(offset));
break;
738 case kInt: row.push_back((
int) getIntAt(offset));
break;
739 default: printf(
"---> error : requested INT for [%s] type = %d\n",
740 bankSchema.getEntryName(item).c_str(),type);
break;
747 int type = bankSchema.getEntryType(item);
748 int offset = bankSchema.getOffset(item, index, bankRows);
750 case kByte:
return (
int) getByteAt(offset);
751 case kShort:
return (
int) getShortAt(offset);
752 default: printf(
"---> error : requested SHORT for [%s] type = %d\n",
753 bankSchema.getEntryName(item).c_str(),type);
break;
759 int type = bankSchema.getEntryType(item);
760 int offset = bankSchema.getOffset(item, index, bankRows);
762 case kByte:
return (
int) getByteAt(offset);
763 default: printf(
"---> error : requested BYTE for [%s] type = %d\n",
764 bankSchema.getEntryName(item).c_str(),type);
break;
769 int item = bankSchema.getEntryOrder(name);
770 int type = bankSchema.getEntryType(item);
771 int offset = bankSchema.getOffset(item, index, bankRows);
773 case kByte:
return (
int) getByteAt(offset);
774 case kShort:
return (
int) getShortAt(offset);
775 case kInt:
return getIntAt(offset);
776 default: printf(
"---> error : requested INT for [%s] type = %d\n",name,type);
break;
782 int item = bankSchema.getEntryOrder(name);
783 int type = bankSchema.getEntryType(item);
784 std::vector<int> row;
786 int nrows = getRows();
787 for(
int j = 0; j < nrows; j++){
788 int offset = bankSchema.getOffset(item, j, bankRows);
790 case kByte: row.push_back((
int) getByteAt(offset));
break;
791 case kShort: row.push_back((
int) getShortAt(offset));
break;
792 case kInt: row.push_back((
int) getIntAt(offset));
break;
793 default: printf(
"---> error : requested INT for [%s] type = %d\n",name,type);
break;
800 int item = bankSchema.getEntryOrder(name);
801 int type = bankSchema.getEntryType(item);
802 int offset = bankSchema.getOffset(item, index, bankRows);
804 case kByte:
return (
int) getByteAt(offset);
805 case kShort:
return (
int) getShortAt(offset);
806 default: printf(
"---> error : requested SHORT for [%s] type = %d\n",
807 bankSchema.getEntryName(item).c_str(),type);
break;
812 int item = bankSchema.getEntryOrder(name);
813 int type = bankSchema.getEntryType(item);
814 int offset = bankSchema.getOffset(item, index, bankRows);
816 case kByte:
return (
int) getByteAt(offset);
817 default: printf(
"---> error : requested BYTE for [%s] type = %d\n",
818 bankSchema.getEntryName(item).c_str(),type);
break;
824 int item = bankSchema.getEntryOrder(name);
825 if(bankSchema.getEntryType(item)==
kFloat){
826 int offset = bankSchema.getOffset(item, index, bankRows);
827 return getFloatAt(offset);
833 int item = bankSchema.getEntryOrder(name);
834 std::vector<float> row;
835 int nrows = getRows();
836 if(bankSchema.getEntryType(item)==
kFloat){
837 for(
int j = 0; j < nrows; j++){
838 int offset = bankSchema.getOffset(item, j, bankRows);
839 row.push_back( getFloatAt(offset));
846 std::vector<float> row;
847 int nrows = getRows();
848 if(bankSchema.getEntryType(item)==
kFloat){
849 for(
int j = 0; j < nrows; j++){
850 int offset = bankSchema.getOffset(item, j, bankRows);
851 row.push_back( getFloatAt(offset));
857 int item = bankSchema.getEntryOrder(name);
858 if(bankSchema.getEntryType(item)==
kDouble){
859 int offset = bankSchema.getOffset(item, index, bankRows);
860 return getDoubleAt(offset);
862 if(bankSchema.getEntryType(item)==
kFloat){
863 int offset = bankSchema.getOffset(item, index, bankRows);
864 return (
double) getFloatAt(offset);
870 std::vector<double> row;
871 int nrows = getRows();
873 if(bankSchema.getEntryType(item)==
kDouble){
874 for(
int j = 0; j < nrows; j++){
875 int offset = bankSchema.getOffset(item, j, bankRows);
876 row.push_back(getDoubleAt(offset));
879 if(bankSchema.getEntryType(item)==
kFloat){
880 for(
int j = 0; j < nrows; j++){
881 int offset = bankSchema.getOffset(item, j, bankRows);
882 row.push_back((
double) getFloatAt(offset));
889 std::vector<double> row;
890 int nrows = getRows();
891 int item = bankSchema.getEntryOrder(name);
893 if(bankSchema.getEntryType(item)==
kDouble){
894 for(
int j = 0; j < nrows; j++){
895 int offset = bankSchema.getOffset(item, j, bankRows);
896 row.push_back(getDoubleAt(offset));
899 if(bankSchema.getEntryType(item)==
kFloat){
900 for(
int j = 0; j < nrows; j++){
901 int offset = bankSchema.getOffset(item, j, bankRows);
902 row.push_back((
double) getFloatAt(offset));
909 int item = bankSchema.getEntryOrder(name);
910 if(bankSchema.getEntryType(item)==
kLong){
911 int offset = bankSchema.getOffset(item, index, bankRows);
912 return getLongAt(offset);
918 int offset = bankSchema.
getOffset(item, index, bankRows);
923 int offset = bankSchema.
getOffset(item, index, bankRows);
928 int offset = bankSchema.
getOffset(item, index, bankRows);
933 int offset = bankSchema.
getOffset(item, index, bankRows);
939 int offset = bankSchema.
getOffset(item, index, bankRows);
944 int offset = bankSchema.
getOffset(item, index, bankRows);
Mathematical expression parser and evaluator.
rowlist encapsulates a list of rows for this bank, providing a way to iterate over them
list_t const & getList() const
void setOwnerBank(bank *const ownerBank)
void reset(int numRows=-1)
void filter(std::function< bool(bank &, int)> func)
void setList(list_t const &list)
bool isInitialized() const
std::vector< int > list_t
static list_t createFullList(int num)
Represents a HIPO bank, a tabular data structure with rows and typed columns.
void putByte(const char *name, int index, int8_t value)
void reset()
Reset the bank to an empty state (zero rows).
void put(const char *name, int index, T value)
Generic setter by column name, dispatches to the typed put method.
rowlist::list_t const & getRowList() const
void putFloat(const char *name, int index, float value)
bank(const schema &__schema, int __rows)
Construct a bank from a schema with a specified number of rows.
T get(int item, int index) const noexcept
Generic getter that returns the value at the given column and row.
rowlist & getMutableRowList()
int getInt(int item, int index) const noexcept
void putShort(const char *name, int index, int16_t value)
bank()
Default constructor.
void notify() override
Called when the bank is updated; recalculates the row count from the schema.
void putLong(const char *name, int index, int64_t value)
long getLong(int item, int index) const noexcept
void printValue(int schemaEntry, int row) const
int getRows() const noexcept
void put(int item, int index, T value)
Generic setter by column index, dispatches to the typed put method.
void putDouble(const char *name, int index, double value)
T get(const char *name, int index) const noexcept
Generic getter that returns the value at the given column name and row.
int getShort(int item, int index) const noexcept
void show() const override
show this bank's contents; only the rows in its current rowlist instance are shown
bank(const schema &__schema)
Construct a bank from a schema.
float getFloat(int item, int index) const noexcept
int getByte(int item, int index) const noexcept
rowlist::list_t const getFullRowList() const
void putInt(const char *name, int index, int32_t value)
double getDouble(int item, int index) const noexcept
rowlist::list_t const getRowListLinked(int const row, int const column) const
int getRows() const noexcept
int getInt(int element, int row) const noexcept
composite(const char *format)
virtual void notify()
Called when the composite is updated (e.g., after reading an event).
int getEntries() const noexcept
composite(int group, int item, int size)
void print()
Print the composite contents to standard output.
void putLong(int element, int row, int64_t value)
float getFloat(int element, int row) const noexcept
void putInt(int element, int row, int value)
int getEntryType(int index) const noexcept
void parse(std::string format)
void reset()
Reset the composite to an empty state.
int getRowSize() const noexcept
int64_t getLong(int element, int row) const noexcept
void putFloat(int element, int row, float value)
composite()
Default constructor.
Represents a HIPO event, a container for multiple structures/banks.
Low-level node representing a tagged data element in a HIPO structure.
int size() const noexcept
int capacity() const noexcept
int dataLength() const noexcept
bool allocate(int size)
Ensure the internal buffer can hold at least size bytes.
Schema definition for a HIPO bank.
int getOffset(int item, int order, int rows) const
Compute the byte offset for a column value by column index.
Low-level data structure representing a HIPO structure.
float getFloatAt(int index) const noexcept
void initStructureBySize(int __group, int __item, int __type, int __size)
Initialize the structure buffer with the given group, item, type, and data size.
void putShortAt(int index, int16_t value)
int getSize() const noexcept
void putIntAt(int index, int value)
int getDataSize() const noexcept
void putByteAt(int index, int8_t value)
virtual ~structure()=default
void putStringAt(int index, std::string &str)
structure()
Default constructor. Sets the structure address to nullptr.
int getStructureBufferSize()
int16_t getShortAt(int index) const noexcept
virtual void show() const
Display the structure contents to standard output.
void putLongAt(int index, int64_t value)
long getLongAt(int index) const noexcept
void initNoCopy(const char *buffer, int size)
int8_t getByteAt(int index) const noexcept
int getIntAt(int index) const noexcept
void setDataSize(int size)
void putDoubleAt(int index, double value)
std::vector< char > & getStructureBuffer()
virtual void notify()
Called when the structure is updated (e.g., after reading an event).
void putFloatAt(int index, float value)
int getHeaderSize() const noexcept
void init(const char *buffer, int size)
double getDoubleAt(int index) const noexcept
std::string getStringAt(int index)
void setHeaderSize(int size)
const char * getAddress()
N-tuple writer for storing columnar float data in HIPO files.
Schema definitions and schema dictionary for HIPO banks.
@ kLong
64-bit signed integer.
@ kInt
32-bit signed integer.
@ kFloat
32-bit IEEE 754 floating point.
@ kShort
16-bit signed integer.
@ kByte
8-bit signed integer.
@ kDouble
64-bit IEEE 754 floating point.
constexpr uint32_t STRUCT_FORMAT_BYTE
constexpr int STRUCT_FORMAT_SHIFT
std::vector< bank > banklist
banklist::size_type getBanklistIndex(banklist &banks, std::string const &bankName) noexcept(false)
Find the index of a bank by name in a banklist.
constexpr uint32_t STRUCT_SIZE_MASK
Low-level node class for handling tagged binary data elements in HIPO structures.