11 #ifndef EVIO_6_0_WRITER_H
12 #define EVIO_6_0_WRITER_H
57 std::string fileName =
"";
59 std::ofstream outFile;
63 std::future<void> future;
65 std::shared_ptr<RecordOutput> unusedRecord =
nullptr;
70 std::shared_ptr<ByteBuffer> buffer;
75 std::shared_ptr<ByteBuffer> userHeaderBuffer =
nullptr;
77 uint8_t* userHeader =
nullptr;
79 uint32_t userHeaderLength = 0;
83 std::string dictionary;
85 std::shared_ptr<ByteBuffer> dictionaryFirstEventBuffer;
87 uint8_t* firstEvent =
nullptr;
89 uint32_t firstEventLength = 0;
94 std::shared_ptr<RecordOutput> outputRecord =
nullptr;
96 std::shared_ptr<RecordOutput> beingWrittenRecord =
nullptr;
98 std::vector<uint8_t> headerArray;
105 std::shared_ptr<std::vector<uint32_t>> recordLengths;
108 size_t writerBytesWritten = 0;
110 uint32_t recordNumber = 1;
113 bool addingTrailer =
true;
115 bool addTrailerIndex =
false;
121 bool firstRecordWritten =
false;
123 bool haveDictionary =
false;
125 bool haveFirstEvent =
false;
127 bool haveUserHeader =
false;
136 uint32_t maxEventCount = 0,
137 uint32_t maxBufferSize = 0);
139 Writer(
const std::string & filename,
141 uint32_t maxEventCount = 0,
142 uint32_t maxBufferSize = 0);
146 uint32_t maxEventCount = 0,
147 uint32_t maxBufferSize = 0,
148 const std::string & dictionary = std::string(
""),
149 uint8_t* firstEvent =
nullptr,
150 uint32_t firstEventLength = 0,
152 bool addTrailerIndex =
false);
156 explicit Writer(std::shared_ptr<ByteBuffer> & buf);
157 Writer(std::shared_ptr<ByteBuffer> & buf, uint8_t * userHdr, uint32_t len);
158 Writer(std::shared_ptr<ByteBuffer> & buf, uint32_t maxEventCount, uint32_t maxBufferSize,
159 const std::string & dictionary, uint8_t* firstEvent, uint32_t firstEventLength);
172 std::shared_ptr<ByteBuffer> createDictionaryRecord();
174 void writeOutputToBuffer();
176 static void staticWriteFunction(
Writer *pWriter,
const char* data,
size_t len);
193 void open(
const std::string & filename);
194 void open(
const std::string & filename, uint8_t* userHdr, uint32_t len);
195 void open(std::shared_ptr<ByteBuffer> & buf, uint8_t* userHdr, uint32_t len);
197 static std::shared_ptr<ByteBuffer>
createRecord(
const std::string & dictionary,
198 uint8_t* firstEvent, uint32_t firstEventLen,
203 std::shared_ptr<ByteBuffer>
createHeader(uint8_t* userHdr, uint32_t userLen);
212 void addEvent(uint8_t* buffer, uint32_t length);
213 void addEvent(std::shared_ptr<ByteBuffer> & buffer);
215 void addEvent(std::shared_ptr<EvioBank> & bank);
216 void addEvent(std::shared_ptr<EvioNode> & node);
224 void writeTrailer(
bool writeIndex, uint32_t recordNum, uint64_t trailerPos);
231 #endif //EVIO_6_0_WRITER_H
This class is copied from one of the same name in the Java programming language.
Definition: ByteBuffer.h:42
FileHeader & getFileHeader()
Get the file header.
Definition: Writer.cpp:357
void addEvent(uint8_t *buffer, uint32_t length)
Add a byte array to the internal record.
Definition: Writer.cpp:1014
void writeRecord(RecordOutput &record)
Appends the record to the file/buffer.
Definition: Writer.cpp:953
CompressionType
Enum of supported data compression types.
Definition: Compressor.h:65
Numerical values associated with endian byte order.
Definition: ByteOrder.h:53
void setCompressionType(Compressor::CompressionType compression)
Convenience method that sets compression type for the file.
Definition: Writer.cpp:387
Compressor::CompressionType getCompressionType()
Get the internal record's header.
Definition: Writer.cpp:377
Definition: Compressor.h:66
void close()
Close opened file.
Definition: Writer.cpp:1247
Class which handles the creation and use of Evio & HIPO Records.
Definition: RecordOutput.h:105
const ByteOrder & getByteOrder() const
Get the file's byte order.
Definition: Writer.cpp:350
bool addTrailerWithIndex()
Does this writer add a trailer with a record index to the end of the file? Or, if writing to a buffer...
Definition: Writer.cpp:418
std::shared_ptr< ByteBuffer > createHeader(uint8_t *userHdr, uint32_t userLen)
Create and return a buffer containing a general file header followed by the user header given in the ...
Definition: Writer.cpp:682
Class to write Evio-6.0/HIPO files.
Definition: Writer.h:47
This class is used to store relevant info about an evio container (bank, segment, or tag segment)...
Definition: EvioNode.h:41
void open(const std::string &filename)
Open a new file and write file header with no user header.
Definition: Writer.cpp:448
Writer()
Default constructor.
Definition: Writer.cpp:21
static std::shared_ptr< ByteBuffer > createRecord(const std::string &dictionary, uint8_t *firstEvent, uint32_t firstEventLen, const ByteOrder &byteOrder, FileHeader *fileHeader, RecordHeader *recordHeader)
STATIC.
Definition: Writer.cpp:618
void reset()
Get this object ready for re-use.
Definition: Writer.cpp:1228
std::shared_ptr< ByteBuffer > getBuffer()
Get the buffer being written to.
Definition: Writer.cpp:343
bool addTrailer() const
Does this writer add a trailer to the end of the file/buffer?
Definition: Writer.cpp:399
static const ByteOrder ENDIAN_LOCAL
Local host's byte order.
Definition: ByteOrder.h:61