ifw-daq
2.1.0-pre1
IFW Data Acquisition modules
|
Go to the documentation of this file.
8 #ifndef DAQ_OCM_DAQ_FITS_KEYWORD_HPP_
9 #define DAQ_OCM_DAQ_FITS_KEYWORD_HPP_
21 #include <cfitsio/fitsio.h>
31 static constexpr
size_t RECORD_LENGTH = 80u;
35 static constexpr
size_t KEYWORD_NAME_LENGTH = 8u;
39 static constexpr std::string_view ESO_HIERARCH_PREFIX =
"HIERARCH ESO ";
44 static constexpr
size_t ESO_HIERARCH_MAX_NAME_LENGTH =
45 RECORD_LENGTH - ESO_HIERARCH_PREFIX.size() - 4u;
49 static constexpr std::string_view VALUE_INDICATOR =
"= ";
53 static constexpr std::string_view BLANK_CHARS = std::string_view(
" \0", 2);
90 Structure = TYP_STRUC_KEY,
91 Compression = TYP_CMPRS_KEY,
98 HduId = TYP_HDUID_KEY,
99 Checksum = TYP_CKSUM_KEY,
101 RefSys = TYP_REFSYS_KEY,
102 Comment = TYP_COMM_KEY,
103 Continue = TYP_CONT_KEY,
112 bool operator==(KeywordNameView lhs, KeywordNameView rhs) noexcept;
118 bool operator!=(KeywordNameView lhs, KeywordNameView rhs) noexcept;
151 explicit
LiteralKeyword(std::array<
char, constants::RECORD_LENGTH> record);
171 return m_components.
type;
187 return {m_components.
name, m_components.
type};
196 std::string_view
GetRecord() const& noexcept;
197 constexpr std::string_view
GetRecord() && noexcept = delete;
207 std::array<char, constants::RECORD_LENGTH> m_record;
209 Components m_components;
218 bool operator<(LiteralKeyword
const&, LiteralKeyword
const&) noexcept;
226 bool operator==(LiteralKeyword
const& lhs, LiteralKeyword
const& rhs) noexcept;
234 bool operator!=(LiteralKeyword
const&, LiteralKeyword
const&) noexcept;
236 std::ostream&
operator<<(std::ostream& os, LiteralKeyword
const& kw);
243 using ValueType = std::variant<std::string, int64_t, uint64_t, double, bool>;
265 template <
class Trait>
271 char const* string_value,
272 std::optional<std::
string>
comment = std::nullopt);
275 std::optional<std::
string>
comment = std::nullopt);
389 template <
class Trait>
392 template <
class Trait>
428 return keyword.GetName();
432 return keyword.GetName();
440 return std::visit([&](
auto const& kw) {
return kw.GetName(); }, keyword);
505 KeywordVector::iterator position,
506 KeywordVector::const_iterator from_first,
507 KeywordVector::const_iterator from_last);
520 LiteralKeyword
Format(LiteralKeyword::Components
const& keyword);
554 void StandardSort(std::vector<LiteralKeyword>& keywords);
559 #endif // #ifndef DAQ_OCM_DAQ_KEYWORD_HPP_
std::string_view GetRecord() const &noexcept
LiteralKeyword() noexcept
Initializes an empty record (filled with ' ' characters)
std::variant< ValueKeyword, EsoKeyword, LiteralKeyword > KeywordVariant
The different variants of keywords that are supported.
std::ostream & operator<<(std::ostream &os, LiteralKeyword const &kw)
void StandardSort(std::vector< LiteralKeyword > &keywords)
Sorts keywords according to ESO DICD standards.
BasicKeyword(BasicKeyword &&) noexcept=default
bool operator<(LiteralKeyword const &, LiteralKeyword const &) noexcept
Sort by logical keyword name (not DICD sort)
constexpr Components GetComponents() const &noexcept
Get components of the keyword in its literal form with insignifant whitespaces removed.
static constexpr KeywordType GetKeywordType() noexcept
KeywordType
Type of FITS keyword.
BasicKeyword(BasicKeyword const &)=default
bool NameEquals(KeywordVariant const &lhs, KeywordVariant const &rhs) noexcept
Compare logical keyword names of keyword of the same type.
@ Eso
An ESO hiearchical keyword.
constexpr KeywordNameView GetName() const &noexcept
Query logical keyword name.
std::variant< std::string, int64_t, uint64_t, double, bool > ValueType
void InsertKeywords(KeywordVector &keywords, KeywordVector::iterator position, KeywordVector::const_iterator from_first, KeywordVector::const_iterator from_last)
Insert keywords.
BasicKeyword< EsoKeywordTraits > EsoKeyword
ESO hiearchical keyword.
Decomposed components a literal keyword.
bool operator<(BasicKeyword const &rhs) const noexcept
Uses name property as the sorting index.
KeywordClass GetKeywordClass(std::string_view name)
Get keyword class.
LiteralKeyword Format(KeywordVariant const &keyword)
A type safe version of LiteralKeyword that consist of the three basic components of a FITS keyword ke...
constexpr KeywordNameView GetName() const &noexcept
Query logical keyword name.
std::optional< std::string > comment
Trimmed keyword comment.
std::string_view comment
Comment may be empty.
bool operator()(LiteralKeyword const &, LiteralKeyword const &) noexcept
bool operator==(KeywordNameView lhs, KeywordNameView rhs) noexcept
@ Commentary
A commentary keyword, which are keywords that do not fall into the previous categories.
KeywordClass
Fits keyword type.
Non template base class that is purely used to avoid type-deduction issues of ValueType.
constexpr KeywordType GetType() const noexcept
bool operator!=(KeywordNameView lhs, KeywordNameView rhs) noexcept
void UpdateKeywords(KeywordVector &to, KeywordVector const &from, ConflictPolicy policy=ConflictPolicy::Replace)
Updates to with keywords from from.
BasicKeyword< ValueKeywordTraits > ValueKeyword
Standard FITS value keyword.
KeywordNameView GetName() &&=delete
KeywordNameView GetName() &&noexcept=delete
std::vector< KeywordVariant > KeywordVector
Vector of keywords.
@ Replace
Replace keyword that conflicts.
std::variant< ValueKeyword, EsoKeyword > TypedKeywordVariant
Subset of value-typed keywords.
static constexpr KeywordType GetKeywordType() noexcept
constexpr KeywordNameView GetKeywordName(EsoKeyword const &keyword) noexcept
Get keyword name from keyword.
bool operator!=(BasicKeyword const &rhs) const noexcept
Compares all members for inequality.
Represents the literal 80-character FITS keyword record.
std::string name
Trimmed keyword name.
bool operator==(BasicKeyword const &rhs) const noexcept
Compares all members for equality.