AARE
Data analysis library for PSI hybrid detectors
Loading...
Searching...
No Matches
SubFile.hpp
Go to the documentation of this file.
1#pragma once
2#include "aare/core/defs.hpp"
3#include <cstdint>
4#include <filesystem>
5#include <map>
6#include <variant>
7
8namespace aare {
9
13class SubFile {
14 protected:
20 using pfunc = size_t (SubFile::*)(std::byte *);
21 pfunc read_impl = nullptr;
28 std::map<std::pair<DetectorType, int>, pfunc> read_impl_map = {
29 {{DetectorType::Moench, 16}, &SubFile::read_impl_reorder<uint16_t>},
35
36 };
37
38 public:
48 SubFile(std::filesystem::path fname, DetectorType detector, ssize_t rows, ssize_t cols, uint16_t bitdepth);
49
55 size_t read_impl_normal(std::byte *buffer);
56
62 template <typename DataType> size_t read_impl_flip(std::byte *buffer);
63
69 template <typename DataType> size_t read_impl_reorder(std::byte *buffer);
70
77 size_t get_part(std::byte *buffer, int frame_number);
78 size_t frame_number(int frame_index);
79
80 // TODO: define the inlines as variables and assign them in constructor
81 inline size_t bytes_per_part() { return (m_bitdepth / 8) * m_rows * m_cols; }
82 inline size_t pixels_per_part() { return m_rows * m_cols; }
83
84 protected:
85 FILE *fp = nullptr;
86 ssize_t m_bitdepth;
87 std::filesystem::path m_fname;
88 ssize_t m_rows{};
89 ssize_t m_cols{};
90 ssize_t n_frames{};
92};
93
94} // namespace aare
Class to read a subfile from a RawFile.
Definition SubFile.hpp:13
size_t(SubFile::*)(std::byte *) pfunc
type of the read_impl function pointer
Definition SubFile.hpp:20
ssize_t m_rows
Definition SubFile.hpp:88
size_t bytes_per_part()
Definition SubFile.hpp:81
size_t get_part(std::byte *buffer, int frame_number)
read the subfile into a buffer with the bytes reordered and flipped
Definition SubFile.cpp:24
pfunc read_impl
Definition SubFile.hpp:21
size_t read_impl_normal(std::byte *buffer)
read the subfile into a buffer
Definition SubFile.cpp:40
std::filesystem::path m_fname
Definition SubFile.hpp:87
size_t pixels_per_part()
Definition SubFile.hpp:82
int m_sub_file_index_
Definition SubFile.hpp:91
size_t read_impl_reorder(std::byte *buffer)
read the subfile into a buffer with the bytes reordered
Definition SubFile.cpp:42
FILE * fp
Definition SubFile.hpp:85
ssize_t n_frames
Definition SubFile.hpp:90
std::map< std::pair< DetectorType, int >, pfunc > read_impl_map
map to store the read_impl functions for different detectors
Definition SubFile.hpp:28
ssize_t m_bitdepth
Definition SubFile.hpp:86
size_t frame_number(int frame_index)
Definition SubFile.cpp:92
ssize_t m_cols
Definition SubFile.hpp:89
size_t read_impl_flip(std::byte *buffer)
read the subfile into a buffer with the bytes flipped
Definition SubFile.cpp:70
Frame class to represent a single frame of data model class should be able to work with streams comin...
Definition CircularFifo.hpp:11
DetectorType
Definition defs.hpp:41