libdballe  7.7
sql/driver.h
Go to the documentation of this file.
1 /*
2  * db/sql/driver - db-independent functions
3  *
4  * Copyright (C) 2005--2015 ARPA-SIM <urpsim@smr.arpa.emr.it>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef DBALLE_DB_SQL_DRIVER_H
23 #define DBALLE_DB_SQL_DRIVER_H
24 
31 #include <dballe/core/defs.h>
32 #include <dballe/db/defs.h>
33 #include <wreport/var.h>
34 #include <memory>
35 #include <functional>
36 #include <vector>
37 #include <cstdio>
38 
39 namespace dballe {
40 namespace db {
41 struct Connection;
42 struct Transaction;
43 
44 namespace v6 {
45 struct QueryBuilder;
46 }
47 
48 namespace sql {
49 struct Repinfo;
50 struct Station;
51 struct LevTr;
52 struct DataV6;
53 struct AttrV6;
54 
57 {
58  int out_lat;
59  int out_lon;
60  char out_ident[64];
61  int out_ident_size; // -1 for NULL
62  wreport::Varcode out_varcode;
63  Datetime out_datetime;
64  Datetime out_datetimemax;
65  char out_value[255];
66  int out_rep_cod;
67  int out_ana_id;
68  int out_id_ltr;
69  int out_id_data;
70  int priority;
71 
78  bool querybest_fields_are_the_same(const SQLRecordV6& r);
79 
81  void dump(FILE* out);
82 };
83 
84 struct Driver
85 {
86 public:
87  virtual ~Driver();
88 
90  virtual void exec_no_data(const std::string& query) = 0;
91 
93  virtual std::unique_ptr<sql::Repinfo> create_repinfov6() = 0;
94 
96  virtual std::unique_ptr<sql::Station> create_stationv6() = 0;
97 
99  virtual std::unique_ptr<sql::LevTr> create_levtrv6() = 0;
100 
102  virtual std::unique_ptr<sql::DataV6> create_datav6() = 0;
103 
105  virtual std::unique_ptr<sql::AttrV6> create_attrv6() = 0;
106 
115  virtual void run_built_query_v6(const v6::QueryBuilder& qb, std::function<void(SQLRecordV6& rec)> dest) = 0;
116 
118  void create_tables(db::Format format);
119 
121  virtual void create_tables_v6() = 0;
122 
124  void delete_tables(db::Format format);
125 
127  virtual void delete_tables_v6() = 0;
128 
130  void remove_all(db::Format format);
131 
133  virtual void remove_all_v6();
134 
136  virtual void vacuum_v6() = 0;
137 
139  virtual void explain(const std::string& query);
140 
142  static std::unique_ptr<Driver> create(Connection& conn);
143 };
144 
145 }
146 }
147 }
148 #endif
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
Query results from SQL output.
Definition: sql/driver.h:56
Definition: sql/driver.h:84
Date and time.
Definition: types.h:147
Build SQL queries for V6 databases.
Definition: qbuilder.h:15
Common definitions.
Definition: sql.h:69