ifw-daq  2.1.0-pre1
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
daq::dpm::merge::Operations
Definition: merge.hpp:88
daq::fits::KeywordVariant
std::variant< ValueKeyword, EsoKeyword, LiteralKeyword > KeywordVariant
The different variants of keywords that are supported.
Definition: keyword.hpp:400
daq::dpm::merge::Params::origfile
std::string origfile
Definition: merge.hpp:102
daq::dpm::merge::KeywordFilter
Interface to a keyword selector.
Definition: merge.hpp:60
daq::dpm::merge::Operations::keyword_sorter
KeywordSorter & keyword_sorter
Definition: merge.hpp:91
daq::dpm::merge::KeywordTransform
Definition: merge.hpp:74
daq::dpm::merge::MergeEvent
Base class of merge events.
Definition: merge.hpp:19
daq::dpm::merge::Operations::keyword_formatter
KeywordFormatter & keyword_formatter
Definition: merge.hpp:90
daq::dpm::merge::KeywordSorter::SortKeywords
virtual void SortKeywords(std::vector< fits::LiteralKeyword > &keywords)=0
Sort keywords.
daq::dpm::merge::StatusReporter
Interface to reporter (implementations exist for JSON or human readable)
Definition: merge.hpp:26
daq::dpm::merge::KeywordTransform::Transform
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.
daq::dpm::merge::Merge
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
daq::dpm::merge::Params
Definition: merge.hpp:100
daq::dpm::merge::KeywordFilter::MakePatternsFilter
virtual std::function< bool(fits::KeywordVariant const &)> MakePatternsFilter(std::vector< std::string > const &patterns)=0
Creates a keyword pattern selector.
daq::dpm::merge::KeywordSorter
Definition: merge.hpp:44
daq::dpm::merge::TargetSource
Target FITS file.
Definition: sources.hpp:111
daq::dpm::merge::Operations::status_reporter
StatusReporter & status_reporter
Definition: merge.hpp:89
daq::dpm::merge::Operations::logger
log4cplus::Logger const & logger
Definition: merge.hpp:92
daq::dpm::merge
Definition: entrypoint.cpp:26
daq::dpm::merge::MergePrimaryHduKeywords
void MergePrimaryHduKeywords(Operations ops, Params const &params, TargetSource &target, std::vector< SourceTypes > const &sources, bool dry_run)
Definition: merge.cpp:129
daq::dpm::merge::StatusReporter::PostAlert
virtual void PostAlert(std::string const &id, std::string const &message)=0
Post event.
daq::dpm::merge::KeywordFormatter
Definition: merge.hpp:34
daq::dpm::merge::Params::arcfile
std::string arcfile
Definition: merge.hpp:101
daq::fits::LiteralKeyword
Represents the literal 80-character FITS keyword record.
Definition: keyword.hpp:125
sources.hpp
daq::dpm::merge::KeywordFormatter::FormatKeyword
virtual fits::LiteralKeyword FormatKeyword(fits::KeywordVariant const &keyword)=0
Format keyword.