libdballe  7.29
v6/mysql/station.h
1 #ifndef DBALLE_DB_V6_MYSQL_STATION_H
2 #define DBALLE_DB_V6_MYSQL_STATION_H
3 
4 #include <dballe/db/v6/station.h>
5 #include <dballe/sql/fwd.h>
6 #include <functional>
7 #include <memory>
8 
9 namespace wreport {
10 struct Var;
11 }
12 
13 namespace dballe {
14 namespace db {
15 namespace v6 {
16 namespace mysql {
17 
22 {
23 protected:
28 
30  bool maybe_get_id(int lat, int lon, const char* ident, int* id);
31 
33  void read_station_vars(const std::string& query, std::function<void(std::unique_ptr<wreport::Var>)> dest);
34 
35 public:
38  MySQLStationBase(const MySQLStationBase&) = delete;
39  MySQLStationBase(const MySQLStationBase&&) = delete;
40  MySQLStationBase& operator=(const MySQLStationBase&) = delete;
41 
50  int get_id(int lat, int lon, const char* ident=nullptr) override;
51 
60  int obtain_id(int lat, int lon, const char* ident=nullptr, bool* inserted=NULL) override;
61 
62  void get_station_vars(int id_station, int id_report, std::function<void(std::unique_ptr<wreport::Var>)> dest) override;
63  void add_station_vars(int id_station, Record& rec) override;
64 
68  void dump(FILE* out) override;
69 };
70 
72 {
73 public:
75 };
76 
77 }
78 }
79 }
80 }
81 #endif
void dump(FILE *out) override
Dump the entire contents of the table to an output stream.
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.
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:17
Forward declarations for public dballe/sql names.
int get_id(int lat, int lon, const char *ident=nullptr) override
Get the station ID given latitude, longitude and mobile identifier.
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/mysql/station.h:21
void read_station_vars(const std::string &query, std::function< void(std::unique_ptr< wreport::Var >)> dest)
Run stm, read its output and generate variables to send to dest.
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.
Definition: v6/station.h:19
Definition: v6/mysql/station.h:71
Database connection.
Definition: mysql.h:126
sql::MySQLConnection & conn
DB connection.
Definition: v6/mysql/station.h:27
void get_station_vars(int id_station, int id_report, std::function< void(std::unique_ptr< wreport::Var >)> dest) override
Export station variables.