ifw-daq  3.0.0-pre2
IFW Data Acquisition modules
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 
14 namespace daq::dpm::merge {
15 
16 /**
17  * Base class of merge events.
18  */
19 class MergeEvent {
20 public:
21 };
22 
23 /**
24  * Interface to reporter (implementations exist for JSON or human readable)
25  */
27 public:
28  /**
29  * Post event
30  */
31  virtual void PostAlert(std::string const& id, std::string const& message) = 0;
32 };
33 
35 public:
36  /**
37  * Format keyword.
38  *
39  * @param keyword Keyword to format.
40  */
42 };
43 
45 public:
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  */
61 public:
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 
75 public:
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 
88 struct Operations {
92  log4cplus::Logger const& logger;
93 };
94 
96  TargetSource& target,
97  std::vector<SourceTypes> const& sources,
98  bool dry_run);
99 
100 struct Params {
101  std::string arcfile;
102  std::string origfile;
103 };
104 
105 /**
106  * Merge @a sources into the target @a target.
107  *
108  * @param[in,out] target FITS file target.
109  * @param sources Input sources.
110  */
111 void Merge(Operations ops,
112  Params const& params,
113  TargetSource& target,
114  std::vector<SourceTypes> const& sources,
115  bool dry_run);
116 
117 } // namespace daq::dpm::merge
118 
119 #endif // #ifndef DAQ_DPM_MERGE_MERGE_HPP
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:125
KeywordFormatter & keyword_formatter
Definition: merge.hpp:90
std::string arcfile
Definition: merge.hpp:101
log4cplus::Logger const & logger
Definition: merge.hpp:92
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:286
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:129
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:400