HIPO4 C++ Library 4.4.1
Columnar I/O library for CLAS12 physics data
Loading...
Searching...
No Matches
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 */
30/*******************************************************************************
31 * File: bank.h
32 * Author: gavalian
33 *
34 * Created on April 12, 2017, 10:14 AM
35 */
36
37#ifndef HIPO_BANK_H
38#define HIPO_BANK_H
39#include <iostream>
40#include <vector>
41#include <cstring>
42#include <cstdint>
43#include <cstdio>
44#include <cstdlib>
45#include <map>
46#include <functional>
47#include "dictionary.h"
48#include "node.h"
49
50namespace hipo {
51
52 class Parser;
53
54 class structure {
55
56 private:
57
58 std::vector<char> structureBuffer;
59 char *structureAddress{};
60 void setAddress(const char *address);
61
62 protected:
63
64 void initStructureBySize(int __group, int __item, int __type, int __size);
65 std::vector<char> &getStructureBuffer(){ return structureBuffer;}
66 int getStructureBufferSize(){ return 8+getSize();}
67 int dataOffset = 8;
68 //std::vector<char> structureBuffer;
69 friend class tuple;
70
71 public:
72
73 structure(){ structureAddress = nullptr;}
74 structure(int size){ allocate(size);}
75 structure(int __group, int __item, std::string &str);
76
77 virtual ~structure()= default;
78 bool allocate(int size);
79
80 int getSize() const noexcept{
81 int length = *reinterpret_cast<uint32_t *>(structureAddress+4);
82 return length&STRUCT_SIZE_MASK;
83 //return getHeaderSize()+getDataSize();
84 }
85
86 int getHeaderSize() const noexcept {
87 int length = *reinterpret_cast<uint32_t *>(structureAddress+4);
89 }
90
91 int getDataSize() const noexcept {
92 return getSize()-getHeaderSize();
93 }
94
95 int getType() const;
96 int getGroup() const;
97 int getItem() const;
98 void init(const char *buffer, int size);
99 void initNoCopy(const char *buffer, int size);
100
101 const char *getAddress();
102 virtual void show() const;
103 void setSize(int size);
104 void setHeaderSize(int size);
105 void setDataSize(int size);
106
107 int getIntAt ( int index) const noexcept {
108 return *reinterpret_cast<int32_t*>(&structureAddress[index+dataOffset]);
109 }
110
111 int16_t getShortAt ( int index) const noexcept {
112 return *reinterpret_cast<int16_t*>(&structureAddress[index+dataOffset]);
113 }
114 int8_t getByteAt ( int index) const noexcept {
115 return *reinterpret_cast<int8_t*>(&structureAddress[index+dataOffset]);
116 }
117 float getFloatAt ( int index) const noexcept {
118 return *reinterpret_cast<float*>(&structureAddress[index+dataOffset]);
119 }
120 double getDoubleAt( int index) const noexcept {
121 return *reinterpret_cast<double*>(&structureAddress[index+dataOffset]);
122 }
123 long getLongAt ( int index) const noexcept {
124 return *reinterpret_cast<int64_t*>(&structureAddress[index+dataOffset]);
125 }
126
127 std::string getStringAt(int index);
128
129 void putIntAt(int index, int value){
130 *reinterpret_cast<int32_t*>(&structureAddress[index+dataOffset]) = value;
131 }
132
133 void putShortAt(int index, int16_t value){
134 *reinterpret_cast<int16_t*>(&structureAddress[index+dataOffset]) = value;
135 }
136
137 void putByteAt(int index, int8_t value){
138 *reinterpret_cast<int8_t*>(&structureAddress[index+dataOffset]) = value;
139 }
140
141 void putFloatAt(int index, float value){
142 *reinterpret_cast<float*>(&structureAddress[index+dataOffset]) = value;
143 }
144
145 void putDoubleAt(int index, double value){
146 *reinterpret_cast<double*>(&structureAddress[index+dataOffset]) = value;
147 }
148
149 void putLongAt(int index, int64_t value){
150 *reinterpret_cast<int64_t*>(&structureAddress[index+dataOffset]) = value;
151 }
152
153 void putStringAt(int index, std::string &str);
154
155 virtual void notify(){}
156 friend class event;
157 };
158
159 class composite : public node {
165 private:
166
167 std::vector<char> typeChars;
168 std::vector<int> offsets;
169 std::vector<int> types;
170 int rowOffset = 0;
171
172 // void parse(std::string format);
173 int getTypeSize(int type);
174
175 public:
176
179 composite(int group, int item, int size){ /*initStructureBySize(group, item, 10, size);*/};
180 composite(const char *format){}
181 composite(int group, int item, const char *format, int capacity);
182
183 void parse(std::string format);
184 void parse(int group, int item, std::string format, int maxrows);
185 virtual ~composite(){}
186
190 int getRows() const noexcept { return dataLength()/rowOffset;}
191
192 int getEntries() const noexcept { return offsets.size();}
193 int getEntryType(int index) const noexcept { return types[index];}
194 void setRows(int rows);// { setDataLength(rows*rowOffset);}
195
196 int getRowSize() const noexcept { return rowOffset;}
197
198 int getInt ( int element, int row) const noexcept;
199 int64_t getLong ( int element, int row) const noexcept;
200 float getFloat ( int element, int row) const noexcept;
201 void putInt ( int element, int row, int value);
202 void putLong ( int element, int row, int64_t value);
203 void putFloat ( int element, int row, float value);
204 virtual void notify();
205 void print();
206 void reset();
207 };
208 //typedef std::auto_ptr<hipo::generic_node> node_pointer;
209
210 class bank : public structure {
211
212 public:
213
215 class rowlist {
216
217 public:
218 using list_t = std::vector<int>;
219
220 rowlist() = default;
221 ~rowlist() = default;
222
225 void reset(int numRows = -1);
226 bool isInitialized() const { return m_init; }
227
229 list_t const& getList() const;
231 void setList(list_t const& list);
232
245 void filter(std::function<bool(bank&, int)> func);
248 void filter(char const* expression);
251 void filter(Parser& p);
252
255 static list_t createFullList(int num);
256
258 void setOwnerBank(bank* const ownerBank) { m_owner_bank = ownerBank; }
259
260 private:
261 bool m_init{false};
262 list_t m_list{};
263 bank* m_owner_bank{nullptr};
264
265 bool ownerBankIsUnknown(std::string_view caller = "");
266
267 };
268
269 private:
270
271 schema bankSchema;
272 int bankRows{-1};
273 rowlist bankRowList;
274
275 public:
276
278 // constructor initializes the nodes in the bank
279 // and they will be filled automatically by reader.next()
280 // method.
281 bank(const schema& __schema){
282 bankSchema = __schema;
283 bankRows = -1;
284 }
285
286 bank(const schema& __schema, int __rows){
287 bankSchema = __schema;
288 bankRows = __rows;
289 int size = bankSchema.getSizeForRows(__rows);
290 initStructureBySize(bankSchema.getGroup(),bankSchema.getItem(), 11, size);
291 bankRowList.reset(bankRows);
292 }
293
294 ~bank() override;
295
296 schema &getSchema() { return bankSchema;}
297
298 int getRows() const noexcept{ return bankRows;}
299 void setRows( int rows);
300 int getInt( int item, int index) const noexcept;
301 int getShort( int item, int index) const noexcept;
302 int getByte( int item, int index) const noexcept;
303 float getFloat( int item, int index) const noexcept;
304 double getDouble( int item, int index) const noexcept;
305 long getLong( int item, int index) const noexcept;
306
307 std::vector<int> getInt( int item) const noexcept;
308 std::vector<float> getFloat( int item) const noexcept;
309 std::vector<double> getDouble( int item) const noexcept;
310
311 template<typename T = double> T get(int item, int index) const noexcept {
312 auto type = bankSchema.getEntryType(item);
313 auto offset = bankSchema.getOffset(item, index, bankRows);
314 switch(type) {
315 case kByte: return (int) getByteAt(offset);
316 case kShort: return (int) getShortAt(offset);
317 case kInt: return getIntAt(offset);
318 case kFloat: return getFloatAt(offset);
319 case kDouble: return getDoubleAt(offset);
320 case kLong: return getLongAt(offset);
321 default:
322 printf("---> error(get) : unknown type for [%s] type = %d\n", bankSchema.getEntryName(item).c_str(), type);
323 }
324 return 0;
325 }
326
327 int getInt( const char *name, int index) const noexcept;
328
329 int getShort( const char *name, int index) const noexcept;
330 int getByte( const char *name, int index) const noexcept;
331 float getFloat( const char *name, int index) const noexcept;
332 double getDouble( const char *name, int index) const noexcept;
333 long getLong( const char *name, int index) const noexcept;
334
335 std::vector<int> getInt( const char *name) const noexcept;
336 std::vector<float> getFloat( const char *name) const noexcept;
337 std::vector<double> getDouble( const char *name) const noexcept;
338
339 template<typename T = double> T get(const char *name, int index) const noexcept {
340 return get<T>(bankSchema.getEntryOrder(name), index);
341 }
342
343 void putInt( const char *name, int index, int32_t value);
344 void putShort( const char *name, int index, int16_t value);
345 void putByte( const char *name, int index, int8_t value);
346 void putFloat( const char *name, int index, float value);
347 void putDouble( const char *name, int index, double value);
348 void putLong( const char *name, int index, int64_t value);
349 template<typename T> void put(const char *name, int index, T value) {
350 put(bankSchema.getEntryOrder(name), index, value);
351 }
352
353 void putInt(int item, int index, int32_t value);
354 void putShort(int item, int index, int16_t value);
355 void putByte(int item, int index, int8_t value);
356 void putFloat(int item, int index, float value);
357 void putDouble(int item, int index, double value);
358 void putLong(int item, int index, int64_t value);
359 template<typename T> void put(int item, int index, T value) {
360 auto type = bankSchema.getEntryType(item);
361 switch(type) {
362 case kByte: putByte(item, index, static_cast<int8_t>(value)); break;
363 case kShort: putShort(item, index, static_cast<int16_t>(value)); break;
364 case kInt: putInt(item, index, static_cast<int32_t>(value)); break;
365 case kFloat: putFloat(item, index, static_cast<float>(value)); break;
366 case kDouble: putDouble(item, index, static_cast<double>(value)); break;
367 case kLong: putLong(item, index, static_cast<int64_t>(value)); break;
368 default:
369 printf("---> error(put) : unknown type for [%s] type = %d\n", bankSchema.getEntryName(item).c_str(), type);
370 }
371 }
372
375 rowlist::list_t const& getRowList() const;
376
379 rowlist::list_t const getFullRowList() const;
380
383 rowlist& getMutableRowList();
384
388 rowlist::list_t const getRowListLinked(int const row, int const column) const;
389
391 void show() const override;
392
396 void show(bool const showAllRows) const;
397
401 void printValue(int schemaEntry, int row) const;
402
406 std::size_t checksum(bool checkAllRows=false) const;
407
408 void reset();
409
410 void notify() override;
411
412 };
414 //inlined getters
415
416 inline float bank::getFloat(int item, int index) const noexcept{
417 if(bankSchema.getEntryType(item)==kFloat){
418 int offset = bankSchema.getOffset(item, index, bankRows);
419 return getFloatAt(offset);
420 }
421 return 0.0;
422 }
423
424 inline double bank::getDouble(int item, int index) const noexcept{
425 if(bankSchema.getEntryType(item)==kDouble){
426 int offset = bankSchema.getOffset(item, index, bankRows);
427 return getDoubleAt(offset);
428 }
429 if(bankSchema.getEntryType(item)==kFloat){
430 int offset = bankSchema.getOffset(item, index, bankRows);
431 return getFloatAt(offset);
432 }
433 return 0.0;
434 }
435
436 inline long bank::getLong(int item, int index) const noexcept{
437 if(bankSchema.getEntryType(item)==kLong){
438 int offset = bankSchema.getOffset(item, index, bankRows);
439 return getLongAt(offset);
440 }
441 return 0;
442 }
443
444 inline int bank::getInt(int item, int index) const noexcept{
445 int type = bankSchema.getEntryType(item);
446 int offset = bankSchema.getOffset(item, index, bankRows);
447 switch(type){
448 case kByte: return (int) getByteAt(offset);
449 case kShort: return (int) getShortAt(offset);
450 case kInt: return getIntAt(offset);
451 default: printf("---> error : requested INT for [%s] type = %d\n",
452 bankSchema.getEntryName(item).c_str(),type); break;
453 }
454 return 0;
455 }
456
457 inline std::vector<int> bank::getInt(int item) const noexcept{
458 int type = bankSchema.getEntryType(item);
459
460 std::vector<int> row;
461 int nrows = getRows();
462
463 for(int j = 0; j < nrows; j++){
464 int offset = bankSchema.getOffset(item, j, bankRows);
465 switch(type){
466 case kByte: row.push_back((int) getByteAt(offset)); break;
467 case kShort: row.push_back((int) getShortAt(offset)); break;
468 case kInt: row.push_back((int) getIntAt(offset)); break;
469 default: printf("---> error : requested INT for [%s] type = %d\n",
470 bankSchema.getEntryName(item).c_str(),type); break;
471 }
472 }
473 return row;
474 }
475
476 inline int bank::getShort(int item, int index) const noexcept{
477 int type = bankSchema.getEntryType(item);
478 int offset = bankSchema.getOffset(item, index, bankRows);
479 switch(type){
480 case kByte: return (int) getByteAt(offset);
481 case kShort: return (int) getShortAt(offset);
482 default: printf("---> error : requested SHORT for [%s] type = %d\n",
483 bankSchema.getEntryName(item).c_str(),type); break;
484 }
485 return 0;
486 }
487
488 inline int bank::getByte(int item, int index) const noexcept{
489 int type = bankSchema.getEntryType(item);
490 int offset = bankSchema.getOffset(item, index, bankRows);
491 switch(type){
492 case kByte: return (int) getByteAt(offset);
493 default: printf("---> error : requested BYTE for [%s] type = %d\n",
494 bankSchema.getEntryName(item).c_str(),type); break;
495 }
496 return 0;
497 }
498 inline int bank::getInt(const char *name, int index) const noexcept{
499 int item = bankSchema.getEntryOrder(name);
500 int type = bankSchema.getEntryType(item);
501 int offset = bankSchema.getOffset(item, index, bankRows);
502 switch(type){
503 case kByte: return (int) getByteAt(offset);
504 case kShort: return (int) getShortAt(offset);
505 case kInt: return getIntAt(offset);
506 default: printf("---> error : requested INT for [%s] type = %d\n",name,type); break;
507 }
508 return 0;
509 }
510
511 inline std::vector<int> bank::getInt(const char *name) const noexcept{
512 int item = bankSchema.getEntryOrder(name);
513 int type = bankSchema.getEntryType(item);
514 std::vector<int> row;
515
516 int nrows = getRows();
517 for(int j = 0; j < nrows; j++){
518 int offset = bankSchema.getOffset(item, j, bankRows);
519 switch(type){
520 case kByte: row.push_back((int) getByteAt(offset)); break;
521 case kShort: row.push_back((int) getShortAt(offset)); break;
522 case kInt: row.push_back((int) getIntAt(offset)); break;
523 default: printf("---> error : requested INT for [%s] type = %d\n",name,type); break;
524 }
525 }
526 return row;
527 }
528
529 inline int bank::getShort(const char *name, int index) const noexcept{
530 int item = bankSchema.getEntryOrder(name);
531 int type = bankSchema.getEntryType(item);
532 int offset = bankSchema.getOffset(item, index, bankRows);
533 switch(type){
534 case kByte: return (int) getByteAt(offset);
535 case kShort: return (int) getShortAt(offset);
536 default: printf("---> error : requested SHORT for [%s] type = %d\n",
537 bankSchema.getEntryName(item).c_str(),type); break;
538 }
539 return 0;
540 }
541 inline int bank::getByte(const char *name, int index) const noexcept{
542 int item = bankSchema.getEntryOrder(name);
543 int type = bankSchema.getEntryType(item);
544 int offset = bankSchema.getOffset(item, index, bankRows);
545 switch(type){
546 case kByte: return (int) getByteAt(offset);
547 default: printf("---> error : requested BYTE for [%s] type = %d\n",
548 bankSchema.getEntryName(item).c_str(),type); break;
549 }
550 return 0;
551 }
552
553 inline float bank::getFloat(const char *name, int index) const noexcept{
554 int item = bankSchema.getEntryOrder(name);
555 if(bankSchema.getEntryType(item)==kFloat){
556 int offset = bankSchema.getOffset(item, index, bankRows);
557 return getFloatAt(offset);
558 }
559 return 0.0;
560 }
561
562 inline std::vector<float> bank::getFloat(const char *name) const noexcept{
563 int item = bankSchema.getEntryOrder(name);
564 std::vector<float> row;
565 int nrows = getRows();
566 if(bankSchema.getEntryType(item)==kFloat){
567 for(int j = 0; j < nrows; j++){
568 int offset = bankSchema.getOffset(item, j, bankRows);
569 row.push_back( getFloatAt(offset));
570 }
571 }
572 return row;
573 }
574
575 inline std::vector<float> bank::getFloat(int item) const noexcept{
576 std::vector<float> row;
577 int nrows = getRows();
578 if(bankSchema.getEntryType(item)==kFloat){
579 for(int j = 0; j < nrows; j++){
580 int offset = bankSchema.getOffset(item, j, bankRows);
581 row.push_back( getFloatAt(offset));
582 }
583 }
584 return row;
585 }
586 inline double bank::getDouble(const char *name, int index) const noexcept{
587 int item = bankSchema.getEntryOrder(name);
588 if(bankSchema.getEntryType(item)==kDouble){
589 int offset = bankSchema.getOffset(item, index, bankRows);
590 return getDoubleAt(offset);
591 }
592 if(bankSchema.getEntryType(item)==kFloat){
593 int offset = bankSchema.getOffset(item, index, bankRows);
594 return (double) getFloatAt(offset);
595 }
596 return 0.0;
597 }
598
599 inline std::vector<double> bank::getDouble(int item) const noexcept{
600 std::vector<double> row;
601 int nrows = getRows();
602
603 if(bankSchema.getEntryType(item)==kDouble){
604 for(int j = 0; j < nrows; j++){
605 int offset = bankSchema.getOffset(item, j, bankRows);
606 row.push_back(getDoubleAt(offset));
607 }
608 }
609 if(bankSchema.getEntryType(item)==kFloat){
610 for(int j = 0; j < nrows; j++){
611 int offset = bankSchema.getOffset(item, j, bankRows);
612 row.push_back((double) getFloatAt(offset));
613 }
614 }
615 return row;
616 }
617
618 inline std::vector<double> bank::getDouble(const char *name) const noexcept{
619 std::vector<double> row;
620 int nrows = getRows();
621 int item = bankSchema.getEntryOrder(name);
622
623 if(bankSchema.getEntryType(item)==kDouble){
624 for(int j = 0; j < nrows; j++){
625 int offset = bankSchema.getOffset(item, j, bankRows);
626 row.push_back(getDoubleAt(offset));
627 }
628 }
629 if(bankSchema.getEntryType(item)==kFloat){
630 for(int j = 0; j < nrows; j++){
631 int offset = bankSchema.getOffset(item, j, bankRows);
632 row.push_back((double) getFloatAt(offset));
633 }
634 }
635 return row;
636 }
637
638 inline long bank::getLong(const char *name, int index) const noexcept{
639 int item = bankSchema.getEntryOrder(name);
640 if(bankSchema.getEntryType(item)==kLong){
641 int offset = bankSchema.getOffset(item, index, bankRows);
642 return getLongAt(offset);
643 }
644 return 0;
645 }
646 inline void bank::putInt(int item, int index, int32_t value){
647 //int type = bankSchema.getEntryType(item);
648 int offset = bankSchema.getOffset(item, index, bankRows);
649 putIntAt(offset,value);
650 }
651 inline void bank::putShort(int item, int index, int16_t value){
652 //int type = bankSchema.getEntryType(item);
653 int offset = bankSchema.getOffset(item, index, bankRows);
654 putShortAt(offset,value);
655 }
656 inline void bank::putByte(int item, int index, int8_t value){
657 //int type = bankSchema.getEntryType(item);
658 int offset = bankSchema.getOffset(item, index, bankRows);
659 putByteAt(offset,value);
660 }
661 inline void bank::putFloat(int item, int index, float value){
662 //int type = bankSchema.getEntryType(item);
663 int offset = bankSchema.getOffset(item, index, bankRows);
664 //printf("---- put float %f at position = %d\n",value,offset);
665 putFloatAt(offset,value);
666 }
667 inline void bank::putDouble(int item, int index, double value){
668 //int type = bankSchema.getEntryType(item);
669 int offset = bankSchema.getOffset(item, index, bankRows);
670 putDoubleAt(offset,value);
671 }
672 inline void bank::putLong(int item, int index, int64_t value){
673 //int type = bankSchema.getEntryType(item);
674 int offset = bankSchema.getOffset(item, index, bankRows);
675 putLongAt(offset,value);
676 }
677
678 using banklist=std::vector<bank>;
679
680 // @returns the index of the bank in `banklist` `banks` which has the name `bankName`; if there is more
681 // than one, only the index of the first such bank will be returned. A runtime exception is thrown
682 // if the bank is not found
683 // @param banks the `banklist` to search
684 // @param bankName the bank name
685 banklist::size_type getBanklistIndex(banklist& banks, std::string const& bankName) noexcept(false);
686
687}
688#endif /* BANK_H */
Definition parser.h:25
rowlist encapsulates a list of rows for this bank, providing a way to iterate over them
Definition bank.h:215
list_t const & getList() const
Definition bank.cpp:355
void setOwnerBank(bank *const ownerBank)
Definition bank.h:258
void filter(std::function< bool(bank &, int)> func)
filter the list according to a function
Definition bank.cpp:366
void setList(list_t const &list)
Definition bank.cpp:361
bool isInitialized() const
Definition bank.h:226
std::vector< int > list_t
Definition bank.h:218
static list_t createFullList(int num)
Definition bank.cpp:398
Definition bank.h:210
void setRows(int rows)
Definition bank.cpp:429
void putByte(const char *name, int index, int8_t value)
Definition bank.cpp:462
void reset()
Definition bank.cpp:437
void put(const char *name, int index, T value)
Definition bank.h:349
rowlist::list_t const & getRowList() const
Definition bank.cpp:484
void putFloat(const char *name, int index, float value)
Definition bank.cpp:467
bank(const schema &__schema, int __rows)
Definition bank.h:286
T get(int item, int index) const noexcept
Definition bank.h:311
rowlist & getMutableRowList()
Definition bank.cpp:492
int getInt(int item, int index) const noexcept
Definition bank.h:444
void putShort(const char *name, int index, int16_t value)
Definition bank.cpp:457
void notify() override
Definition bank.cpp:443
void putLong(const char *name, int index, int64_t value)
Definition bank.cpp:478
long getLong(int item, int index) const noexcept
Definition bank.h:436
void printValue(int schemaEntry, int row) const
print a stored value
Definition bank.cpp:530
int getRows() const noexcept
Definition bank.h:298
void put(int item, int index, T value)
Definition bank.h:359
std::size_t checksum(bool checkAllRows=false) const
calculate a checksum for this bank; useful for comparing two banks' equality
Definition bank.cpp:549
schema & getSchema()
Definition bank.h:296
void putDouble(const char *name, int index, double value)
Definition bank.cpp:472
T get(const char *name, int index) const noexcept
Definition bank.h:339
int getShort(int item, int index) const noexcept
Definition bank.h:476
void show() const override
show this bank's contents; only the rows in its current rowlist instance are shown
Definition bank.cpp:506
bank(const schema &__schema)
Definition bank.h:281
float getFloat(int item, int index) const noexcept
Definition bank.h:416
int getByte(int item, int index) const noexcept
Definition bank.h:488
~bank() override
rowlist::list_t const getFullRowList() const
Definition bank.cpp:488
void putInt(const char *name, int index, int32_t value)
Definition bank.cpp:452
double getDouble(int item, int index) const noexcept
Definition bank.h:424
rowlist::list_t const getRowListLinked(int const row, int const column) const
Definition bank.cpp:497
Definition bank.h:159
int getRows() const noexcept
Definition bank.h:190
int getInt(int element, int row) const noexcept
Definition bank.cpp:214
composite(const char *format)
Definition bank.h:180
virtual void notify()
Definition bank.cpp:282
int getEntries() const noexcept
Definition bank.h:192
composite(int group, int item, int size)
Definition bank.h:179
void print()
Definition bank.cpp:307
void putLong(int element, int row, int64_t value)
Definition bank.cpp:265
float getFloat(int element, int row) const noexcept
Definition bank.cpp:241
void putInt(int element, int row, int value)
Definition bank.cpp:251
int getEntryType(int index) const noexcept
Definition bank.h:193
void parse(std::string format)
Definition bank.cpp:160
void reset()
Definition bank.cpp:148
int getRowSize() const noexcept
Definition bank.h:196
int64_t getLong(int element, int row) const noexcept
Definition bank.cpp:231
void putFloat(int element, int row, float value)
Definition bank.cpp:273
virtual ~composite()
Definition bank.h:185
composite(int size)
Definition bank.h:178
composite()
Definition bank.h:177
void setRows(int rows)
Definition bank.cpp:164
Definition event.h:62
Definition node.h:51
int group()
Definition node.h:148
int item()
Definition node.h:149
int size() const noexcept
Definition node.h:92
int capacity() const noexcept
Definition node.h:98
int dataLength() const noexcept
Definition node.h:126
int type()
Definition node.h:150
bool allocate(int size)
Definition node.h:84
Schema definition for a HIPO bank.
Definition dictionary.h:56
int getOffset(int item, int order, int rows) const
Definition dictionary.h:109
Definition bank.h:54
float getFloatAt(int index) const noexcept
Definition bank.h:117
void initStructureBySize(int __group, int __item, int __type, int __size)
Definition bank.cpp:65
void putShortAt(int index, int16_t value)
Definition bank.h:133
int getItem() const
Definition bank.cpp:106
int getSize() const noexcept
Definition bank.h:80
void putIntAt(int index, int value)
Definition bank.h:129
int getDataSize() const noexcept
Definition bank.h:91
void putByteAt(int index, int8_t value)
Definition bank.h:137
std::vector< char > & getStructureBuffer()
Definition bank.h:65
bool allocate(int size)
Definition bank.cpp:58
int getGroup() const
Definition bank.cpp:101
virtual ~structure()=default
void putStringAt(int index, std::string &str)
Definition bank.cpp:135
structure()
Definition bank.h:73
int getStructureBufferSize()
Definition bank.h:66
void setSize(int size)
Definition bank.cpp:74
int16_t getShortAt(int index) const noexcept
Definition bank.h:111
virtual void show() const
Definition bank.cpp:120
int dataOffset
Definition bank.h:67
void putLongAt(int index, int64_t value)
Definition bank.h:149
long getLongAt(int index) const noexcept
Definition bank.h:123
int getType() const
Definition bank.cpp:96
void initNoCopy(const char *buffer, int size)
Definition bank.cpp:110
int8_t getByteAt(int index) const noexcept
Definition bank.h:114
int getIntAt(int index) const noexcept
Definition bank.h:107
structure(int size)
Definition bank.h:74
void setDataSize(int size)
Definition bank.cpp:80
void putDoubleAt(int index, double value)
Definition bank.h:145
virtual void notify()
Definition bank.h:155
void putFloatAt(int index, float value)
Definition bank.h:141
int getHeaderSize() const noexcept
Definition bank.h:86
void init(const char *buffer, int size)
Definition bank.cpp:114
double getDoubleAt(int index) const noexcept
Definition bank.h:120
std::string getStringAt(int index)
Definition bank.cpp:125
void setHeaderSize(int size)
Definition bank.cpp:89
const char * getAddress()
Definition bank.cpp:140
Definition tuple.h:61
HIPO namespace is used for the classes that read/write files and records.
Definition bank.cpp:45
@ kLong
Definition dictionary.h:41
@ kInt
Definition dictionary.h:38
@ kFloat
Definition dictionary.h:39
@ kShort
Definition dictionary.h:37
@ kByte
Definition dictionary.h:36
@ kDouble
Definition dictionary.h:40
constexpr uint32_t STRUCT_FORMAT_BYTE
Definition constants.h:130
banklist::size_type getBanklistIndex(banklist &banks, std::string const &bankName) noexcept(false)
Definition bank.cpp:585
constexpr int STRUCT_FORMAT_SHIFT
Definition constants.h:129
std::vector< bank > banklist
Definition bank.h:678
constexpr uint32_t STRUCT_SIZE_MASK
Definition constants.h:127