libdballe  7.7
db/sqlite/levtr.h
1 /*
2  * db/v6/lev_tr - lev_tr table management
3  *
4  * Copyright (C) 2005--2014 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_SQLITE_LEVTRV6_H
23 #define DBALLE_DB_SQLITE_LEVTRV6_H
24 
25 #include <dballe/db/db.h>
26 #include <dballe/db/sql/levtr.h>
27 #include <dballe/db/sqlite/internals.h>
28 #include <cstdio>
29 #include <memory>
30 
31 namespace dballe {
32 struct Record;
33 struct Msg;
34 
35 namespace msg {
36 struct Context;
37 }
38 
39 namespace db {
40 struct Connection;
41 struct Statement;
42 
43 namespace sqlite {
44 struct DB;
45 
49 struct SQLiteLevTrV6 : public sql::LevTr
50 {
51 protected:
56 
58  SQLiteStatement* sstm = nullptr;
60  SQLiteStatement* sdstm = nullptr;
62  SQLiteStatement* istm = nullptr;
64  SQLiteStatement* dstm = nullptr;
65 
66  DBRow working_row;
67 
68 public:
70  SQLiteLevTrV6(const LevTr&) = delete;
71  SQLiteLevTrV6(const LevTr&&) = delete;
72  SQLiteLevTrV6& operator=(const SQLiteLevTrV6&) = delete;
73  ~SQLiteLevTrV6();
74 
79  int obtain_id(const Level& lev, const Trange& tr) override;
80 
81  const DBRow* read(int id) override;
82  void read_all(std::function<void(const DBRow&)> dest) override;
83 
87  void dump(FILE* out) override;
88 };
89 
90 
91 }
92 }
93 }
94 #endif
95 
SQLiteStatement * dstm
Precompiled delete statement.
Definition: db/sqlite/levtr.h:64
void dump(FILE *out) override
Dump the entire contents of the table to an output stream.
SQLite statement.
Definition: sqlite/internals.h:124
const DBRow * read(int id) override
Read the LevTr data for an id, returns nullptr if not found.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:565
Database connection.
Definition: sqlite/internals.h:56
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
Vertical level or layer.
Definition: types.h:515
Functions used to connect to DB-All.e and insert, query and delete data.
SQLiteConnection & conn
DB connection.
Definition: db/sqlite/levtr.h:55
int obtain_id(const Level &lev, const Trange &tr) override
Return the ID for the given Level and Trange, adding it to the database if it does not already exist...
SQLiteStatement * sdstm
Precompiled select data statement.
Definition: db/sqlite/levtr.h:60
SQLiteStatement * istm
Precompiled insert statement.
Definition: db/sqlite/levtr.h:62
Precompiled queries to manipulate the lev_tr table.
Definition: db/sql/levtr.h:46
Precompiled queries to manipulate the lev_tr table.
Definition: db/sqlite/levtr.h:49
SQLiteStatement * sstm
Precompiled select statement.
Definition: db/sqlite/levtr.h:58