DUNE-DAQ
DUNE Trigger and Data Acquisition software
|
#include <BufferedFileWriter.hpp>
Public Member Functions | |
BufferedFileWriter (std::string filename, size_t buffer_size, std::string compression_algorithm="None", bool use_o_direct=true) | |
BufferedFileWriter () | |
~BufferedFileWriter () | |
BufferedFileWriter (const BufferedFileWriter &)=delete | |
BufferedFileWriter is not copy-constructible. | |
BufferedFileWriter & | operator= (const BufferedFileWriter &)=delete |
BufferedFileWriter is not copy-assginable. | |
BufferedFileWriter (BufferedFileWriter &&)=delete | |
BufferedFileWriter is not move-constructible. | |
BufferedFileWriter & | operator= (BufferedFileWriter &&)=delete |
BufferedFileWriter is not move-assignable. | |
void | open (std::string filename, size_t buffer_size, std::string compression_algorithm="None", bool use_o_direct=true) |
bool | is_open () const |
bool | write (const char *memory, const size_t size) |
void | close () |
void | flush () |
Private Types | |
using | io_sink_t = boost::iostreams::file_descriptor_sink |
using | aligned_allocator_t = boost::alignment::aligned_allocator<io_sink_t::char_type, Alignment> |
using | filtering_ostream_t |
Private Attributes | |
std::string | m_filename |
size_t | m_buffer_size |
std::string | m_compression_algorithm |
int | m_fd |
io_sink_t | m_sink |
filtering_ostream_t | m_output_stream |
bool | m_is_open = false |
bool | m_use_o_direct = true |
Class to buffer and write data of a specified type to a file using O_DIRECT. In addition, data can be compressed. before being written.
ReadoutType | Type of the data that will be written to file |
Alignment | The alignment used for allocations of buffers. It has to fulfil certain system specific requirements such that file writing with O_DIRECT can work. |
Definition at line 47 of file BufferedFileWriter.hpp.
|
private |
Definition at line 50 of file BufferedFileWriter.hpp.
|
private |
Definition at line 51 of file BufferedFileWriter.hpp.
|
private |
Definition at line 49 of file BufferedFileWriter.hpp.
|
inline |
Constructor to construct and initialize an instance. The file will be open after initialization.
filename | The file to be used. Existing data will be overwritten, if the file does not exist it will be created. |
buffer_size | The size of the buffer that is used before data is written to the file. Make sure that this size fulfils size requirements of O_DIRECT, otherwise writes will fail. |
compression_algorithm | The compression algorithm to use. Can be one of: None, zstd, lzma or zlib |
use_o_direct | file descriptors : avoid excessive resource footprint. It also avoids the intermediate aligned buffer, requires the source latency buffer to be memory aligned. |
CannotOpenFile | If the file can not be opened. |
ConfigurationError | If the compression algorithm parameter is not recognized. |
Definition at line 66 of file BufferedFileWriter.hpp.
|
inline |
Constructor to construct an instance without opening a file.
Definition at line 74 of file BufferedFileWriter.hpp.
|
inline |
Destructor that closes the file before destruction to make sure all data in any buffers is written to file.
Definition at line 79 of file BufferedFileWriter.hpp.
|
delete |
BufferedFileWriter is not copy-constructible.
|
delete |
BufferedFileWriter is not move-constructible.
|
inline |
Close the writer. All data from any buffers will be written to file.
Definition at line 167 of file BufferedFileWriter.hpp.
|
inline |
If no compression is used, this writes all data from buffers to the file. In case that compression is used, this is not guaranteed.
Definition at line 180 of file BufferedFileWriter.hpp.
|
inline |
Check if the file is open.
Definition at line 149 of file BufferedFileWriter.hpp.
|
inline |
Open a file.
filename | The file to be used. Existing data will be overwritten, if the file does not exist it will be created. |
buffer_size | The size of the buffer that is used before data is written to the file. Make sure that this size fulfils size requirements of O_DIRECT, otherwise writes will fail. |
compression_algorithm | The compression algorithm to use. Can be one of: None, zstd, lzma or zlib |
use_o_direct | file descriptors : avoid excessive resource footprint. It also avoids the intermediate aligned buffer, requires the source latency buffer to be memory aligned. |
CannotOpenFile | If the file can not be opened. |
ConfigurationError | If the compression algorithm parameter is not recognized. |
Definition at line 101 of file BufferedFileWriter.hpp.
|
delete |
BufferedFileWriter is not move-assignable.
|
delete |
BufferedFileWriter is not copy-assginable.
|
inline |
Write something to the buffer. If the buffer is full, all data from it will be written to file.
element | The element to write. |
Definition at line 156 of file BufferedFileWriter.hpp.
|
private |
Definition at line 198 of file BufferedFileWriter.hpp.
|
private |
Definition at line 199 of file BufferedFileWriter.hpp.
|
private |
Definition at line 202 of file BufferedFileWriter.hpp.
|
private |
Definition at line 197 of file BufferedFileWriter.hpp.
|
private |
Definition at line 205 of file BufferedFileWriter.hpp.
|
private |
Definition at line 204 of file BufferedFileWriter.hpp.
|
private |
Definition at line 203 of file BufferedFileWriter.hpp.
|
private |
Definition at line 206 of file BufferedFileWriter.hpp.