libdballe  7.7
db/postgresql/levtr.h
1 /*
2  * db/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_POSTGRESQL_LEV_TR_H
23 #define DBALLE_DB_POSTGRESQL_LEV_TR_H
24 
25 #include <dballe/db/db.h>
26 #include <dballe/db/sql/levtr.h>
27 #include <dballe/db/postgresql/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 postgresql {
44 struct DB;
45 
50 {
51 protected:
56 
57  DBRow working_row;
58 
59 public:
61  PostgreSQLLevTrV6(const LevTr&) = delete;
62  PostgreSQLLevTrV6(const LevTr&&) = delete;
63  PostgreSQLLevTrV6& operator=(const PostgreSQLLevTrV6&) = delete;
65 
70  int obtain_id(const Level& lev, const Trange& tr) override;
71 
72  const DBRow* read(int id) override;
73  void read_all(std::function<void(const DBRow&)> dest) override;
74 
78  void dump(FILE* out) override;
79 };
80 
81 
82 }
83 }
84 }
85 #endif
Definition: db/sql/levtr.h:48
void read_all(std::function< void(const DBRow &)> dest) override
Read the contents of the LevTr table.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:565
Precompiled queries to manipulate the lev_tr table.
Definition: db/postgresql/levtr.h:49
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
void dump(FILE *out) override
Dump the entire contents of the table to an output stream.
const DBRow * read(int id) override
Read the LevTr data for an id, returns nullptr if not found.
Vertical level or layer.
Definition: types.h:515
Functions used to connect to DB-All.e and insert, query and delete data.
PostgreSQLConnection & conn
DB connection.
Definition: db/postgresql/levtr.h:55
Database connection.
Definition: postgresql/internals.h:249
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...
Precompiled queries to manipulate the lev_tr table.
Definition: db/sql/levtr.h:46