1
+ /*
2
+ * (C) Copyright 2025- ECMWF.
3
+ *
4
+ * This software is licensed under the terms of the Apache Licence Version 2.0
5
+ * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6
+ *
7
+ * In applying this licence, ECMWF does not waive the privileges and immunities
8
+ * granted to it by virtue of its status as an intergovernmental organisation nor
9
+ * does it submit to any jurisdiction.
10
+ */
11
+ #pragma once
12
+
13
+ #include < string>
14
+ #include < vector>
15
+
16
+ #include " nwp_definitions.h"
17
+
18
+ namespace nwp_emulator {
19
+
20
+ /* *
21
+ * @class DataReader
22
+ * @brief Base class for handling different types of data sources for the emulator.
23
+ */
24
+ class DataReader {
25
+ protected:
26
+ std::string gridName_;
27
+ std::vector<std::string> params_;
28
+
29
+ int stepCountLimit_; // /< Limitation on the number of steps the emulator can run
30
+ int step_{0 }; // /< Number of model steps
31
+ int count_{0 }; // /< Number of messages for the current step
32
+ int index_{0 }; // /< Index of the considered message at the current step
33
+
34
+ public:
35
+ DataReader (int stepCountLimit) : stepCountLimit_(stepCountLimit) {}
36
+ virtual ~DataReader () = default ;
37
+
38
+ /* *
39
+ * @brief Provides the raw values for a single levelin the next message from the data source.
40
+ *
41
+ * Each of the inheriting readers will have a different way to generate raw model data for the provider,
42
+ * which can use the parameters to map the raw values to a specific field, levtype and level.
43
+ *
44
+ * @param[out] shortName The name of the parameter represented by the raw values for the caller use.
45
+ * @param[out] levtype The levtype of the parameter for the caller use.
46
+ * @param[out] level The level of the levtype for the caller use.
47
+ * @param[out] data The vector that contains the raw values for the field.
48
+ *
49
+ * @return true if the data generation is successful, false otherwise.
50
+ */
51
+ virtual bool nextMessage (std::string& shortName, std::string& levtype, std::string& level,
52
+ std::vector<FIELD_TYPE_REAL>& data) = 0;
53
+
54
+ // / Returns true when the reader has read model data for all the steps.
55
+ virtual bool done () = 0;
56
+
57
+ // / Getters
58
+ const std::string& getGridName () const { return gridName_; }
59
+ int getStep () const { return step_; }
60
+ const std::vector<std::string>& getParams () const { return params_; }
61
+ };
62
+ } // namespace nwp_emulator
0 commit comments