libdballe  7.6
db/sql/station.h
Go to the documentation of this file.
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_SQL_STATION_H
23 #define DBALLE_DB_SQL_STATION_H
24 
31 #include <memory>
32 #include <cstdio>
33 
34 namespace wreport {
35 struct Var;
36 }
37 
38 namespace dballe {
39 struct Record;
40 
41 namespace db {
42 struct Connection;
43 
44 namespace sql {
45 
46 struct Station
47 {
48 public:
50  //static std::unique_ptr<Station> create(Connection& conn);
51 
52  virtual ~Station();
53 
62  virtual int get_id(int lat, int lon, const char* ident=NULL) = 0;
63 
72  virtual int obtain_id(int lat, int lon, const char* ident=NULL, bool* inserted=NULL) = 0;
73 
77  virtual void dump(FILE* out) = 0;
78 
82  virtual void get_station_vars(int id_station, int id_report, std::function<void(std::unique_ptr<wreport::Var>)> dest) = 0;
83 
90  virtual void add_station_vars(int id_station, Record& rec) = 0;
91 };
92 
93 }
94 }
95 }
96 
97 #endif
98 
virtual void dump(FILE *out)=0
Dump the entire contents of the table to an output stream.
virtual void get_station_vars(int id_station, int id_report, std::function< void(std::unique_ptr< wreport::Var >)> dest)=0
Export station variables.
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
virtual ~Station()
Instantiate a Station object for this connection.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
virtual void add_station_vars(int id_station, Record &rec)=0
Add all station variables (without attributes) to rec.
Definition: db/sql/station.h:46
virtual int obtain_id(int lat, int lon, const char *ident=NULL, bool *inserted=NULL)=0
Get the station ID given latitude, longitude and mobile identifier.
Definition: conversion.h:6
virtual int get_id(int lat, int lon, const char *ident=NULL)=0
Get the station ID given latitude, longitude and mobile identifier.