From 60624bcd6de144550b923d8c6dcb05a2ed6fb014 Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Wed, 26 Sep 2018 14:43:14 +0200 Subject: [PATCH] Clean up csaxs format --- csaxs/CsaxsFormat.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 csaxs/CsaxsFormat.cpp diff --git a/csaxs/CsaxsFormat.cpp b/csaxs/CsaxsFormat.cpp new file mode 100644 index 0000000..9bba396 --- /dev/null +++ b/csaxs/CsaxsFormat.cpp @@ -0,0 +1,74 @@ +#include +#include + +#include "config.hpp" +#include "H5Format.hpp" + +using namespace std; +using s_ptr = shared_ptr; + +class CsaxsFormat : public H5Format +{ + shared_ptr> input_value_type = NULL; + shared_ptr> default_values = NULL; + shared_ptr> dataset_move_mapping = NULL; + shared_ptr file_format = NULL; + + public: + ~CsaxsFormat(){}; + + CsaxsFormat(const string& dataset_name, int n_bad_modules) + { + + // After format has been writen, where to move the raw datasets. + dataset_move_mapping.reset(new std::unordered_map( + { + {config::raw_image_dataset_name, "data/" + dataset_name + "/data"}, + })); + + // Definition of the file format. + file_format.reset( + new h5_parent("", EMPTY_ROOT, { + s_ptr(new h5_group("data", { + s_ptr(new h5_group(dataset_name, {})) + })) + })); + } + + const h5_parent& get_format_definition() const override + { + return *file_format; + } + + const unordered_map& get_default_values() const override + { + return *default_values; + } + + void add_calculated_values(unordered_map& values) const override + { + // No calculated values. + } + + void add_input_values(unordered_map& values, + const unordered_map& input_values) const override + { + // Input value mapping is 1:1. + for (const auto& input_value : input_values) { + const auto& name = input_value.first; + const auto& value = input_value.second; + + values[name] = value; + } + } + + const std::unordered_map& get_input_value_type() const override + { + return *input_value_type; + } + + const unordered_map& get_dataset_move_mapping() const override { + return *dataset_move_mapping; + } + +};