1 #ifndef DBA_DB_V7_CURSOR_H 2 #define DBA_DB_V7_CURSOR_H 5 #include <dballe/db/v7/levtr.h> 7 #include <dballe/db/v7/transaction.h> 29 mutable std::unique_ptr<DBValues> values;
33 void dump(FILE* out)
const;
42 std::unique_ptr<wreport::Var> var)
43 : station(station), value(id_data, std::move(var))
52 void dump(FILE* out)
const;
60 using StationDataRow::StationDataRow;
63 const Datetime& datetime,
int id_data,
64 std::unique_ptr<wreport::Var> var)
65 :
StationDataRow(station, id_data, std::move(var)), id_levtr(id_levtr),
70 void dump(FILE* out)
const;
77 wreport::Varcode code;
84 : station(station), id_levtr(id_levtr), code(code), dtrange(dtrange),
89 void dump(FILE* out)
const;
134 std::shared_ptr<v7::Transaction>
tr;
142 Base(std::shared_ptr<v7::Transaction>
tr) :
tr(
tr) {}
146 int remaining()
const override;
147 bool has_value()
const override {
return !
at_start && !
results.empty(); }
157 void discard()
override 173 inline static std::shared_ptr<Impl> downcast(std::shared_ptr<Interface> c)
175 auto res = std::dynamic_pointer_cast<Impl>(c);
177 throw std::runtime_error(
178 "Attempted to downcast the wrong kind of cursor");
182 const Row& row()
const {
return results.front(); }
185 int get_priority()
const 187 return tr->repinfo().get_priority(
results.front().station.report);
191 extern template class Base<Stations>;
192 extern template class Base<StationData>;
193 extern template class Base<Data>;
194 extern template class Base<Summary>;
200 DBValues get_values()
const override;
202 void remove()
override;
209 friend std::shared_ptr<dballe::CursorStation>
210 run_station_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
217 bool with_attributes;
220 std::shared_ptr<dballe::db::Transaction> get_transaction()
const override 224 wreport::Varcode get_varcode()
const override {
return row().value.code(); }
225 wreport::Var get_var()
const override {
return *row().value; }
226 int attr_reference_id()
const override {
return row().value.data_id; }
227 void query_attrs(std::function<
void(std::unique_ptr<wreport::Var>)> dest,
228 bool force_read)
override;
229 void remove()
override;
235 friend std::shared_ptr<dballe::CursorStationData>
236 run_station_data_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
248 if (levtr ==
nullptr)
252 this->tr->levtr().lookup_cache(this->results.front().id_levtr));
265 void discard()
override 281 const Datetime& datetime,
int id_data,
282 std::unique_ptr<wreport::Var> var);
286 const Datetime& datetime,
int id_data,
287 std::unique_ptr<wreport::Var> var);
294 bool with_attributes;
298 std::shared_ptr<dballe::db::Transaction> get_transaction()
const override 303 Datetime get_datetime()
const override {
return row().datetime; }
304 wreport::Varcode get_varcode()
const override {
return row().value.code(); }
305 wreport::Var get_var()
const override {
return *row().value; }
306 int attr_reference_id()
const override {
return row().value.data_id; }
307 Level get_level()
const override {
return get_levtr().level; }
308 Trange get_trange()
const override {
return get_levtr().trange; }
310 void query_attrs(std::function<
void(std::unique_ptr<wreport::Var>)> dest,
311 bool force_read)
override;
312 void remove()
override;
316 friend std::shared_ptr<dballe::CursorData>
317 run_data_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
326 DatetimeRange get_datetimerange()
const override {
return row().dtrange; }
327 Level get_level()
const override {
return get_levtr().level; }
328 Trange get_trange()
const override {
return get_levtr().trange; }
329 wreport::Varcode get_varcode()
const override {
return row().code; }
330 size_t get_count()
const override {
return row().count; }
331 void remove()
override;
337 friend std::shared_ptr<dballe::CursorSummary>
338 run_summary_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
342 std::shared_ptr<dballe::CursorStation>
343 run_station_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
345 std::shared_ptr<dballe::CursorStationData>
346 run_station_data_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
348 std::shared_ptr<dballe::CursorData>
349 run_data_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
351 std::shared_ptr<dballe::CursorSummary>
352 run_summary_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
354 void run_delete_query(
Tracer<>& trc, std::shared_ptr<v7::Transaction> tr,
Row resulting from a station query.
Definition: db/v7/cursor.h:26
Definition: qbuilder.h:82
CursorStation implementation.
Definition: db/v7/cursor.h:197
CursorStationData implementation.
Definition: db/v7/cursor.h:215
Definition: qbuilder.h:134
Common base types used by most of DB-All.e code.
Class passed to key-value accessors to set values in an invoker-defined way.
Definition: core/enq.h:17
CursorSummary implementation.
Definition: db/v7/cursor.h:322
unsigned test_iterate(FILE *dump=0) override
Iterate the cursor until the end, returning the number of items.
bool at_start
True if we are at the start of the iteration.
Definition: db/v7/cursor.h:140
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:688
Functions used to connect to DB-All.e and insert, query and delete data.
Cursor iterating over summary entries.
Definition: cursor.h:98
Standard dballe::Query implementation.
Definition: core/query.h:35
Cursor iterating over data values.
Definition: cursor.h:78
CursorData implementation.
Definition: db/v7/cursor.h:273
Definition: db/v7/cursor.h:92
Collection of DBValue objects, indexed by wreport::Varcode.
Definition: values.h:229
Definition: db/v7/cursor.h:240
Definition: db/v7/cursor.h:36
Vertical level or layer.
Definition: types.h:624
Range of datetimes.
Definition: types.h:296
Structure used to build and execute a query, and to iterate through the results.
Definition: db/v7/cursor.h:128
Definition: db/v7/cursor.h:55
Definition: db/v7/cursor.h:73
std::deque< Row > results
Storage for the raw database results.
Definition: db/v7/cursor.h:137
Smart pointer for trace::Step objects, which calls done() when going out of scope.
Definition: db/v7/fwd.h:44
Cursor iterating over station data values.
Definition: cursor.h:67
Date and time.
Definition: types.h:163
std::shared_ptr< v7::Transaction > tr
Database to operate on.
Definition: db/v7/cursor.h:134
Cursor iterating over stations.
Definition: cursor.h:57
Structures used as input to database insert functions.
Repinfo table management used by the db module.
Container for a wreport::Var pointer, and its database ID.
Definition: value.h:70
Definition: qbuilder.h:95