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;
56 void enq(
Enq& enq)
const override;
66 inline static std::unique_ptr<CursorStation>
downcast(std::unique_ptr<dballe::CursorStation> c)
69 if (!res)
throw std::runtime_error(
"Attempted to downcast the wrong kind of cursor");
71 return std::unique_ptr<CursorStation>(res);
79 const Values& station_values;
81 Values::const_iterator cur;
94 return !at_start && cur != station_values.end();
100 return station_values.size();
101 return station_values.end() - cur;
109 cur = station_values.begin();
112 else if (cur == station_values.end())
117 return cur != station_values.end();
124 cur = station_values.end();
127 void enq(
Enq& enq)
const override;
135 inline static std::unique_ptr<CursorStationData>
downcast(std::unique_ptr<dballe::CursorStationData> c)
138 if (!res)
throw std::runtime_error(
"Attempted to downcast the wrong kind of cursor");
140 return std::unique_ptr<CursorStationData>(res);
149 Values::const_iterator var;
157 : level(level), trange(trange), var(var)
166 std::vector<CursorDataRow> rows;
167 std::vector<CursorDataRow>::const_iterator cur;
168 bool at_start =
true;
177 for (
const auto& ctx: msg.data)
178 for (Values::const_iterator cur = ctx.values.begin(); cur != ctx.values.end(); ++cur)
179 rows.emplace_back(ctx.level, ctx.trange, cur);
182 for (Values::const_iterator cur = msg.station_data.begin(); cur != msg.station_data.end(); ++cur)
184 rows.emplace_back(cur);
190 return !at_start && cur != rows.end();
197 return rows.end() - cur;
208 else if (cur == rows.end())
215 return cur != rows.end();
225 void enq(
Enq& enq)
const override;
236 inline static std::unique_ptr<CursorData>
downcast(std::unique_ptr<dballe::CursorData> c)
238 CursorData* res = dynamic_cast<CursorData*>(c.get());
239 if (!res)
throw std::runtime_error(
"Attempted to downcast the wrong kind of cursor");
241 return std::unique_ptr<CursorData>(res);
bool next() override
Get a new item from the results of a query.
Definition: msg/cursor.h:104
wreport::Varcode get_varcode() const override
Get the variable code.
Definition: msg/cursor.h:229
static std::unique_ptr< CursorStation > downcast(std::unique_ptr< dballe::CursorStation > c)
Downcast a unique_ptr pointer.
Definition: msg/cursor.h:66
int remaining() const override
Get the number of rows still to be fetched.
Definition: msg/cursor.h:193
Definition: msg/cursor.h:162
wreport::Varcode get_varcode() const override
Get the variable code.
Definition: msg/cursor.h:131
Class passed to key-value accessors to set values in an invoker-defined way.
Definition: core/enq.h:17
Level get_level() const override
Get the level.
Definition: msg/cursor.h:231
Cursor iterating over stations.
Definition: core/cursor.h:12
DBStation get_station() const override
Get the whole station data in a single call.
Definition: msg/cursor.h:58
bool has_value() const override
Check if the cursor points to a valid value.
Definition: msg/cursor.h:92
bool has_value() const override
Check if the cursor points to a valid value.
Definition: msg/cursor.h:188
wreport::Var get_var() const override
Get the variable.
Definition: msg/cursor.h:132
bool next() override
Get a new item from the results of a query.
Definition: msg/cursor.h:200
static std::unique_ptr< CursorData > downcast(std::unique_ptr< dballe::CursorData > c)
Downcast a unique_ptr pointer.
Definition: msg/cursor.h:236
DBStation get_station() const override
Get the whole station data in a single call.
Definition: msg/cursor.h:227
Definition: msg/cursor.h:13
const Values & find_station_context() const
Find the station info context.
Coords get_coords() const override
Get the reference coordinates for this message.
Collection of DBValue objects, indexed by wreport::Varcode.
Definition: values.h:191
wreport::Var get_var() const override
Get the variable.
Definition: msg/cursor.h:230
Ident get_ident() const override
Get the station identifier for this message.
bool next() override
Get a new item from the results of a query.
Definition: msg/cursor.h:40
std::string get_report() const override
Get the report for this message.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:686
Definition: msg/cursor.h:76
static std::unique_ptr< CursorStationData > downcast(std::unique_ptr< dballe::CursorStationData > c)
Downcast a unique_ptr pointer.
Definition: msg/cursor.h:135
Vertical level or layer.
Definition: types.h:624
void discard() override
Discard the results that have not been read yet.
Definition: msg/cursor.h:121
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:176
void discard() override
Discard the results that have not been read yet.
Definition: msg/cursor.h:51
Trange get_trange() const override
Get the time range.
Definition: msg/cursor.h:232
DBStation get_station() const override
Get the whole station data in a single call.
Definition: msg/cursor.h:129
DBValues get_values() const override
Get the station data values.
Definition: msg/cursor.h:60
Date and time.
Definition: types.h:164
bool has_value() const override
Check if the cursor points to a valid value.
Definition: msg/cursor.h:28
Cursor iterating over station data values.
Definition: core/cursor.h:27
Cursor iterating over data values.
Definition: core/cursor.h:42
Definition: msg/cursor.h:145
Datetime get_datetime() const override
Get the datetime.
Definition: msg/cursor.h:233
void discard() override
Discard the results that have not been read yet.
Definition: msg/cursor.h:219
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:33
Datetime get_datetime() const override
Get the reference Datetime for this message.
int remaining() const override
Get the number of rows still to be fetched.
Definition: msg/cursor.h:97