1#ifndef DBALLE_DB_V7_BATCH_H
2#define DBALLE_DB_V7_BATCH_H
4#include <wreport/var.h>
6#include <dballe/core/smallset.h>
7#include <dballe/db/v7/fwd.h>
8#include <dballe/db/v7/utils.h>
21 bool write_attrs =
true;
24 bool have_station(
const std::string& report,
const Coords& coords,
const Ident& ident);
25 void new_station(
Tracer<>& trc,
const std::string& report,
const Coords& coords,
const Ident& ident);
29 unsigned count_select_stations = 0;
30 unsigned count_select_station_data = 0;
31 unsigned count_select_data = 0;
33 Batch(
Transaction& transaction) : transaction(transaction) {}
36 void set_write_attrs(
bool write_attrs);
43 void dump(FILE* out)
const;
65 void dump(FILE* out)
const;
66 bool operator<(
const StationDatum& o)
const {
return var->code() < o.var->
code(); }
67 bool operator==(
const StationDatum& o)
const {
return var->code() == o.var->
code(); }
79 std::vector<StationDatum> to_insert;
80 std::vector<StationDatum> to_update;
83 void add(
const wreport::Var* var, UpdateMode on_conflict);
94 : id_levtr(id_levtr), var(var) {}
95 MeasuredDatum(
int id,
int id_levtr,
const wreport::Var* var)
96 : id(
id), id_levtr(id_levtr), var(var) {}
98 void dump(FILE* out)
const;
99 bool operator<(
const MeasuredDatum& o)
const {
return id_levtr < o.id_levtr || (id_levtr == o.id_levtr && var->code() < o.var->
code()); }
100 bool operator==(
const MeasuredDatum& o)
const {
return id_levtr == o.id_levtr && var->code() == o.var->
code(); }
108 MeasuredDataID(
IdVarcode id_varcode,
int id)
109 : id_varcode(id_varcode), id(
id)
124 std::vector<MeasuredDatum> to_insert;
125 std::vector<MeasuredDatum> to_update;
132 void add(
int id_levtr,
const wreport::Var* var, UpdateMode on_conflict);
136inline const Datetime& measured_data_vector_get_value(
MeasuredData*
const& item) {
return item->datetime; }
138struct MeasuredDataVector :
public core::SmallSet<MeasuredData*, Datetime, measured_data_vector_get_value>
140 MeasuredDataVector() {}
141 MeasuredDataVector(
const MeasuredDataVector&) =
delete;
142 MeasuredDataVector(MeasuredDataVector&&) =
default;
143 ~MeasuredDataVector();
144 MeasuredDataVector& operator=(
const MeasuredDataVector&) =
delete;
145 MeasuredDataVector& operator=(MeasuredDataVector&&) =
default;
155 Station(
Batch& batch)
161 void write_pending(
Tracer<>& trc,
bool with_attrs);
162 void dump(FILE* out)
const;
A station identifier, that can be any string (including the empty string) or a missing value.
Definition types.h:748
Smart pointer for trace::Step objects, which calls done() when going out of scope.
Definition db/v7/fwd.h:46
Coordinates.
Definition types.h:369
Date and time.
Definition types.h:165
Set structure optimized for a small number of items.
Definition smallset.h:17
Definition transaction.h:16
Common base types used by most of DB-All.e code.