1 #ifndef DBALLE_MSG_CURSOR_H 2 #define DBALLE_MSG_CURSOR_H 4 #include <dballe/core/cursor.h> 6 #include <dballe/msg/msg.h> 16 const Values& station_values;
51 void enq(
Enq& enq)
const override;
61 inline static std::unique_ptr<CursorStation>
downcast(std::unique_ptr<dballe::CursorStation> c)
64 if (!res)
throw std::runtime_error(
"Attempted to downcast the wrong kind of cursor");
66 return std::unique_ptr<CursorStation>(res);
74 const Values& station_values;
76 Values::const_iterator cur;
90 return station_values.size();
91 return station_values.end() - cur;
99 cur = station_values.begin();
102 else if (cur == station_values.end())
107 return cur != station_values.end();
114 cur = station_values.end();
117 void enq(
Enq& enq)
const override;
125 inline static std::unique_ptr<CursorStationData>
downcast(std::unique_ptr<dballe::CursorStationData> c)
128 if (!res)
throw std::runtime_error(
"Attempted to downcast the wrong kind of cursor");
130 return std::unique_ptr<CursorStationData>(res);
139 Values::const_iterator var;
147 : level(level), trange(trange), var(var)
156 std::vector<CursorDataRow> rows;
157 std::vector<CursorDataRow>::const_iterator cur;
158 bool at_start =
true;
167 for (
const auto& ctx: msg.data)
168 for (Values::const_iterator cur = ctx.values.begin(); cur != ctx.values.end(); ++cur)
169 rows.emplace_back(ctx.level, ctx.trange, cur);
172 for (Values::const_iterator cur = msg.station_data.begin(); cur != msg.station_data.end(); ++cur)
174 rows.emplace_back(cur);
182 return rows.end() - cur;
193 else if (cur == rows.end())
200 return cur != rows.end();
210 void enq(
Enq& enq)
const override;
221 inline static std::unique_ptr<CursorData>
downcast(std::unique_ptr<dballe::CursorData> c)
224 if (!res)
throw std::runtime_error(
"Attempted to downcast the wrong kind of cursor");
226 return std::unique_ptr<CursorData>(res);
Datetime get_datetime() const override
Get the datetime.
Definition: msg/cursor.h:218
Definition: msg/cursor.h:152
int remaining() const override
Get the number of rows still to be fetched.
Definition: msg/cursor.h:87
Common base types used by most of DB-All.e code.
Ident ident
Mobile station identifier.
Definition: types.h:799
Class passed to key-value accessors to set values in an invoker-defined way.
Definition: core/enq.h:17
Sorted storage for all the dba_msg_datum present on one level.
DBStation get_station() const override
Get the whole station data in a single call.
Definition: msg/cursor.h:119
Definition: msg/cursor.h:13
Coords coords
Station coordinates.
Definition: types.h:796
DBValues get_values() const override
Get the station data values.
Definition: msg/cursor.h:55
Cursor iterating over station data values.
Definition: core/cursor.h:27
DBStation get_station() const override
Get the whole station data in a single call.
Definition: msg/cursor.h:53
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:683
std::string get_report() const override
Get the report for this message.
bool next() override
Get a new item from the results of a query.
Definition: msg/cursor.h:185
Collection of DBValue objects, indexed by wreport::Varcode.
Definition: values.h:191
const Values & find_station_context() const
Find the station info context.
Level get_level() const override
Get the level.
Definition: msg/cursor.h:216
Vertical level or layer.
Definition: types.h:621
wreport::Varcode get_varcode() const override
Get the variable code.
Definition: msg/cursor.h:214
wreport::Var get_var() const override
Get the variable.
Definition: msg/cursor.h:215
wreport::Varcode get_varcode() const override
Get the variable code.
Definition: msg/cursor.h:121
std::string report
Report name for this station.
Definition: types.h:793
Coords get_coords() const override
Get the reference coordinates for this message.
Definition: msg/cursor.h:71
bool next() override
Get a new item from the results of a query.
Definition: msg/cursor.h:94
DBStation get_station() const override
Get the whole station data in a single call.
Definition: msg/cursor.h:212
bool next() override
Get a new item from the results of a query.
Definition: msg/cursor.h:35
void discard() override
Discard the results that have not been read yet.
Definition: msg/cursor.h:111
Cursor iterating over stations.
Definition: core/cursor.h:12
static std::unique_ptr< CursorStation > downcast(std::unique_ptr< dballe::CursorStation > c)
Downcast a unique_ptr pointer.
Definition: msg/cursor.h:61
Date and time.
Definition: types.h:164
Cursor iterating over data values.
Definition: core/cursor.h:42
int remaining() const override
Get the number of rows still to be fetched.
Definition: msg/cursor.h:28
Trange get_trange() const override
Get the time range.
Definition: msg/cursor.h:217
wreport::Var get_var() const override
Get the variable.
Definition: msg/cursor.h:122
Datetime get_datetime() const override
Get the reference Datetime for this message.
Storage for related physical data.
Definition: msg.h:130
int remaining() const override
Get the number of rows still to be fetched.
Definition: msg/cursor.h:178
void discard() override
Discard the results that have not been read yet.
Definition: msg/cursor.h:204
static std::unique_ptr< CursorData > downcast(std::unique_ptr< dballe::CursorData > c)
Downcast a unique_ptr pointer.
Definition: msg/cursor.h:221
void discard() override
Discard the results that have not been read yet.
Definition: msg/cursor.h:46
static std::unique_ptr< CursorStationData > downcast(std::unique_ptr< dballe::CursorStationData > c)
Downcast a unique_ptr pointer.
Definition: msg/cursor.h:125
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:176
Ident get_ident() const override
Get the station identifier for this message.
Definition: msg/cursor.h:135