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 2525#include " ActionStatistics.h"
2626#include " eckit/memory/NonCopyable.h"
2727#include " multio/config/ComponentConfiguration.h"
28+ #include " multio/datamod/core/EntryParser.h"
2829#include " multio/message/Message.h"
2930#include " multio/util/FailureHandling.h"
3031
@@ -130,4 +131,16 @@ class ActionBuilder final : public ActionBuilderBase {
130131
131132// --------------------------------------------------------------------------------------------------
132133
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+
133146} // namespace multio::action
Original file line number Diff line number Diff line change @@ -43,23 +43,9 @@ mars2grib::RawOptions mapOpts(EncodeMtg2Options opts) {
4343 return ret;
4444};
4545
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-
6046
6147EncodeMtg2::EncodeMtg2 (const ComponentConfiguration& compConf) :
62- ChainedAction{compConf}, opts_{parseOpts (compConf)}, mars2grib_{mapOpts (opts_)} {}
48+ ChainedAction{compConf}, opts_{parseConfig<EncodeMtg2Options> (compConf)}, mars2grib_{mapOpts (opts_)} {}
6349
6450
6551void EncodeMtg2::executeImpl (Message msg) {
Original file line number Diff line number Diff line change 2020
2121namespace multio ::action::scale {
2222
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-
3523const std::vector<ScaleMappingConfig> getPresetMappings (const Preset& preset) {
3624 // Load the mapping file
3725 eckit::LocalConfiguration mappingConf{eckit::YAMLConfiguration{eckit::PathName{
@@ -71,7 +59,7 @@ Mappings getMappings(const ScaleConfig& config) {
7159}
7260
7361Scale::Scale (const ComponentConfiguration& compConf) :
74- ChainedAction (compConf), mappings_{getMappings (parseConfig (compConf))} {}
62+ ChainedAction (compConf), mappings_{getMappings (parseConfig<ScaleConfig> (compConf))} {}
7563
7664void Scale::executeImpl (message::Message msg) {
7765 // Skip non-field messages
You can’t perform that action at this time.
0 commit comments