// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include #include #include #include #include #include "JFJochReader.h" #include "JFJochReaderSpots.h" #include "HDF5ImageSource.h" #include "HDF5MetadataSource.h" #include "../writer/HDF5Objects.h" #include "../image_analysis/IntegrationOutcome.h" // Composes one shared raw-image source with one or more metadata sources ("snapshots") over the // same images: the original _master.h5 plus optional reprocessing _process.h5 results. The active // snapshot supplies the dataset and per-image metadata; the image source always supplies pixels, // so switching snapshots never reloads image data. class JFJochHDF5Reader : public JFJochReader { HDF5ImageSource image_source_; std::map > snapshots_; std::shared_ptr active_metadata_; std::string active_snapshot_; size_t number_of_images = 0; bool LoadImage_i(std::shared_ptr &dataset, DataMessage &message, std::vector &buffer, int64_t image_number, bool update_dataset) override; HDF5ImageLocator::Location GetImageLocation(int64_t image_number) const; public: ~JFJochHDF5Reader() override = default; void ReadFile(const std::string &filename); uint64_t GetNumberOfImages() const override; void Close() override; std::vector GetHDF5DataSource( uint64_t first_image = 0, std::optional image_count = {} ) const; std::vector ReadReflections(size_t start_image = 0, std::optional end_image = {}) const; std::vector ReadSpots(int64_t image) const override; // True if the loaded file stores spot-finding results; false for a plain DECTRIS dataset (no // /entry/MX), so callers can find spots instead of reusing absent ones. [[nodiscard]] bool HasStoredSpots() const; CompressedImage ReadCalibration(std::vector &tmp, const std::string &name) const; std::shared_ptr GetRawImage(int64_t image_number) override; // Metadata snapshots over the same images. The original file is registered as "Original" on // ReadFile and is the initial active snapshot; reprocessing results can be added later. void RegisterSnapshot(const std::string &name, const std::string &master_path); void RemoveSnapshot(const std::string &name); // "Original" cannot be removed void SetActiveSnapshot(const std::string &name); std::vector SnapshotNames() const; std::string ActiveSnapshot() const; // All snapshot datasets (name -> dataset), for overlaying every run's plots at once. std::vector>> AllSnapshotDatasets() const; };