libdballe  8.6
db/v7/sqlite/data.h
1 #ifndef DBALLE_DB_V7_SQLITE_DATA_H
2 #define DBALLE_DB_V7_SQLITE_DATA_H
3 
4 #include <dballe/db/v7/data.h>
5 #include <dballe/db/v7/cache.h>
6 #include <dballe/sql/fwd.h>
7 
8 namespace dballe {
9 namespace db {
10 namespace v7 {
11 namespace sqlite {
12 struct DB;
13 
14 // Partial implementation of the common parts of StationData and Data
15 template<typename Parent>
16 class SQLiteDataCommon : public Parent
17 {
18 protected:
21 
34 
35 public:
37  SQLiteDataCommon(const SQLiteDataCommon&) = delete;
38  SQLiteDataCommon(const SQLiteDataCommon&&) = delete;
39  SQLiteDataCommon& operator=(const SQLiteDataCommon&) = delete;
41 
42  void update(Tracer<>& trc, std::vector<typename Parent::BatchValue>& vars, bool with_attrs) override;
43  void read_attrs(Tracer<>& trc, int id_data, std::function<void(std::unique_ptr<wreport::Var>)> dest) override;
44  void write_attrs(Tracer<>& trc, int id_data, const Values& values) override;
45  void remove_all_attrs(Tracer<>& trc, int id_data) override;
46  void remove(Tracer<>& trc, const v7::IdQueryBuilder& qb) override;
47  void remove_by_id(Tracer<>& trc, int id) override;
48 };
49 
50 extern template class SQLiteDataCommon<StationData>;
51 extern template class SQLiteDataCommon<Data>;
52 
57 {
58 public:
59  using SQLiteDataCommon::SQLiteDataCommon;
60 
62 
63  void query(Tracer<>& trc, int id_station, std::function<void(int id, wreport::Varcode code)> dest) override;
64  void insert(Tracer<>& trc, int id_station, std::vector<batch::StationDatum>& vars, bool with_attrs) override;
65  void run_station_data_query(Tracer<>& trc, const v7::DataQueryBuilder& qb, std::function<void(const dballe::DBStation& station, int id_data, std::unique_ptr<wreport::Var> var)>) override;
66  void dump(FILE* out) override;
67  void clear_cache() override {}
68 };
69 
74 {
75 public:
76  using SQLiteDataCommon::SQLiteDataCommon;
77 
79 
80  void query(Tracer<>& trc, int id_station, const Datetime& datetime, std::function<void(int id, int id_levtr, wreport::Varcode code)> dest) override;
81  void insert(Tracer<>& trc, int id_station, const Datetime& datetime, std::vector<batch::MeasuredDatum>& vars, bool with_attrs) override;
82  void run_data_query(Tracer<>& trc, const v7::DataQueryBuilder& qb, std::function<void(const dballe::DBStation& station, int id_levtr, const Datetime& datetime, int id_data, std::unique_ptr<wreport::Var> var)>) override;
83  void run_summary_query(Tracer<>& trc, const v7::SummaryQueryBuilder& qb, std::function<void(const dballe::DBStation& station, int id_levtr, wreport::Varcode code, const DatetimeRange& datetime, size_t size)>) override;
84  void dump(FILE* out) override;
85  void clear_cache() override {}
86 };
87 
88 }
89 }
90 }
91 }
92 #endif
dballe::db::v7::sqlite::SQLiteDataCommon::conn
dballe::sql::SQLiteConnection & conn
DB connection.
Definition: db/v7/sqlite/data.h:20
dballe::db::v7::IdQueryBuilder
Definition: qbuilder.h:115
dballe::db::v7::SummaryQueryBuilder
Definition: qbuilder.h:124
dballe::db::v7::sqlite::SQLiteDataCommon::write_attrs_stm
dballe::sql::SQLiteStatement * write_attrs_stm
Precompiled write attributes statement.
Definition: db/v7/sqlite/data.h:25
dballe::db::v7::Tracer
Smart pointer for trace::Step objects, which calls done() when going out of scope.
Definition: db/v7/fwd.h:45
fwd.h
dballe::db::v7::sqlite::SQLiteDataCommon::read_attrs_stm
dballe::sql::SQLiteStatement * read_attrs_stm
Precompiled read attributes statement.
Definition: db/v7/sqlite/data.h:23
dballe::db::v7::sqlite::SQLiteDataCommon
Definition: db/v7/sqlite/data.h:16
dballe::db::v7::Transaction
Definition: transaction.h:15
dballe::DBStation
Definition: types.h:850
wreport::Varcode
uint16_t Varcode
dballe::DatetimeRange
Range of datetimes.
Definition: types.h:294
dballe::db::v7::sqlite::SQLiteStationData
Precompiled query to manipulate the station data table.
Definition: db/v7/sqlite/data.h:56
dballe::sql::SQLiteStatement
SQLite statement.
Definition: sqlite.h:98
dballe::Values
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:176
dballe::db::v7::sqlite::SQLiteDataCommon::remove_attrs_stm
dballe::sql::SQLiteStatement * remove_attrs_stm
Precompiled remove attributes statement.
Definition: db/v7/sqlite/data.h:27
dballe::db::v7::sqlite::SQLiteData
Precompiled query to manipulate the data table.
Definition: db/v7/sqlite/data.h:73
dballe::db::v7::sqlite::SQLiteDataCommon::istm
dballe::sql::SQLiteStatement * istm
Precompiled insert statement.
Definition: db/v7/sqlite/data.h:31
dballe::db::v7::sqlite::SQLiteDataCommon::ustm
dballe::sql::SQLiteStatement * ustm
Precompiled update statement.
Definition: db/v7/sqlite/data.h:33
dballe::Datetime
Date and time.
Definition: types.h:164
dballe::sql::SQLiteConnection
Database connection.
Definition: sqlite.h:34
dballe::db::v7::DataQueryBuilder
Definition: qbuilder.h:91
dballe::db::v7::sqlite::SQLiteDataCommon::sstm
dballe::sql::SQLiteStatement * sstm
Precompiled select statement.
Definition: db/v7/sqlite/data.h:29