5 #include <dballe/db/defs.h>
6 #include <wreport/varinfo.h>
7 #include <wreport/var.h>
31 struct ODBCConnection;
36 typedef std::vector<wreport::Varcode> AttrList;
61 virtual bool next() = 0;
78 virtual double get_lat()
const = 0;
81 virtual double get_lon()
const = 0;
84 virtual const char*
get_ident(
const char* def=0)
const = 0;
109 virtual wreport::Var
get_var()
const = 0;
160 virtual void query_attrs(std::function<
void(std::unique_ptr<wreport::Var>&&)> dest) = 0;
168 virtual void attr_insert(
const Values& attrs) = 0;
177 virtual void attr_remove(
const AttrList& qcs) = 0;
187 static db::Format get_default_format();
188 static void set_default_format(db::Format
format);
203 static std::unique_ptr<DB>
connect(
const char* dsn,
const char* user,
const char* password);
228 static std::unique_ptr<DB>
connect_memory(
const std::string& arg = std::string());
241 static std::unique_ptr<DB>
create(std::unique_ptr<db::Connection> conn);
251 static bool is_url(
const char* str);
254 virtual db::Format
format()
const = 0;
275 virtual void reset(
const char* repinfo_file=0) = 0;
294 virtual void update_repinfo(
const char* repinfo_file,
int* added,
int* deleted,
int* updated) = 0;
354 virtual void remove(
const Query& rec) = 0;
373 virtual void vacuum() = 0;
416 virtual std::unique_ptr<db::CursorData>
query_data(
const Query& query) = 0;
440 virtual void attr_query_station(
int data_id, std::function<
void(std::unique_ptr<wreport::Var>)>&& dest) = 0;
450 virtual void attr_query_data(
int data_id, std::function<
void(std::unique_ptr<wreport::Var>)>&& dest) = 0;
552 virtual bool export_msgs(
const Query& query, std::function<
bool(std::unique_ptr<Message>&&)> dest) = 0;
557 virtual void dump(FILE* out) = 0;
virtual bool next()=0
Get a new item from the results of a query.
static std::unique_ptr< DB > connect(const char *dsn, const char *user, const char *password)
Start a session with DB-All.e.
Common interface for cursors iterating over station or data values.
Definition: db.h:103
virtual void remove_all()=0
Remove all data from the database.
virtual void disappear()=0
Remove all our traces from the database, if applicable.
virtual wreport::Var get_var() const =0
Get the variable.
Cursor iterating over summary entries.
Definition: db.h:137
virtual void import_msg(const Message &msg, const char *repmemo, int flags)=0
Import a Message into the DB-All.e database.
virtual int attr_reference_id() const =0
Return an integer value that can be used to refer to the current variable for attribute access...
Cursor iterating over station data values.
Definition: db.h:119
virtual std::unique_ptr< db::CursorStationData > query_station_data(const Query &query)=0
Query the station variables in the database.
virtual std::unique_ptr< db::CursorSummary > query_summary(const Query &query)=0
Query a summary of what the result would be for a query.
static const char * default_repinfo_file()
Return the default repinfo file pathname.
virtual db::Format format() const =0
Return the format of this DB.
virtual const char * get_rep_memo() const =0
Get the report name.
virtual DB & get_db() const =0
Get the database that created this cursor.
virtual void to_record(Record &rec)=0
Fill in a record with the contents of a dba_db_cursor.
virtual wreport::Varcode get_varcode() const =0
Get the variable code.
virtual std::map< std::string, int > get_repinfo_priorities()=0
Get a mapping between rep_memo and their priorities.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:565
virtual unsigned test_iterate(FILE *dump=0)
Iterate the cursor until the end, returning the number of items.
virtual void attr_insert_data(int data_id, const Values &attrs)=0
Insert new attributes on a data value.
A bulletin that has been decoded and physically interpreted.
Definition: message.h:25
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
virtual void dump(FILE *out)=0
Dump the entire contents of the database to an output stream.
virtual void remove_station_data(const Query &query)=0
Remove data from the database.
virtual bool is_station_variable(int data_id, wreport::Varcode varcode)=0
Check if this varcode and data_id correspond to a station variable.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
virtual void attr_query_data(int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest)=0
Query attributes on a data value.
virtual void attr_remove_data(int data_id, const db::AttrList &qcs)=0
Delete attributes from a data value.
virtual Trange get_trange() const =0
Get the time range.
Common interface for all kinds of cursors.
Definition: db.h:39
Vertical level or layer.
Definition: types.h:515
virtual double get_lat() const =0
Get the station latitude.
Cursor iterating over stations.
Definition: db.h:98
Cursor iterating over data values.
Definition: db.h:124
virtual int remaining() const =0
Get the number of rows still to be fetched.
virtual DatetimeRange get_datetimerange() const =0
Get the datetime range.
Range of datetimes.
Definition: types.h:255
virtual void attr_query_station(int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest)=0
Query attributes on a station value.
virtual size_t get_count() const =0
Get the count of elements.
virtual int get_station_id() const =0
Get the station identifier.
virtual void attr_remove_station(int data_id, const db::AttrList &qcs)=0
Delete attributes from a station value.
virtual std::unique_ptr< db::CursorStation > query_stations(const Query &query)=0
Start a query on the station variables archive.
virtual void import_msgs(const Messages &msgs, const char *repmemo, int flags)
Import Messages into the DB-All.e database.
static bool is_url(const char *str)
Return TRUE if the string looks like a DB URL.
virtual Level get_level() const =0
Get the level.
Ordered collection of messages.
Definition: message.h:64
static std::unique_ptr< DB > create(std::unique_ptr< db::Connection > conn)
Create a database from an open Connection.
virtual void reset(const char *repinfo_file=0)=0
Reset the database, removing all existing Db-All.e tables and re-creating them empty.
virtual Trange get_trange() const =0
Get the time range.
Query used to filter DB-All.e data.
Definition: query.h:14
Date and time.
Definition: types.h:147
static std::unique_ptr< DB > connect_from_file(const char *pathname)
Create from a SQLite file pathname.
static std::unique_ptr< DB > connect_from_url(const char *url)
Create from an url-like specification, that can be:
virtual wreport::Varcode get_varcode() const =0
Get the variable code.
virtual void insert_station_data(StationValues &vals, bool can_replace, bool station_can_add)=0
Insert station values into the database.
virtual void vacuum()=0
Perform database cleanup operations.
virtual std::unique_ptr< db::CursorData > query_data(const Query &query)=0
Query the database.
virtual const char * get_ident(const char *def=0) const =0
Get the station identifier, or NULL if missing.
virtual void attr_insert_station(int data_id, const Values &attrs)=0
Insert new attributes on a station value.
virtual Level get_level() const =0
Get the level.
virtual void insert_data(DataValues &vals, bool can_replace, bool station_can_add)=0
Insert data values into the database.
virtual void update_repinfo(const char *repinfo_file, int *added, int *deleted, int *updated)=0
Update the repinfo table in the database, with the data found in the given file.
static std::unique_ptr< DB > connect_memory(const std::string &arg=std::string())
Create an in-memory database.
virtual Datetime get_datetime() const =0
Get the datetime.
virtual double get_lon() const =0
Get the station longitude.
virtual bool export_msgs(const Query &query, std::function< bool(std::unique_ptr< Message > &&)> dest)=0
Perform the query in `query', and send the results to dest.
static std::unique_ptr< DB > connect_test()
Start a test session with DB-All.e.
virtual void discard_rest()=0
Discard the results that have not been read yet.