vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
image_descriptor.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <vitrio/array/numerical_type.hpp>
6#include <vitrio/export.hpp>
7#include <vitrio/span.hpp>
8
9#include <cstddef>
10#include <functional>
11#include <vector>
12
13namespace vitrio
14{
15
28{
29public:
39 VITRIO_API
42 std::size_t core_rank,
43 numerical_type data_type
44 );
45
46 VITRIO_API
48 VITRIO_API
49 image_descriptor(image_descriptor &&other) noexcept;
50 VITRIO_API
52
53 VITRIO_API
54 image_descriptor& operator=(const image_descriptor &other);
55 VITRIO_API
56 image_descriptor& operator=(image_descriptor &&other) noexcept;
57
63 VITRIO_API
64 std::size_t hash() const noexcept;
65
72 VITRIO_API
73 span<const std::size_t> get_extents() const noexcept;
74
81 VITRIO_API
82 std::size_t get_core_rank() const noexcept;
83
89 VITRIO_API
90 numerical_type get_data_type() const noexcept;
91
92 friend bool operator==(
93 const image_descriptor &lhs,
94 const image_descriptor &rhs
95 ) noexcept
96 {
97 return
98 lhs.m_core_rank == rhs.m_core_rank &&
99 lhs.m_data_type == rhs.m_data_type &&
100 lhs.m_extents == rhs.m_extents;
101 }
102
103 friend bool operator!=(
104 const image_descriptor &lhs,
105 const image_descriptor &rhs
106 ) noexcept
107 {
108 return !(lhs == rhs);
109 }
110
111private:
112 std::vector<std::size_t> m_extents;
113 std::size_t m_core_rank;
114 numerical_type m_data_type;
115};
116
127VITRIO_API
128span<const std::size_t>
129get_core_extents(const image_descriptor &descriptor) noexcept;
130
131} // namespace vitrio
132
133namespace std
134{
135
136template<>
137struct hash<vitrio::image_descriptor>
138{
139 std::size_t operator()(
140 const vitrio::image_descriptor &descriptor
141 ) const noexcept
142 {
143 return descriptor.hash();
144 }
145};
146
147} // namespace std
The shape and data type of the values an image file holds.
Definition image_descriptor.hpp:28
span< const std::size_t > get_extents() const noexcept
Get the extents of the file.
numerical_type get_data_type() const noexcept
Get the data type of the elements.
std::size_t get_core_rank() const noexcept
Get how many of the extents are one image or volume.
image_descriptor(span< const std::size_t > extents, std::size_t core_rank, numerical_type data_type)
Construct a descriptor from its components.
std::size_t hash() const noexcept
Get the hash value for this descriptor.
A view of a contiguous sequence of elements.
Definition span.hpp:29