libdballe  7.29
v7/station.h
1 #ifndef DBALLE_DB_V7_STATION_H
2 #define DBALLE_DB_V7_STATION_H
3 
4 #include <dballe/sql/fwd.h>
5 #include <dballe/db/v7/state.h>
6 #include <memory>
7 #include <cstdio>
8 #include <functional>
9 
10 namespace wreport {
11 struct Var;
12 }
13 
14 namespace dballe {
15 struct Record;
16 
17 namespace db {
18 namespace v7 {
19 
20 struct Station
21 {
22 protected:
23  virtual bool maybe_get_id(const StationDesc& st, int* id) = 0;
24  virtual void _dump(std::function<void(int, int, const Coords& coords, const char* ident)> out) = 0;
25 
26 public:
28  //static std::unique_ptr<Station> create(Connection& conn);
29 
30  virtual ~Station();
31 
37  virtual stations_t::iterator lookup_id(State& st, int id) = 0;
38 
44  virtual stations_t::iterator get_id(State& st, const StationDesc& desc);
45 
51  virtual stations_t::iterator obtain_id(State& st, const StationDesc& desc) = 0;
52 
56  void dump(FILE* out);
57 
61  virtual void get_station_vars(int id_station, std::function<void(std::unique_ptr<wreport::Var>)> dest) = 0;
62 
69  virtual void add_station_vars(int id_station, Record& rec) = 0;
70 };
71 
72 }
73 }
74 }
75 #endif
76 
Definition: state.h:32
virtual stations_t::iterator get_id(State &st, const StationDesc &desc)
Get the station ID given latitude, longitude and mobile identifier.
Cache intermediate results during a database transaction, to avoid hitting the database multiple time...
Definition: state.h:140
virtual void add_station_vars(int id_station, Record &rec)=0
Add all station variables (without attributes) to rec.
Coordinates.
Definition: types.h:337
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:17
Forward declarations for public dballe/sql names.
virtual ~Station()
Instantiate a Station object for this connection.
Definition: v7/station.h:20
void dump(FILE *out)
Dump the entire contents of the table to an output stream.
virtual void get_station_vars(int id_station, std::function< void(std::unique_ptr< wreport::Var >)> dest)=0
Export station variables.
virtual stations_t::iterator obtain_id(State &st, const StationDesc &desc)=0
Get the station ID given latitude, longitude and mobile identifier.
virtual stations_t::iterator lookup_id(State &st, int id)=0
Look up a station give its ID.