mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 19:54:13 +02:00
Change shared_ptr for unique_ptr
This commit is contained in:
@@ -26,7 +26,7 @@ class FastH5Writer {
|
||||
uint64_t current_pulse_id_;
|
||||
size_t current_frame_index_;
|
||||
|
||||
std::unordered_map<std::string, std::shared_ptr<char[]>> buffers_;
|
||||
std::unordered_map<std::string, std::unique_ptr<char>> buffers_;
|
||||
std::unordered_map<std::string, H5::DataSet> datasets_;
|
||||
|
||||
std::unordered_map<std::string, H5::PredType> scalar_metadata_;
|
||||
@@ -44,6 +44,8 @@ public:
|
||||
const std::string& device_name,
|
||||
const std::string& root_folder);
|
||||
|
||||
virtual ~FastH5Writer();
|
||||
|
||||
template <class T> void add_scalar_metadata(
|
||||
const std::string& metadata_name);
|
||||
|
||||
|
||||
@@ -69,10 +69,16 @@ void FastH5Writer::create_file(const string& filename)
|
||||
|
||||
size_t n_buffer_bytes =
|
||||
dataset.getDataType().getSize() * n_frames_per_file_;
|
||||
buffers_.insert({dataset_name, make_shared<char[]>(n_buffer_bytes)});
|
||||
buffers_.insert(
|
||||
{dataset_name, make_unique<char>(n_buffer_bytes)});
|
||||
}
|
||||
}
|
||||
|
||||
FastH5Writer::~FastH5Writer()
|
||||
{
|
||||
close_file();
|
||||
}
|
||||
|
||||
void FastH5Writer::close_file()
|
||||
{
|
||||
flush_metadata();
|
||||
@@ -129,28 +135,28 @@ void FastH5Writer::flush_metadata()
|
||||
|
||||
void FastH5Writer::write_data(const char *buffer)
|
||||
{
|
||||
hsize_t offset[3] = {current_frame_index_, 0, 0};
|
||||
hsize_t offset[3] = {current_frame_index_, 0, 0};
|
||||
|
||||
if(H5DOwrite_chunk(
|
||||
current_image_dataset_.getId(),
|
||||
H5P_DEFAULT,
|
||||
0, // Filters
|
||||
offset, // Offset
|
||||
frame_bytes_size_,
|
||||
buffer))
|
||||
{
|
||||
stringstream err_msg;
|
||||
if(H5DOwrite_chunk(
|
||||
current_image_dataset_.getId(),
|
||||
H5P_DEFAULT,
|
||||
0, // Filters
|
||||
offset, // Offset
|
||||
frame_bytes_size_,
|
||||
buffer))
|
||||
{
|
||||
stringstream err_msg;
|
||||
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
err_msg << "[" << system_clock::now() << "]";
|
||||
err_msg << "[FastH5Writer::write_data]";
|
||||
// TODO: This error message is bad. Extract the real error from lib.
|
||||
err_msg << " Error when writing to ";
|
||||
err_msg << current_output_filename_;
|
||||
using namespace date;
|
||||
using namespace chrono;
|
||||
err_msg << "[" << system_clock::now() << "]";
|
||||
err_msg << "[FastH5Writer::write_data]";
|
||||
// TODO: This error message is bad. Extract the real error from lib.
|
||||
err_msg << " Error when writing to ";
|
||||
err_msg << current_output_filename_;
|
||||
|
||||
throw runtime_error(err_msg.str());
|
||||
}
|
||||
throw runtime_error(err_msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
void FastH5Writer::write_scalar_metadata(
|
||||
|
||||
Reference in New Issue
Block a user