HIPO  4.3.0
High Performance Output data format for experimental physics
recordbuilder.h
Go to the documentation of this file.
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 
7 /*
8  * File: recordbuilder.h
9  * Author: gavalian
10  *
11  * Created on April 11, 2017, 4:47 PM
12  */
13 
19 
20 #ifndef HIPORECORDBUILDER_H
21 #define HIPORECORDBUILDER_H
22 
23 #include <iostream>
24 #include <vector>
25 #include <string>
26 #include <stdint.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <fstream>
30 
31 #include "event.h"
32 #include "utils.h"
33 
34 namespace hipo {
35 
37 
45  class recordbuilder {
46 
47  private:
48  const int defaultNumberOfEvents = 100000;
49  const int defaultRecordSize = 8*1024*1024;
50  //std::vector< std::vector<char> > eventBuffer;
51  std::vector<char> bufferIndex;
52  std::vector<char> bufferEvents;
53  std::vector<char> bufferData;
54  std::vector<char> bufferRecord;
55 
56  int bufferIndexEntries;
57  int bufferEventsPosition;
58  long bufferUserWordOne = 0;
59  long bufferUserWordTwo = 0;
60 
61  int compressRecord(int src_size);
62  int getRecordLengthRounding(int bufferSize);
63 
64  public:
65 
71  recordbuilder(int maxEvents, int maxLength);
72 
74  recordbuilder();
75 
77  virtual ~recordbuilder(){};
78 
86  bool addEvent(std::vector<char> &vec, int start, int length);
87 
93  bool addEvent(hipo::event &evnt);
94 
96  long getUserWordOne();
98  long getUserWordTwo();
99 
104  void setUserWordOne(long userWordOne);
105 
110  void setUserWordTwo(long userWordTwo);
111 
113  int getRecordSize();
115  int getEntries();
117  std::vector<char> &getRecordBuffer(){ return bufferRecord;};
119  void reset();
121  void build();
122  };
123 }
124 #endif /* HIPORECORD_H */
Represents a HIPO event, a container for multiple structures/banks.
Definition: event.h:77
Builds HIPO records by accumulating events and compressing them.
Definition: recordbuilder.h:45
void build()
Compresses accumulated events and builds the final record.
void setUserWordOne(long userWordOne)
Sets the first user-defined word in the record header.
virtual ~recordbuilder()
Virtual destructor.
Definition: recordbuilder.h:77
std::vector< char > & getRecordBuffer()
Returns a reference to the internal record buffer.
int getRecordSize()
Returns the total size of the built record in bytes.
recordbuilder()
Default constructor with default capacity.
void reset()
Resets the builder, clearing all accumulated events.
long getUserWordTwo()
Returns the second user-defined word stored in the record header.
void setUserWordTwo(long userWordTwo)
Sets the second user-defined word in the record header.
long getUserWordOne()
Returns the first user-defined word stored in the record header.
bool addEvent(std::vector< char > &vec, int start, int length)
Adds an event from a raw byte vector.
int getEntries()
Returns the number of events currently in the record.
HIPO event container and manipulation interface.
Definition: bank.cpp:47
Utility functions and benchmark timer for HIPO library operations.