libdballe  7.7
db/odbc/station.h
1 /*
2  * db/station - station 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_STATION_H
23 #define DBALLE_DB_ODBC_STATION_H
24 
25 #include <dballe/db/sql/station.h>
26 #include <sqltypes.h>
27 #include <functional>
28 #include <memory>
29 
30 namespace wreport {
31 struct Var;
32 }
33 
34 namespace dballe {
35 namespace db {
36 struct ODBCConnection;
37 struct ODBCStatement;
38 struct Sequence;
39 
40 namespace odbc {
41 
46 {
47 protected:
52 
55 
68 
70  int id;
72  int lat;
74  int lon;
76  char ident[64];
78  SQLLEN ident_ind;
79 
86  void set_ident(const char* ident);
87 
94  void get_data(int id);
95 
99  void update();
100 
104  void remove();
105 
106  void impl_add_station_vars(const char* query, int id_station, Record& rec);
107 
108 public:
110  ~ODBCStationBase();
111  ODBCStationBase(const ODBCStationBase&) = delete;
112  ODBCStationBase(const ODBCStationBase&&) = delete;
113  ODBCStationBase& operator=(const ODBCStationBase&) = delete;
114 
123  int get_id(int lat, int lon, const char* ident=NULL) override;
124 
133  int obtain_id(int lat, int lon, const char* ident=NULL, bool* inserted=NULL) override;
134 
135  void get_station_vars(int id_station, int id_report, std::function<void(std::unique_ptr<wreport::Var>)> dest) override;
136  void add_station_vars(int id_station, Record& rec) override;
137 
141  void dump(FILE* out) override;
142 };
143 
144 
146 {
147 public:
149  void get_station_vars(int id_station, int id_report, std::function<void(std::unique_ptr<wreport::Var>)> dest) override;
150  void add_station_vars(int id_station, Record& rec) override;
151 };
152 
153 }
154 
155 }
156 }
157 #endif
ODBCStatement * sstm
Precompiled select data by station id query.
Definition: db/odbc/station.h:61
db::Sequence * seq_station
Station ID sequence, when the DB requires it.
Definition: db/odbc/station.h:54
int id
Station ID SQL parameter.
Definition: db/odbc/station.h:70
ODBCStatement * dstm
Precompiled delete query.
Definition: db/odbc/station.h:67
ODBC statement.
Definition: odbc/internals.h:170
ODBCStatement * ustm
Precompiled update query.
Definition: db/odbc/station.h:65
Precompiled queries to manipulate the station table.
Definition: db/odbc/station.h:45
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
ODBCConnection & conn
DB connection.
Definition: db/odbc/station.h:51
Definition: db/odbc/station.h:145
ODBCStatement * smstm
Precompiled select mobile station query.
Definition: db/odbc/station.h:59
Station table management used by the db module.
Definition: db/sql/station.h:46
SQLLEN ident_ind
Mobile station identifier indicator.
Definition: db/odbc/station.h:78
Definition: conversion.h:6
int lon
Station longitude SQL parameter.
Definition: db/odbc/station.h:74
int lat
Station latitude SQL parameter.
Definition: db/odbc/station.h:72
ODBC statement to read a sequence.
Definition: odbc/internals.h:247
ODBCStatement * sfstm
Precompiled select fixed station query.
Definition: db/odbc/station.h:57
Database connection.
Definition: odbc/internals.h:87
ODBCStatement * istm
Precompiled insert query.
Definition: db/odbc/station.h:63