mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 04:02:24 +02:00
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
#ifndef H5WRITER_H
|
|
#define H5WRITER_H
|
|
|
|
#include <map>
|
|
#include "config.hpp"
|
|
#include "h5_utils.hpp"
|
|
|
|
class H5Writer
|
|
{
|
|
// Initialized in constructor.
|
|
std::string filename;
|
|
std::string dataset_name;
|
|
hsize_t frames_per_file;
|
|
hsize_t initial_dataset_size;
|
|
|
|
// Configuration parameters.
|
|
hsize_t dataset_increase_step = config::dataset_increase_step;
|
|
|
|
// State variables.
|
|
hsize_t max_frame_index = 0;
|
|
hsize_t current_dataset_size = 0;
|
|
hsize_t current_frame_chunk = 0;
|
|
|
|
H5::H5File file;
|
|
H5::DataSet dataset;
|
|
|
|
hsize_t prepare_storage_for_frame(size_t frame_index, size_t* frame_shape, std::string& data_type, std::string& endianness);
|
|
void create_file(size_t* frame_shape, hsize_t frame_chunk, std::string& data_type, std::string& endianness);
|
|
|
|
public:
|
|
H5Writer(const std::string filename, const std::string dataset_name, hsize_t frames_per_file=0, hsize_t initial_dataset_size=config::initial_dataset_size);
|
|
~H5Writer();
|
|
bool is_file_open();
|
|
void close_file();
|
|
void write_frame_data(size_t frame_index, size_t* frame_shape, size_t data_bytes_size, char* data, std::string data_type, std::string endianness);
|
|
H5::H5File& get_h5_file();
|
|
};
|
|
|
|
#endif |