libdballe  7.7
db/odbc/levtr.h
Go to the documentation of this file.
1 /*
2  * db/odbc/lev_tr - lev_tr table management
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_ODBC_LEV_TR_H
23 #define DBALLE_DB_ODBC_LEV_TR_H
24 
31 #include <dballe/db/db.h>
32 #include <dballe/db/sql/levtr.h>
34 #include <cstdio>
35 #include <memory>
36 
37 namespace dballe {
38 struct Record;
39 struct Msg;
40 
41 namespace msg {
42 struct Context;
43 }
44 
45 namespace db {
46 struct Connection;
47 struct Statement;
48 
49 namespace odbc {
50 struct DB;
51 
55 struct ODBCLevTrV6 : public sql::LevTr
56 {
57 protected:
62 
65 
67  ODBCStatement* sstm = nullptr;
69  ODBCStatement* sdstm = nullptr;
71  ODBCStatement* istm = nullptr;
73  ODBCStatement* dstm = nullptr;
74 
75  DBRow working_row;
76 
83  int insert();
84 
91  int get_id();
92 
96  void remove();
97 
98 public:
100  ODBCLevTrV6(const LevTr&) = delete;
101  ODBCLevTrV6(const LevTr&&) = delete;
102  ODBCLevTrV6& operator=(const ODBCLevTrV6&) = delete;
103  ~ODBCLevTrV6();
104 
109  int obtain_id(const Level& lev, const Trange& tr) override;
110 
111  const DBRow* read(int id) override;
112  void read_all(std::function<void(const DBRow&)> dest) override;
113 
117  void dump(FILE* out) override;
118 };
119 
120 
121 }
122 }
123 }
124 #endif
125 
Precompiled queries to manipulate the lev_tr table.
Definition: db/odbc/levtr.h:55
int get_id()
Get the lev_tr id for the current lev_tr data.
ODBC statement.
Definition: odbc/internals.h:170
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
ODBCStatement * sstm
Precompiled select statement.
Definition: db/odbc/levtr.h:67
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
ODBCStatement * istm
Precompiled insert statement.
Definition: db/odbc/levtr.h:71
Vertical level or layer.
Definition: types.h:515
Functions used to connect to DB-All.e and insert, query and delete data.
db::Sequence * seq_lev_tr
lev_tr ID sequence, for databases that need it
Definition: db/odbc/levtr.h:64
ODBCStatement * sdstm
Precompiled select data statement.
Definition: db/odbc/levtr.h:69
int insert()
Insert a new lev_tr in the database.
ODBCStatement * dstm
Precompiled delete statement.
Definition: db/odbc/levtr.h:73
void dump(FILE *out) override
Dump the entire contents of the table to an output stream.
ODBC statement to read a sequence.
Definition: odbc/internals.h:247
ODBCConnection & conn
DB connection.
Definition: db/odbc/levtr.h:61
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...
Database functions and data structures used by the db module, but not exported as official API...
Precompiled queries to manipulate the lev_tr table.
Definition: db/sql/levtr.h:46
Database connection.
Definition: odbc/internals.h:87