Add dataset move logic to format

This commit is contained in:
2018-02-12 16:55:26 +01:00
parent 873af3b7c7
commit e1cfc457b1
3 changed files with 16 additions and 7 deletions
+3 -1
View File
@@ -340,5 +340,7 @@ void H5FormatUtils::write_format(H5::H5File& file, const H5Format& format,
write_format_data(file, format_definition, format_values);
file.move(config::raw_image_dataset_name.c_str(), format.get_frames_dataset_name().c_str());
for (const auto& mapping : format.get_dataset_move_mapping()) {
file.move(mapping.first.c_str(), mapping.second.c_str());
}
}
+2 -2
View File
@@ -100,13 +100,13 @@ class H5Format
virtual void add_input_values(std::unordered_map<std::string, boost::any>& values,
const std::unordered_map<std::string, boost::any>& input_values) const = 0;
virtual std::string get_frames_dataset_name() const = 0;
virtual const std::unordered_map<std::string, std::string>& get_dataset_move_mapping() const = 0;
};
namespace H5FormatUtils
{
hsize_t expand_dataset(H5::DataSet& dataset, hsize_t frame_index, hsize_t dataset_increase_step);
void compact_dataset(H5::DataSet& dataset, hsize_t max_frame_index);
H5::Group create_group(H5::Group& target, const std::string& name);
+11 -4
View File
@@ -4,6 +4,7 @@
#include <iostream>
#include <memory>
#include "../config.hpp"
#include "../H5Format.hpp"
using namespace std;
@@ -13,6 +14,7 @@ class NXmxFormat : public H5Format
{
shared_ptr<unordered_map<string, DATA_TYPE>> input_value_type = NULL;
shared_ptr<unordered_map<string, boost::any>> default_values = NULL;
shared_ptr<unordered_map<string, std::string>> dataset_move_mapping = NULL;
shared_ptr<h5_group> file_format = NULL;
public:
@@ -93,6 +95,11 @@ class NXmxFormat : public H5Format
{"samz", NX_FLOAT},
}));
dataset_move_mapping.reset(new std::unordered_map<string, string>(
{
{config::raw_image_dataset_name, "entry/plottable_data/image"},
}));
// Default values used in the file format.
default_values.reset(new std::unordered_map<string, boost::any>(
{
@@ -897,10 +904,6 @@ class NXmxFormat : public H5Format
}));
}
string get_frames_dataset_name() const override {
return "entry/plottable_data/data";
}
const h5_group& get_format_definition() const override {
return *file_format;
}
@@ -1052,4 +1055,8 @@ class NXmxFormat : public H5Format
return *input_value_type;
}
const unordered_map<string, string>& get_dataset_move_mapping() const override {
return *dataset_move_mapping;
}
};