ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
merge.hpp
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup daq_dpm_merge
4 * @copyright ESO - European Southern Observatory
5 */
6#ifndef DAQ_DPM_MERGE_MERGE_HPP
7#define DAQ_DPM_MERGE_MERGE_HPP
8#include <vector>
9
10#include <log4cplus/logger.h>
11
12#include "sources.hpp"
13
14namespace daq::dpm::merge {
15
16/**
17 * Base class of merge events.
18 */
20public:
21};
22
23/**
24 * Interface to reporter (implementations exist for JSON or human readable)
25 */
27public:
28 /**
29 * Post event
30 */
31 virtual void PostAlert(std::string const& id, std::string const& message) = 0;
32};
33
35public:
36 /**
37 * Format keyword.
38 *
39 * @param keyword Keyword to format.
40 */
42};
43
45public:
46 /**
47 * Sort keywords
48 *
49 * @note Sorting function must abide by FITS standard and e.g. not reorder keywords with a
50 * mandatory order.
51 *
52 * @param[in,out] keywords Vector of keywords to format.
53 */
54 virtual void SortKeywords(std::vector<fits::LiteralKeyword>& keywords) = 0;
55};
56
57/**
58 * Interface to a keyword selector.
59 */
61public:
62 /**
63 * Creates a keyword pattern selector
64 *
65 * @param patterns Selection patterns in the format: "+e INS *", "-e INS TEMP[12] *",
66 * "+v VALUEKW".
67 * @returns Function that returns true for the provided keyword if it patches the pattern, and
68 * false otherwise.
69 */
70 virtual std::function<bool(fits::KeywordVariant const&)>
71 MakePatternsFilter(std::vector<std::string> const& patterns) = 0;
72};
73
75public:
76 /**
77 * Replace keyword name using regular expression.
78 *
79 * @param regexp Regular expression pattern.
80 * @param format Regular expression format replacement string.
81 */
82 virtual void Transform(std::string const& regexp,
83 std::string const& format,
84 fits::KeywordVector::iterator begin,
85 fits::KeywordVector::iterator end) = 0;
86};
87
88struct Operations {
92 log4cplus::Logger const& logger;
93};
94
96 TargetSource& target,
97 std::vector<SourceTypes> const& sources,
98 bool dry_run);
99
100struct Params {
101 std::string arcfile;
102 std::string origfile;
103};
104
105/**
106 * Check for data in primary HDU which would not be merged and produce alert.
107 *
108 * @param status_reporter The implementation used to set alert.
109 * @param file The file to check.
110 */
111void CheckUnmergedPrimaryHduData(log4cplus::Logger const& logger,
112 StatusReporter& status_reporter,
113 FitsFileSource const& source);
114
115/**
116 * Merge @a sources into the target @a target.
117 *
118 * @param[in,out] target FITS file target.
119 * @param sources Input sources.
120 */
121void Merge(Operations ops,
122 Params const& params,
123 TargetSource& target,
124 std::vector<SourceTypes> const& sources,
125 bool dry_run);
126
127} // namespace daq::dpm::merge
128
129#endif // #ifndef DAQ_DPM_MERGE_MERGE_HPP
Input FITS source file.
Definition: sources.hpp:144
Interface to a keyword selector.
Definition: merge.hpp:60
virtual std::function< bool(fits::KeywordVariant const &)> MakePatternsFilter(std::vector< std::string > const &patterns)=0
Creates a keyword pattern selector.
virtual fits::LiteralKeyword FormatKeyword(fits::KeywordVariant const &keyword)=0
Format keyword.
virtual void SortKeywords(std::vector< fits::LiteralKeyword > &keywords)=0
Sort keywords.
virtual void Transform(std::string const &regexp, std::string const &format, fits::KeywordVector::iterator begin, fits::KeywordVector::iterator end)=0
Replace keyword name using regular expression.
Interface to reporter (implementations exist for JSON or human readable)
Definition: merge.hpp:26
virtual void PostAlert(std::string const &id, std::string const &message)=0
Post event.
Represents the literal 80-character FITS keyword record.
Definition: keyword.hpp:129
KeywordFormatter & keyword_formatter
Definition: merge.hpp:90
std::string arcfile
Definition: merge.hpp:101
log4cplus::Logger const & logger
Definition: merge.hpp:92
void CheckUnmergedPrimaryHduData(log4cplus::Logger const &logger, StatusReporter &status_reporter, FitsFileSource const &source)
Check for data in primary HDU which would not be merged and produce alert.
Definition: merge.cpp:15
std::string origfile
Definition: merge.hpp:102
KeywordSorter & keyword_sorter
Definition: merge.hpp:91
void Merge(Operations ops, Params const &params, TargetSource &target, std::vector< SourceTypes > const &sources, bool dry_run)
Merge sources into the target target.
Definition: merge.cpp:351
StatusReporter & status_reporter
Definition: merge.hpp:89
void MergePrimaryHduKeywords(Operations ops, Params const &params, TargetSource &target, std::vector< SourceTypes > const &sources, bool dry_run)
Definition: merge.cpp:189
Base class of merge events.
Definition: merge.hpp:19
std::variant< ValueKeyword, EsoKeyword, LiteralKeyword > KeywordVariant
The different variants of keywords that are supported.
Definition: keyword.hpp:409