libdballe  7.19
mysql/data.h
1 #ifndef DBALLE_DB_V7_MYSQL_DATA_H
2 #define DBALLE_DB_V7_MYSQL_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 mysql {
13 struct DB;
14 
15 template<typename Traits>
16 class MySQLDataCommon : public DataCommon<Traits>
17 {
18 protected:
21 
22 #if 0
23  dballe::sql::MySQLStatement* read_attrs_stm = nullptr;
26  dballe::sql::MySQLStatement* write_attrs_stm = nullptr;
28  dballe::sql::MySQLStatement* remove_attrs_stm = nullptr;
30  dballe::sql::MySQLStatement* sstm = nullptr;
32  dballe::sql::MySQLStatement* istm = nullptr;
34  dballe::sql::MySQLStatement* ustm = nullptr;
35 #endif
36 
37 public:
39  MySQLDataCommon(const MySQLDataCommon&) = delete;
40  MySQLDataCommon(const MySQLDataCommon&&) = delete;
41  MySQLDataCommon& operator=(const MySQLDataCommon&) = delete;
42  ~MySQLDataCommon();
43 
44  void read_attrs(int id_data, std::function<void(std::unique_ptr<wreport::Var>)> dest) override;
45  void write_attrs(int id_data, const Values& values) override;
46  void remove_all_attrs(int id_data) override;
47  void remove(const v7::IdQueryBuilder& qb) override;
48 };
49 
50 extern template class MySQLDataCommon<StationDataTraits>;
51 extern template class MySQLDataCommon<DataTraits>;
52 
57 {
58 public:
59  using MySQLDataCommon::MySQLDataCommon;
60 
62  void insert(dballe::db::v7::Transaction& t, v7::bulk::InsertStationVars& vars, bulk::UpdateMode update_mode=bulk::UPDATE, bool with_attrs=false) override;
63  void dump(FILE* out) override;
64 };
65 
70 {
71 public:
72  using MySQLDataCommon::MySQLDataCommon;
73 
75  void insert(dballe::db::v7::Transaction& t, v7::bulk::InsertVars& vars, bulk::UpdateMode update_mode=bulk::UPDATE, bool with_attrs=false) override;
76  void dump(FILE* out) override;
77 };
78 
79 }
80 }
81 }
82 }
83 #endif
virtual void dump(FILE *out)=0
Dump the entire contents of the table to an output stream.
Definition: v7/qbuilder.h:115
Definition: mysql/data.h:16
Definition: data.h:36
Forward declarations for public dballe/sql names.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
void write_attrs(int id_data, const Values &values) override
Replace the attributes of a variable with those in Values.
Precompiled query to manipulate the station data table.
Definition: mysql/data.h:56
Input for a bulk insert of a lot of variables sharing the same context information.
Definition: data.h:275
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.
Definition: db/v7/transaction.h:12
void remove_all_attrs(int id_data) override
Remove all attributes from a variable.
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::MySQLConnection & conn
DB connection.
Definition: mysql/data.h:20
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: mysql.h:125
Precompiled query to manipulate the data table.
Definition: mysql/data.h:69