libdballe  7.21
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/sql/fwd.h>
6 
7 namespace dballe {
8 struct Record;
9 
10 namespace db {
11 namespace v7 {
12 namespace sqlite {
13 struct DB;
14 
15 template<typename Traits>
16 class SQLiteDataCommon : public DataCommon<Traits>
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 read_attrs(int id_data, std::function<void(std::unique_ptr<wreport::Var>)> dest) override;
43  void write_attrs(int id_data, const Values& values) override;
44  void remove_all_attrs(int id_data) override;
45  void remove(const v7::IdQueryBuilder& qb) override;
46 };
47 
48 extern template class SQLiteDataCommon<StationDataTraits>;
49 extern template class SQLiteDataCommon<DataTraits>;
50 
55 {
56 public:
57  using SQLiteDataCommon::SQLiteDataCommon;
58 
60  void insert(dballe::db::v7::Transaction& t, v7::bulk::InsertStationVars& vars, bulk::UpdateMode update_mode=bulk::UPDATE, bool with_attrs=false) override;
61  void dump(FILE* out) override;
62 };
63 
68 {
69 public:
70  using SQLiteDataCommon::SQLiteDataCommon;
71 
73  void insert(dballe::db::v7::Transaction& t, v7::bulk::InsertVars& vars, bulk::UpdateMode update_mode=bulk::UPDATE, bool with_attrs=false) override;
74  void dump(FILE* out) override;
75 };
76 
77 }
78 }
79 }
80 }
81 #endif
Precompiled query to manipulate the data table.
Definition: sqlite/data.h:67
void write_attrs(int id_data, const Values &values) override
Replace the attributes of a variable with those in Values.
void read_attrs(int id_data, std::function< void(std::unique_ptr< wreport::Var >)> dest) override
Load from the database all the attributes for var.
virtual void dump(FILE *out)=0
Dump the entire contents of the table to an output stream.
dballe::sql::SQLiteStatement * write_attrs_stm
Precompiled write attributes statement.
Definition: sqlite/data.h:25
Definition: v7/qbuilder.h:115
dballe::sql::SQLiteStatement * sstm
Precompiled select statement.
Definition: sqlite/data.h:29
Definition: data.h:36
Definition: sqlite/data.h:16
Forward declarations for public dballe/sql names.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
dballe::sql::SQLiteConnection & conn
DB connection.
Definition: sqlite/data.h:20
Input for a bulk insert of a lot of variables sharing the same context information.
Definition: data.h:275
dballe::sql::SQLiteStatement * istm
Precompiled insert statement.
Definition: sqlite/data.h:31
dballe::sql::SQLiteStatement * remove_attrs_stm
Precompiled remove attributes statement.
Definition: sqlite/data.h:27
Definition: db/v7/transaction.h:12
virtual void insert(dballe::db::v7::Transaction &t, typename Traits::BulkVars &vars, bulk::UpdateMode update_mode=bulk::UPDATE, bool with_attrs=false)=0
Bulk variable insert.
dballe::sql::SQLiteStatement * ustm
Precompiled update statement.
Definition: sqlite/data.h:33
void remove_all_attrs(int id_data) override
Remove all attributes from a variable.
SQLite statement.
Definition: sqlite.h:88
dballe::sql::SQLiteStatement * read_attrs_stm
Precompiled read attributes statement.
Definition: sqlite/data.h:23
Precompiled query to manipulate the station data table.
Definition: sqlite/data.h:54
Input for a bulk insert of a lot of variables sharing the same context information.
Definition: data.h:297
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:202
Database connection.
Definition: sqlite.h:33