libdballe  7.29
v6/sqlite/station.h
1 #ifndef DBALLE_DB_V6_SQLITE_STATION_H
2 #define DBALLE_DB_V6_SQLITE_STATION_H
3 
4 #include <dballe/db/v6/station.h>
5 #include <functional>
6 #include <memory>
7 
8 namespace wreport {
9 struct Var;
10 }
11 
12 namespace dballe {
13 namespace db {
14 namespace v6 {
15 namespace sqlite {
16 
21 {
22 protected:
27 
34 
36  bool maybe_get_id(int lat, int lon, const char* ident, int* id);
37 
39  void read_station_vars(dballe::sql::SQLiteStatement& stm, std::function<void(std::unique_ptr<wreport::Var>)> dest);
40 
41 public:
44  SQLiteStationBase(const SQLiteStationBase&) = delete;
45  SQLiteStationBase(const SQLiteStationBase&&) = delete;
46  SQLiteStationBase& operator=(const SQLiteStationBase&) = delete;
47 
56  int get_id(int lat, int lon, const char* ident=nullptr) override;
57 
66  int obtain_id(int lat, int lon, const char* ident=nullptr, bool* inserted=NULL) override;
67 
68  void get_station_vars(int id_station, int id_report, std::function<void(std::unique_ptr<wreport::Var>)> dest) override;
69  void add_station_vars(int id_station, Record& rec) override;
70 
74  void dump(FILE* out) override;
75 };
76 
78 {
79 public:
81 };
82 
83 }
84 }
85 }
86 }
87 #endif
dballe::sql::SQLiteConnection & conn
DB connection.
Definition: v6/sqlite/station.h:26
void dump(FILE *out) override
Dump the entire contents of the table to an output stream.
void get_station_vars(int id_station, int id_report, std::function< void(std::unique_ptr< wreport::Var >)> dest) override
Export station variables.
dballe::sql::SQLiteStatement * sfstm
Precompiled select fixed station query.
Definition: v6/sqlite/station.h:29
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:17
void read_station_vars(dballe::sql::SQLiteStatement &stm, std::function< void(std::unique_ptr< wreport::Var >)> dest)
Run stm, read its output and generate variables to send to dest.
dballe::sql::SQLiteStatement * istm
Precompiled insert query.
Definition: v6/sqlite/station.h:33
bool maybe_get_id(int lat, int lon, const char *ident, int *id)
Lookup the ID of a station, returning true if it was found, false if not.
void add_station_vars(int id_station, Record &rec) override
Add all station variables (without attributes) to rec.
Precompiled queries to manipulate the station table.
Definition: v6/sqlite/station.h:20
Definition: v6/sqlite/station.h:77
dballe::sql::SQLiteStatement * smstm
Precompiled select mobile station query.
Definition: v6/sqlite/station.h:31
int obtain_id(int lat, int lon, const char *ident=nullptr, bool *inserted=NULL) override
Get the station ID given latitude, longitude and mobile identifier.
SQLite statement.
Definition: sqlite.h:89
int get_id(int lat, int lon, const char *ident=nullptr) override
Get the station ID given latitude, longitude and mobile identifier.
Definition: v6/station.h:19
Database connection.
Definition: sqlite.h:34