HIPO  4.3.0
High Performance Output data format for experimental physics
bank.h
Go to the documentation of this file.
1 //******************************************************************************
2 //* ██╗ ██╗██╗██████╗ ██████╗ ██╗ ██╗ ██████╗ *
3 //* ██║ ██║██║██╔══██╗██╔═══██╗ ██║ ██║ ██╔═████╗ *
4 //* ███████║██║██████╔╝██║ ██║ ███████║ ██║██╔██║ *
5 //* ██╔══██║██║██╔═══╝ ██║ ██║ ╚════██║ ████╔╝██║ *
6 //* ██║ ██║██║██║ ╚██████╔╝ ██║██╗╚██████╔╝ *
7 //* ╚═╝ ╚═╝╚═╝╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═════╝ *
8 //************************ Jefferson National Lab (2017) ***********************
9 /*
10  * Copyright (c) 2017. Jefferson Lab (JLab). All rights reserved. Permission
11  * to use, copy, modify, and distribute this software and its documentation
12  * for educational, research, and not-for-profit purposes, without fee and
13  * without a signed licensing agreement.
14  *
15  * IN NO EVENT SHALL JLAB BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL
16  * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING
17  * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JLAB HAS
18  * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19  *
20  * JLAB SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE. THE HIPO DATA FORMAT SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
23  * ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". JLAB HAS NO OBLIGATION TO
24  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
25  *
26  * This software was developed under the United States Government license.
27  * For more information contact author at gavalian@jlab.org
28  * Department of Experimental Nuclear Physics, Jefferson Lab.
29  */
32 
33 /*******************************************************************************
34  * File: bank.h
35  * Author: gavalian
36  *
37  * Created on April 12, 2017, 10:14 AM
38  */
39 
40 #ifndef HIPO_BANK_H
41 #define HIPO_BANK_H
42 #include <iostream>
43 #include <vector>
44 #include <cstring>
45 #include <cstdint>
46 #include <cstdio>
47 #include <cstdlib>
48 #include <map>
49 #include <functional>
50 #include "dictionary.h"
51 #include "node.h"
52 
53 namespace hipo {
54 
55  class Parser; // forward declaration
56 
58 
64  class structure {
65 
66  private:
67 
68  std::vector<char> structureBuffer;
69  char *structureAddress{};
70  void setAddress(const char *address);
71 
72  protected:
73 
75  void initStructureBySize(int __group, int __item, int __type, int __size);
77  std::vector<char> &getStructureBuffer(){ return structureBuffer;}
79  int getStructureBufferSize(){ return 8+getSize();}
80  int dataOffset = 8;
81  //std::vector<char> structureBuffer;
82  friend class tuple;
83 
84  public:
85 
87  structure(){ structureAddress = nullptr;}
90  structure(int size){ allocate(size);}
97  structure(int __group, int __item, std::string &str);
98 
99  virtual ~structure()= default;
103  bool allocate(int size);
104 
106  int getSize() const noexcept{
107  int length = *reinterpret_cast<uint32_t *>(structureAddress+4);
108  return length&STRUCT_SIZE_MASK;
109  //return getHeaderSize()+getDataSize();
110  }
111 
113  int getHeaderSize() const noexcept {
114  int length = *reinterpret_cast<uint32_t *>(structureAddress+4);
115  return (length>>STRUCT_FORMAT_SHIFT)&STRUCT_FORMAT_BYTE;
116  }
117 
119  int getDataSize() const noexcept {
120  return getSize()-getHeaderSize();
121  }
122 
124  int getType() const;
126  int getGroup() const;
128  int getItem() const;
132  void init(const char *buffer, int size);
136  void initNoCopy(const char *buffer, int size);
137 
139  const char *getAddress();
141  virtual void show() const;
144  void setSize(int size);
147  void setHeaderSize(int size);
150  void setDataSize(int size);
151 
154  int getIntAt ( int index) const noexcept {
155  return *reinterpret_cast<int32_t*>(&structureAddress[index+dataOffset]);
156  }
157 
160  int16_t getShortAt ( int index) const noexcept {
161  return *reinterpret_cast<int16_t*>(&structureAddress[index+dataOffset]);
162  }
165  int8_t getByteAt ( int index) const noexcept {
166  return *reinterpret_cast<int8_t*>(&structureAddress[index+dataOffset]);
167  }
170  float getFloatAt ( int index) const noexcept {
171  return *reinterpret_cast<float*>(&structureAddress[index+dataOffset]);
172  }
175  double getDoubleAt( int index) const noexcept {
176  return *reinterpret_cast<double*>(&structureAddress[index+dataOffset]);
177  }
180  long getLongAt ( int index) const noexcept {
181  return *reinterpret_cast<int64_t*>(&structureAddress[index+dataOffset]);
182  }
183 
186  std::string getStringAt(int index);
187 
191  void putIntAt(int index, int value){
192  *reinterpret_cast<int32_t*>(&structureAddress[index+dataOffset]) = value;
193  }
194 
198  void putShortAt(int index, int16_t value){
199  *reinterpret_cast<int16_t*>(&structureAddress[index+dataOffset]) = value;
200  }
201 
205  void putByteAt(int index, int8_t value){
206  *reinterpret_cast<int8_t*>(&structureAddress[index+dataOffset]) = value;
207  }
208 
212  void putFloatAt(int index, float value){
213  *reinterpret_cast<float*>(&structureAddress[index+dataOffset]) = value;
214  }
215 
219  void putDoubleAt(int index, double value){
220  *reinterpret_cast<double*>(&structureAddress[index+dataOffset]) = value;
221  }
222 
226  void putLongAt(int index, int64_t value){
227  *reinterpret_cast<int64_t*>(&structureAddress[index+dataOffset]) = value;
228  }
229 
233  void putStringAt(int index, std::string &str);
234 
236  virtual void notify(){}
237  friend class event;
238  };
239 
241  class composite : public node {
247  private:
248 
249  std::vector<char> typeChars;
250  std::vector<int> offsets;
251  std::vector<int> types;
252  int rowOffset = 0;
253 
254  // void parse(std::string format);
255  int getTypeSize(int type);
256 
257  public:
258 
268  composite(int group, int item, int size){ /*initStructureBySize(group, item, 10, size);*/};
271  composite(const char *format){}
279  composite(int group, int item, const char *format, int capacity);
280 
283  void parse(std::string format);
289  void parse(int group, int item, std::string format, int maxrows);
290  virtual ~composite(){}
291 
295  int getRows() const noexcept { return dataLength()/rowOffset;}
296 
298  int getEntries() const noexcept { return offsets.size();}
301  int getEntryType(int index) const noexcept { return types[index];}
304  void setRows(int rows);// { setDataLength(rows*rowOffset);}
305 
307  int getRowSize() const noexcept { return rowOffset;}
308 
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);
337  virtual void notify();
339  void print();
341  void reset();
342  };
343  //typedef std::auto_ptr<hipo::generic_node> node_pointer;
344 
346 
352  class bank : public structure {
353 
354  public:
355 
357  class rowlist {
358 
359  public:
360  using list_t = std::vector<int>;
361 
362  rowlist() = default;
363  ~rowlist() = default;
364 
367  void reset(int numRows = -1);
368  bool isInitialized() const { return m_init; }
369 
371  list_t const& getList() const;
373  void setList(list_t const& list);
374 
378  void filter(std::function<bool(bank&, int)> func);
381  void filter(char const* expression);
384  void filter(Parser& parser);
385 
388  static list_t createFullList(int num);
389 
391  void setOwnerBank(bank* const ownerBank) { m_owner_bank = ownerBank; }
392 
393  private:
394  bool m_init{false};
395  list_t m_list{};
396  bank* m_owner_bank{nullptr};
397 
398  static list_t s_number_list_init(list_t::size_type num = 500);
399  static list_t s_number_list;
400 
401  bool ownerBankIsUnknown(std::string_view caller = "");
402 
403  };
404 
405  private:
406 
407  schema bankSchema;
408  int bankRows{-1};
409  rowlist bankRowList;
410 
411  public:
412 
414  bank();
422  bank(const schema& __schema){
423  bankSchema = __schema;
424  bankRows = -1;
425  }
426 
432  bank(const schema& __schema, int __rows){
433  bankSchema = __schema;
434  bankRows = __rows;
435  int size = bankSchema.getSizeForRows(__rows);
436  initStructureBySize(bankSchema.getGroup(),bankSchema.getItem(), 11, size);
437  bankRowList.reset(bankRows);
438  }
439 
440  ~bank() override;
441 
443  schema &getSchema() { return bankSchema;}
444 
446  int getRows() const noexcept{ return bankRows;}
449  void setRows( int rows);
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;
474 
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;
484 
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);
495  switch(type) {
496  case kByte: return (int) getByteAt(offset);
497  case kShort: return (int) getShortAt(offset);
498  case kInt: return getIntAt(offset);
499  case kFloat: return getFloatAt(offset);
500  case kDouble: return getDoubleAt(offset);
501  case kLong: return getLongAt(offset);
502  default:
503  printf("---> error(get) : unknown type for [%s] type = %d\n", bankSchema.getEntryName(item).c_str(), type);
504  }
505  return 0;
506  }
507 
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;
532 
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;
542 
550  template<typename T = double> T get(const char *name, int index) const noexcept {
551  return get<T>(bankSchema.getEntryOrder(name), index);
552  }
553 
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);
593  }
594 
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);
634  switch(type) {
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;
639  case kDouble: putDouble(item, index, static_cast<double>(value)); break;
640  case kLong: putLong(item, index, static_cast<int64_t>(value)); break;
641  default:
642  printf("---> error(put) : unknown type for [%s] type = %d\n", bankSchema.getEntryName(item).c_str(), type);
643  }
644  }
645 
648  rowlist::list_t const& getRowList() const;
649 
652  rowlist::list_t const getFullRowList() const;
653 
656  rowlist& getMutableRowList();
657 
661  rowlist::list_t const getRowListLinked(int const row, int const column) const;
662 
664  void show() const override;
665 
669  void show(bool const showAllRows) const;
670 
674  void printValue(int schemaEntry, int row) const;
675 
677  void reset();
678 
680  void notify() override;
681 
682  };
684  //inlined getters
685 
686  inline float bank::getFloat(int item, int index) const noexcept{
687  if(bankSchema.getEntryType(item)==kFloat){
688  int offset = bankSchema.getOffset(item, index, bankRows);
689  return getFloatAt(offset);
690  }
691  return 0.0;
692  }
693 
694  inline double bank::getDouble(int item, int index) const noexcept{
695  if(bankSchema.getEntryType(item)==kDouble){
696  int offset = bankSchema.getOffset(item, index, bankRows);
697  return getDoubleAt(offset);
698  }
699  if(bankSchema.getEntryType(item)==kFloat){
700  int offset = bankSchema.getOffset(item, index, bankRows);
701  return getFloatAt(offset);
702  }
703  return 0.0;
704  }
705 
706  inline long bank::getLong(int item, int index) const noexcept{
707  if(bankSchema.getEntryType(item)==kLong){
708  int offset = bankSchema.getOffset(item, index, bankRows);
709  return getLongAt(offset);
710  }
711  return 0;
712  }
713 
714  inline int bank::getInt(int item, int index) const noexcept{
715  int type = bankSchema.getEntryType(item);
716  int offset = bankSchema.getOffset(item, index, bankRows);
717  switch(type){
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;
723  }
724  return 0;
725  }
726 
727  inline std::vector<int> bank::getInt(int item) const noexcept{
728  int type = bankSchema.getEntryType(item);
729 
730  std::vector<int> row;
731  int nrows = getRows();
732 
733  for(int j = 0; j < nrows; j++){
734  int offset = bankSchema.getOffset(item, j, bankRows);
735  switch(type){
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;
741  }
742  }
743  return row;
744  }
745 
746  inline int bank::getShort(int item, int index) const noexcept{
747  int type = bankSchema.getEntryType(item);
748  int offset = bankSchema.getOffset(item, index, bankRows);
749  switch(type){
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;
754  }
755  return 0;
756  }
757 
758  inline int bank::getByte(int item, int index) const noexcept{
759  int type = bankSchema.getEntryType(item);
760  int offset = bankSchema.getOffset(item, index, bankRows);
761  switch(type){
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;
765  }
766  return 0;
767  }
768  inline int bank::getInt(const char *name, int index) const noexcept{
769  int item = bankSchema.getEntryOrder(name);
770  int type = bankSchema.getEntryType(item);
771  int offset = bankSchema.getOffset(item, index, bankRows);
772  switch(type){
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;
777  }
778  return 0;
779  }
780 
781  inline std::vector<int> bank::getInt(const char *name) const noexcept{
782  int item = bankSchema.getEntryOrder(name);
783  int type = bankSchema.getEntryType(item);
784  std::vector<int> row;
785 
786  int nrows = getRows();
787  for(int j = 0; j < nrows; j++){
788  int offset = bankSchema.getOffset(item, j, bankRows);
789  switch(type){
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;
794  }
795  }
796  return row;
797  }
798 
799  inline int bank::getShort(const char *name, int index) const noexcept{
800  int item = bankSchema.getEntryOrder(name);
801  int type = bankSchema.getEntryType(item);
802  int offset = bankSchema.getOffset(item, index, bankRows);
803  switch(type){
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;
808  }
809  return 0;
810  }
811  inline int bank::getByte(const char *name, int index) const noexcept{
812  int item = bankSchema.getEntryOrder(name);
813  int type = bankSchema.getEntryType(item);
814  int offset = bankSchema.getOffset(item, index, bankRows);
815  switch(type){
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;
819  }
820  return 0;
821  }
822 
823  inline float bank::getFloat(const char *name, int index) const noexcept{
824  int item = bankSchema.getEntryOrder(name);
825  if(bankSchema.getEntryType(item)==kFloat){
826  int offset = bankSchema.getOffset(item, index, bankRows);
827  return getFloatAt(offset);
828  }
829  return 0.0;
830  }
831 
832  inline std::vector<float> bank::getFloat(const char *name) const noexcept{
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));
840  }
841  }
842  return row;
843  }
844 
845  inline std::vector<float> bank::getFloat(int item) const noexcept{
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));
852  }
853  }
854  return row;
855  }
856  inline double bank::getDouble(const char *name, int index) const noexcept{
857  int item = bankSchema.getEntryOrder(name);
858  if(bankSchema.getEntryType(item)==kDouble){
859  int offset = bankSchema.getOffset(item, index, bankRows);
860  return getDoubleAt(offset);
861  }
862  if(bankSchema.getEntryType(item)==kFloat){
863  int offset = bankSchema.getOffset(item, index, bankRows);
864  return (double) getFloatAt(offset);
865  }
866  return 0.0;
867  }
868 
869  inline std::vector<double> bank::getDouble(int item) const noexcept{
870  std::vector<double> row;
871  int nrows = getRows();
872 
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));
877  }
878  }
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));
883  }
884  }
885  return row;
886  }
887 
888  inline std::vector<double> bank::getDouble(const char *name) const noexcept{
889  std::vector<double> row;
890  int nrows = getRows();
891  int item = bankSchema.getEntryOrder(name);
892 
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));
897  }
898  }
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));
903  }
904  }
905  return row;
906  }
907 
908  inline long bank::getLong(const char *name, int index) const noexcept{
909  int item = bankSchema.getEntryOrder(name);
910  if(bankSchema.getEntryType(item)==kLong){
911  int offset = bankSchema.getOffset(item, index, bankRows);
912  return getLongAt(offset);
913  }
914  return 0;
915  }
916  inline void bank::putInt(int item, int index, int32_t value){
917  //int type = bankSchema.getEntryType(item);
918  int offset = bankSchema.getOffset(item, index, bankRows);
919  putIntAt(offset,value);
920  }
921  inline void bank::putShort(int item, int index, int16_t value){
922  //int type = bankSchema.getEntryType(item);
923  int offset = bankSchema.getOffset(item, index, bankRows);
924  putShortAt(offset,value);
925  }
926  inline void bank::putByte(int item, int index, int8_t value){
927  //int type = bankSchema.getEntryType(item);
928  int offset = bankSchema.getOffset(item, index, bankRows);
929  putByteAt(offset,value);
930  }
931  inline void bank::putFloat(int item, int index, float value){
932  //int type = bankSchema.getEntryType(item);
933  int offset = bankSchema.getOffset(item, index, bankRows);
934  //printf("---- put float %f at position = %d\n",value,offset);
935  putFloatAt(offset,value);
936  }
937  inline void bank::putDouble(int item, int index, double value){
938  //int type = bankSchema.getEntryType(item);
939  int offset = bankSchema.getOffset(item, index, bankRows);
940  putDoubleAt(offset,value);
941  }
942  inline void bank::putLong(int item, int index, int64_t value){
943  //int type = bankSchema.getEntryType(item);
944  int offset = bankSchema.getOffset(item, index, bankRows);
945  putLongAt(offset,value);
946  }
947 
948  using banklist=std::vector<bank>;
949 
961  banklist::size_type getBanklistIndex(banklist& banks, std::string const& bankName) noexcept(false);
962 
963 }
964 #endif /* BANK_H */
Mathematical expression parser and evaluator.
Definition: parser.h:43
rowlist encapsulates a list of rows for this bank, providing a way to iterate over them
Definition: bank.h:357
list_t const & getList() const
Definition: bank.cpp:356
void setOwnerBank(bank *const ownerBank)
Definition: bank.h:391
void reset(int numRows=-1)
Definition: bank.cpp:343
void filter(std::function< bool(bank &, int)> func)
Definition: bank.cpp:367
void setList(list_t const &list)
Definition: bank.cpp:362
bool isInitialized() const
Definition: bank.h:368
std::vector< int > list_t
Definition: bank.h:360
static list_t createFullList(int num)
Definition: bank.cpp:399
Represents a HIPO bank, a tabular data structure with rows and typed columns.
Definition: bank.h:352
void setRows(int rows)
Definition: bank.cpp:439
void putByte(const char *name, int index, int8_t value)
Definition: bank.cpp:472
void reset()
Reset the bank to an empty state (zero rows).
Definition: bank.cpp:447
void put(const char *name, int index, T value)
Generic setter by column name, dispatches to the typed put method.
Definition: bank.h:591
rowlist::list_t const & getRowList() const
Definition: bank.cpp:494
void putFloat(const char *name, int index, float value)
Definition: bank.cpp:477
bank(const schema &__schema, int __rows)
Construct a bank from a schema with a specified number of rows.
Definition: bank.h:432
T get(int item, int index) const noexcept
Generic getter that returns the value at the given column and row.
Definition: bank.h:492
rowlist & getMutableRowList()
Definition: bank.cpp:502
int getInt(int item, int index) const noexcept
Definition: bank.h:714
void putShort(const char *name, int index, int16_t value)
Definition: bank.cpp:467
bank()
Default constructor.
void notify() override
Called when the bank is updated; recalculates the row count from the schema.
Definition: bank.cpp:453
void putLong(const char *name, int index, int64_t value)
Definition: bank.cpp:488
long getLong(int item, int index) const noexcept
Definition: bank.h:706
void printValue(int schemaEntry, int row) const
Definition: bank.cpp:540
int getRows() const noexcept
Definition: bank.h:446
void put(int item, int index, T value)
Generic setter by column index, dispatches to the typed put method.
Definition: bank.h:632
void putDouble(const char *name, int index, double value)
Definition: bank.cpp:482
T get(const char *name, int index) const noexcept
Generic getter that returns the value at the given column name and row.
Definition: bank.h:550
int getShort(int item, int index) const noexcept
Definition: bank.h:746
void show() const override
show this bank's contents; only the rows in its current rowlist instance are shown
Definition: bank.cpp:516
bank(const schema &__schema)
Construct a bank from a schema.
Definition: bank.h:422
float getFloat(int item, int index) const noexcept
Definition: bank.h:686
int getByte(int item, int index) const noexcept
Definition: bank.h:758
schema & getSchema()
Definition: bank.h:443
~bank() override
rowlist::list_t const getFullRowList() const
Definition: bank.cpp:498
void putInt(const char *name, int index, int32_t value)
Definition: bank.cpp:462
double getDouble(int item, int index) const noexcept
Definition: bank.h:694
rowlist::list_t const getRowListLinked(int const row, int const column) const
Definition: bank.cpp:507
int getRows() const noexcept
Definition: bank.h:295
int getInt(int element, int row) const noexcept
Definition: bank.cpp:216
composite(const char *format)
Definition: bank.h:271
virtual void notify()
Called when the composite is updated (e.g., after reading an event).
Definition: bank.cpp:284
int getEntries() const noexcept
Definition: bank.h:298
composite(int group, int item, int size)
Definition: bank.h:268
void print()
Print the composite contents to standard output.
Definition: bank.cpp:309
void putLong(int element, int row, int64_t value)
Definition: bank.cpp:267
float getFloat(int element, int row) const noexcept
Definition: bank.cpp:243
void putInt(int element, int row, int value)
Definition: bank.cpp:253
int getEntryType(int index) const noexcept
Definition: bank.h:301
void parse(std::string format)
Definition: bank.cpp:162
void reset()
Reset the composite to an empty state.
Definition: bank.cpp:150
int getRowSize() const noexcept
Definition: bank.h:307
int64_t getLong(int element, int row) const noexcept
Definition: bank.cpp:233
void putFloat(int element, int row, float value)
Definition: bank.cpp:275
virtual ~composite()
Definition: bank.h:290
composite(int size)
Definition: bank.h:263
composite()
Default constructor.
Definition: bank.h:260
void setRows(int rows)
Definition: bank.cpp:166
Represents a HIPO event, a container for multiple structures/banks.
Definition: event.h:77
Low-level node representing a tagged data element in a HIPO structure.
Definition: node.h:68
int group()
Definition: node.h:212
int item()
Definition: node.h:214
int size() const noexcept
Definition: node.h:138
int capacity() const noexcept
Definition: node.h:145
int dataLength() const noexcept
Definition: node.h:183
int type()
Definition: node.h:216
bool allocate(int size)
Ensure the internal buffer can hold at least size bytes.
Definition: node.h:128
Schema definition for a HIPO bank.
Definition: dictionary.h:73
int getOffset(int item, int order, int rows) const
Compute the byte offset for a column value by column index.
Definition: dictionary.h:171
Low-level data structure representing a HIPO structure.
Definition: bank.h:64
float getFloatAt(int index) const noexcept
Definition: bank.h:170
void initStructureBySize(int __group, int __item, int __type, int __size)
Initialize the structure buffer with the given group, item, type, and data size.
Definition: bank.cpp:67
void putShortAt(int index, int16_t value)
Definition: bank.h:198
int getItem() const
Definition: bank.cpp:108
int getSize() const noexcept
Definition: bank.h:106
void putIntAt(int index, int value)
Definition: bank.h:191
int getDataSize() const noexcept
Definition: bank.h:119
void putByteAt(int index, int8_t value)
Definition: bank.h:205
bool allocate(int size)
Definition: bank.cpp:60
int getGroup() const
Definition: bank.cpp:103
virtual ~structure()=default
void putStringAt(int index, std::string &str)
Definition: bank.cpp:137
structure()
Default constructor. Sets the structure address to nullptr.
Definition: bank.h:87
int getStructureBufferSize()
Definition: bank.h:79
void setSize(int size)
Definition: bank.cpp:76
int16_t getShortAt(int index) const noexcept
Definition: bank.h:160
virtual void show() const
Display the structure contents to standard output.
Definition: bank.cpp:122
int dataOffset
Definition: bank.h:80
void putLongAt(int index, int64_t value)
Definition: bank.h:226
long getLongAt(int index) const noexcept
Definition: bank.h:180
int getType() const
Definition: bank.cpp:98
void initNoCopy(const char *buffer, int size)
Definition: bank.cpp:112
int8_t getByteAt(int index) const noexcept
Definition: bank.h:165
int getIntAt(int index) const noexcept
Definition: bank.h:154
structure(int size)
Definition: bank.h:90
void setDataSize(int size)
Definition: bank.cpp:82
void putDoubleAt(int index, double value)
Definition: bank.h:219
std::vector< char > & getStructureBuffer()
Definition: bank.h:77
virtual void notify()
Called when the structure is updated (e.g., after reading an event).
Definition: bank.h:236
void putFloatAt(int index, float value)
Definition: bank.h:212
int getHeaderSize() const noexcept
Definition: bank.h:113
void init(const char *buffer, int size)
Definition: bank.cpp:116
double getDoubleAt(int index) const noexcept
Definition: bank.h:175
std::string getStringAt(int index)
Definition: bank.cpp:127
void setHeaderSize(int size)
Definition: bank.cpp:91
const char * getAddress()
Definition: bank.cpp:142
N-tuple writer for storing columnar float data in HIPO files.
Definition: tuple.h:71
Schema definitions and schema dictionary for HIPO banks.
Definition: bank.cpp:47
@ kLong
64-bit signed integer.
Definition: dictionary.h:57
@ kInt
32-bit signed integer.
Definition: dictionary.h:54
@ kFloat
32-bit IEEE 754 floating point.
Definition: dictionary.h:55
@ kShort
16-bit signed integer.
Definition: dictionary.h:53
@ kByte
8-bit signed integer.
Definition: dictionary.h:52
@ kDouble
64-bit IEEE 754 floating point.
Definition: dictionary.h:56
constexpr uint32_t STRUCT_FORMAT_BYTE
Definition: constants.h:129
constexpr int STRUCT_FORMAT_SHIFT
Definition: constants.h:128
std::vector< bank > banklist
Definition: bank.h:948
banklist::size_type getBanklistIndex(banklist &banks, std::string const &bankName) noexcept(false)
Find the index of a bank by name in a banklist.
Definition: bank.cpp:559
constexpr uint32_t STRUCT_SIZE_MASK
Definition: constants.h:126
Low-level node class for handling tagged binary data elements in HIPO structures.