4 #include <dballe/transaction.h>
7 #include <dballe/db/defs.h>
10 #include <wreport/var.h>
36 std::string format_format(Format format);
39 Format format_parse(
const std::string& str);
65 virtual bool next() = 0;
87 virtual double get_lat()
const = 0;
90 virtual double get_lon()
const = 0;
93 virtual const char*
get_ident(
const char* def=0)
const = 0;
171 static db::Format get_default_format();
172 static void set_default_format(db::Format
format);
194 static std::unique_ptr<DB>
connect_memory(
const std::string& arg = std::string());
207 static std::unique_ptr<DB>
create(std::unique_ptr<sql::Connection> conn);
217 static bool is_url(
const char* str);
220 virtual db::Format
format()
const = 0;
241 virtual void reset(
const char* repinfo_file=0) = 0;
260 virtual void update_repinfo(
const char* repinfo_file,
int* added,
int* deleted,
int* updated) = 0;
272 virtual std::unique_ptr<dballe::Transaction>
transaction() = 0;
377 void remove(
const Query& query);
418 virtual void vacuum() = 0;
461 virtual std::unique_ptr<db::CursorData>
query_data(
const Query& query) = 0;
485 virtual void attr_query_station(
int data_id, std::function<
void(std::unique_ptr<wreport::Var>)>&& dest) = 0;
495 virtual void attr_query_data(
int data_id, std::function<
void(std::unique_ptr<wreport::Var>)>&& dest) = 0;
675 bool export_msgs(
const Query& query, std::function<
bool(std::unique_ptr<Message>&&)> dest);
696 virtual void dump(FILE* out) = 0;
virtual void print_info(FILE *out)
Print informations about the database to the given output stream.
virtual bool next()=0
Get a new item from the results of a query.
Common interface for cursors iterating over station or data values.
Definition: db.h:112
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:146
void import_msg(const Message &msg, const char *repmemo, int flags)
Import a Message into the DB-All.e database.
A RAII transaction interface.
Definition: transaction.h:15
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:128
Information about a station.
Definition: values.h:21
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.
void insert_data(DataValues &vals, bool can_replace, bool station_can_add)
Insert data values into the database.
void import_msgs(const Messages &msgs, const char *repmemo, int flags)
Import Messages into the DB-All.e database.
void attr_insert_data(int data_id, const Values &attrs)
Insert new attributes on a data value.
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.
A set of measured values.
Definition: values.h:304
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:587
virtual unsigned test_iterate(FILE *dump=0)
Iterate the cursor until the end, returning the number of items.
A bulletin that has been decoded and physically interpreted.
Definition: message.h:28
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:17
virtual void dump(FILE *out)=0
Dump the entire contents of the database to an output stream.
void insert_station_data(StationValues &vals, bool can_replace, bool station_can_add)
Insert station values into 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.
Forward declarations for public dballe/sql names.
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 Trange get_trange() const =0
Get the time range.
Common interface for all kinds of cursors.
Definition: db.h:43
Vertical level or layer.
Definition: types.h:532
virtual double get_lat() const =0
Get the station latitude.
Cursor iterating over stations.
Definition: db.h:107
Cursor iterating over data values.
Definition: db.h:133
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:272
void remove_station_data(const Query &query)
Remove data from the database.
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.
static std::unique_ptr< DB > create(std::unique_ptr< sql::Connection > conn)
Create a database from an open Connection.
virtual std::unique_ptr< db::CursorStation > query_stations(const Query &query)=0
Start a query on the station variables archive.
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.
void attr_insert_station(int data_id, const Values &attrs)
Insert new attributes on a station value.
Ordered collection of messages.
Definition: message.h:67
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.
void attr_remove_data(int data_id, const db::AttrList &attrs)
Delete attributes from a data value.
virtual std::unique_ptr< dballe::Transaction > transaction()=0
Begin a transaction on this database, and return a Transaction object that can be used to commit it...
Query used to filter DB-All.e data.
Definition: query.h:14
Date and time.
Definition: types.h:158
void attr_remove_station(int data_id, const db::AttrList &attrs)
Delete attributes from a station value.
bool export_msgs(const Query &query, std::function< bool(std::unique_ptr< Message > &&)> dest)
Perform the query in `query', and send the results to dest.
static std::unique_ptr< DB > connect_from_file(const char *pathname)
Create from a SQLite file pathname.
A set of station values.
Definition: values.h:274
static std::unique_ptr< DB > connect_from_url(const char *url)
Create from an url-like specification, as described in doc/fapi_connect.md.
virtual wreport::Varcode get_varcode() const =0
Get the variable code.
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.
Structures used as input to database insert functions.
virtual Level get_level() const =0
Get the level.
void remove_all()
Remove all data from 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.
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:203
virtual Datetime get_datetime() const =0
Get the datetime.
virtual double get_lon() const =0
Get the station longitude.
static std::unique_ptr< DB > connect_test()
Start a test session with DB-All.e.
virtual Station get_station() const =0
Get the whole station data in a single call.
virtual void discard_rest()=0
Discard the results that have not been read yet.