11 #ifndef EVIO_6_0_COMPACTEVENTBUILDER_H
12 #define EVIO_6_0_COMPACTEVENTBUILDER_H
52 std::shared_ptr<ByteBuffer> buffer =
nullptr;
55 uint8_t * array =
nullptr;
58 size_t arrayOffset = 0;
67 bool createdBuffer =
false;
71 bool generateNodes =
false;
75 std::vector<std::shared_ptr<EvioNode>> nodes;
78 static const uint32_t MAX_LEVELS = 50;
81 static const uint32_t padCount[];
89 class StructureContent {
104 StructureContent() =
default;
106 void setData(
size_t pos,
DataType const & type,
DataType const & dataType) {
109 this->dataType = dataType;
110 padding = dataLen = 0;
118 std::vector<std::shared_ptr<StructureContent>> stackArray;
125 std::vector<uint32_t> totalLengths;
128 std::shared_ptr<StructureContent> currentStructure =
nullptr;
132 int32_t currentLevel = -1;
138 explicit CompactEventBuilder(std::shared_ptr<ByteBuffer> buffer,
bool generateNodes =
false);
140 void setBuffer(std::shared_ptr<ByteBuffer> buffer,
bool generateNodes =
false);
144 void initBuffer(std::shared_ptr<ByteBuffer> buffer,
bool generateNodes);
154 std::shared_ptr<EvioNode>
openBank(uint16_t tag,
DataType const & dataType, uint8_t num);
163 void addToAllLengths(uint32_t len);
165 void setCurrentHeaderLength(uint32_t len);
166 void setCurrentHeaderPadding(uint32_t padding);
168 void writeHeader(std::shared_ptr<EvioNode> & node);
169 void writeNode(std::shared_ptr<EvioNode> & node,
bool swapData);
176 void addIntData(uint32_t * data, uint32_t len);
184 void toFile(std::string
const & fileName);
192 #endif //EVIO_6_0_COMPACTEVENTBUILDER_H
bool closeStructure()
This method ends the writing of the current evio structure and makes sure the length and padding fiel...
Definition: CompactEventBuilder.cpp:409
void addCompositeData(std::vector< std::shared_ptr< CompositeData >> &data)
Appends CompositeData objects to the structure.
Definition: CompactEventBuilder.cpp:1138
void setTopLevelTag(short tag)
In the emu software package, it's necessary to change the top level tag after the top level bank has ...
Definition: CompactEventBuilder.cpp:456
void addLongData(uint64_t *data, uint32_t len)
Appends long data to the structure.
Definition: CompactEventBuilder.cpp:934
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
void addEvioNode(std::shared_ptr< EvioNode > node)
Adds the evio structure represented by the EvioNode object into the buffer.
Definition: CompactEventBuilder.cpp:680
This class is used for creating events and their substructures while minimizing use of objects...
Definition: CompactEventBuilder.h:47
void addDoubleData(double *data, uint32_t len)
Appends double data to the structure.
Definition: CompactEventBuilder.cpp:1044
void addStringData(std::vector< std::string > &strings)
Appends string data to the structure.
Definition: CompactEventBuilder.cpp:1094
void addShortData(uint16_t *data, uint32_t len)
Appends short data to the structure.
Definition: CompactEventBuilder.cpp:855
void closeAll()
This method finishes the event writing by setting all the proper lengths & padding and ends up at the...
Definition: CompactEventBuilder.cpp:445
std::shared_ptr< EvioNode > openTagSegment(int tag, DataType dataType)
This method adds an evio tagsegment structure to the buffer.
Definition: CompactEventBuilder.cpp:242
CompactEventBuilder(size_t bufferSize, ByteOrder const &order, bool generateNodes=false)
This is the constructor to use for building a new event (just the event in a buffer, not the full evio file format).
Definition: CompactEventBuilder.cpp:31
static const DataType BANK
Bank.
Definition: DataType.h:52
void toFile(std::string const &fileName)
This method writes a file in proper evio format with block header containing the single event constru...
Definition: CompactEventBuilder.cpp:1190
std::shared_ptr< EvioNode > openSegment(uint16_t tag, DataType const &dataType)
This method adds an evio segment structure to the buffer.
Definition: CompactEventBuilder.cpp:166
Numerical values associated with evio data types.
Definition: DataType.h:32
void addIntData(uint32_t *data, uint32_t len)
Appends int data to the structure.
Definition: CompactEventBuilder.cpp:799
std::shared_ptr< ByteBuffer > getBuffer()
Get the buffer being written into.
Definition: CompactEventBuilder.cpp:141
static const DataType UNKNOWN32
Unknown data type.
Definition: DataType.h:36
size_t getTotalBytes() const
Get the total number of bytes written into the buffer.
Definition: CompactEventBuilder.cpp:151
void addByteData(uint8_t *data, uint32_t len)
Appends byte data to the structure.
Definition: CompactEventBuilder.cpp:735
void setBuffer(std::shared_ptr< ByteBuffer > buffer, bool generateNodes=false)
Set the buffer to be written into.
Definition: CompactEventBuilder.cpp:94
void addFloatData(float *data, uint32_t len)
Appends float data to the structure.
Definition: CompactEventBuilder.cpp:993
std::shared_ptr< EvioNode > openBank(uint16_t tag, DataType const &dataType, uint8_t num)
This method adds an evio bank to the buffer.
Definition: CompactEventBuilder.cpp:324
static const ByteOrder ENDIAN_LOCAL
Local host's byte order.
Definition: ByteOrder.h:61