File tree Expand file tree Collapse file tree 3 files changed +15
-28
lines changed Expand file tree Collapse file tree 3 files changed +15
-28
lines changed Original file line number Diff line number Diff line change 25
25
#include " ActionStatistics.h"
26
26
#include " eckit/memory/NonCopyable.h"
27
27
#include " multio/config/ComponentConfiguration.h"
28
+ #include " multio/datamod/core/EntryParser.h"
28
29
#include " multio/message/Message.h"
29
30
#include " multio/util/FailureHandling.h"
30
31
@@ -130,4 +131,16 @@ class ActionBuilder final : public ActionBuilderBase {
130
131
131
132
// --------------------------------------------------------------------------------------------------
132
133
134
+ template <typename ParsedConfig>
135
+ ParsedConfig parseConfig (const ComponentConfiguration& compConf) {
136
+ multio::datamod::ParseOptions opts;
137
+ opts.allowAdditionalKeys = false ;
138
+
139
+ auto conf = compConf.parsedConfig ();
140
+ conf.remove (" type" );
141
+ conf.remove (" next" );
142
+
143
+ return multio::datamod::readRecordByValue<ParsedConfig>(conf, opts);
144
+ }
145
+
133
146
} // namespace multio::action
Original file line number Diff line number Diff line change @@ -43,23 +43,9 @@ mars2grib::RawOptions mapOpts(EncodeMtg2Options opts) {
43
43
return ret;
44
44
};
45
45
46
- EncodeMtg2Options parseOpts (const ComponentConfiguration& compConf) {
47
- // / TODO(pgeier) With C++20 designators are more useful for inline creation of structs:
48
- // / ParsedOptions{.allowAdditionalKeys=false}
49
- dm::ParseOptions opts;
50
- opts.allowAdditionalKeys = false ;
51
-
52
- // TODO(pgeier) Fix after refactoring action - need to remove keys "type" and "next"
53
- auto conf = compConf.parsedConfig ();
54
- conf.remove (" type" );
55
- conf.remove (" next" );
56
-
57
- return dm::readRecordByValue<EncodeMtg2Options>(conf, opts);
58
- }
59
-
60
46
61
47
EncodeMtg2::EncodeMtg2 (const ComponentConfiguration& compConf) :
62
- ChainedAction{compConf}, opts_{parseOpts (compConf)}, mars2grib_{mapOpts (opts_)} {}
48
+ ChainedAction{compConf}, opts_{parseConfig<EncodeMtg2Options> (compConf)}, mars2grib_{mapOpts (opts_)} {}
63
49
64
50
65
51
void EncodeMtg2::executeImpl (Message msg) {
Original file line number Diff line number Diff line change 20
20
21
21
namespace multio ::action::scale {
22
22
23
- ScaleConfig parseConfig (const ComponentConfiguration& compConf) {
24
- dm::ParseOptions opts;
25
- opts.allowAdditionalKeys = false ;
26
-
27
- // TODO(pgeier) Fix after refactoring action - need to remove keys "type" and "next"
28
- auto conf = compConf.parsedConfig ();
29
- conf.remove (" type" );
30
- conf.remove (" next" );
31
-
32
- return dm::readRecordByValue<ScaleConfig>(conf, opts);
33
- }
34
-
35
23
const std::vector<ScaleMappingConfig> getPresetMappings (const Preset& preset) {
36
24
// Load the mapping file
37
25
eckit::LocalConfiguration mappingConf{eckit::YAMLConfiguration{eckit::PathName{
@@ -71,7 +59,7 @@ Mappings getMappings(const ScaleConfig& config) {
71
59
}
72
60
73
61
Scale::Scale (const ComponentConfiguration& compConf) :
74
- ChainedAction (compConf), mappings_{getMappings (parseConfig (compConf))} {}
62
+ ChainedAction (compConf), mappings_{getMappings (parseConfig<ScaleConfig> (compConf))} {}
75
63
76
64
void Scale::executeImpl (message::Message msg) {
77
65
// Skip non-field messages
You can’t perform that action at this time.
0 commit comments