vitrio 0.3.1
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
image_metadata_field.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <vitrio/image_metadata.hpp>
6
7#include <cstddef>
8#include <cstdint>
9#include <string>
10#include <type_traits>
11
12namespace vitrio
13{
14
27template <typename T>
29{
30 static_assert(
31 std::is_same<T, std::int64_t>::value ||
32 std::is_same<T, double>::value ||
33 std::is_same<T, std::string>::value,
34 "The value of a field is a std::int64_t, a double or a std::string."
35 );
36
37public:
38 using value_type = T;
39
46 template <std::size_t N>
47 constexpr explicit image_metadata_field(const char (&label)[N]) noexcept;
48
54 constexpr const char* get_label() const noexcept;
55
56private:
57 const char *m_label;
58};
59
71template <
72 typename T,
73 typename std::enable_if<
74 std::is_arithmetic<T>::value && !std::is_same<T, bool>::value,
75 int
76 >::type = 0
77>
78void set_field(
79 image_metadata &metadata,
80 image_metadata_field<double> field,
81 T value
82);
83
97template <
98 typename T,
99 typename std::enable_if<
100 std::is_integral<T>::value && !std::is_same<T, bool>::value,
101 int
102 >::type = 0
103>
104void set_field(
105 image_metadata &metadata,
106 image_metadata_field<std::int64_t> field,
107 T value
108);
109
121void set_field(
122 image_metadata &metadata,
123 image_metadata_field<std::string> field,
124 std::string value
125);
126
127void set_field(
128 image_metadata &metadata,
129 image_metadata_field<std::string> field,
130 std::nullptr_t value
131) = delete;
132
144template <typename T>
145const T* find_field(
146 const image_metadata &metadata,
147 image_metadata_field<T> field
148);
149
162template <typename T>
163const T& get_field(
164 const image_metadata &metadata,
165 image_metadata_field<T> field
166);
167
168} // namespace vitrio
169
170#include "image_metadata_field.inl"
constexpr const char * get_label() const noexcept
Get the label of this field.
constexpr image_metadata_field(const char(&label)[N]) noexcept
Construct a field from its label.
What an image file states beyond its shape and data type, such as the distance between its samples.
Definition image_metadata.hpp:35