26 #include <wreport/varinfo.h>
27 #include <wreport/var.h>
44 #define DBA_IMPORT_ATTRS 1
46 #define DBA_IMPORT_FULL_PSEUDOANA 2
49 #define DBA_IMPORT_OVERWRITE 8
75 typedef std::vector<wreport::Varcode> AttrList;
100 virtual bool next() = 0;
117 virtual double get_lat()
const = 0;
120 virtual double get_lon()
const = 0;
123 virtual const char*
get_ident(
const char* def=0)
const = 0;
126 virtual const char*
get_rep_memo(
const char* def=0)
const = 0;
141 virtual wreport::Var
get_var()
const = 0;
186 static db::Format get_default_format();
187 static void set_default_format(db::Format
format);
202 static std::auto_ptr<DB>
connect(
const char* dsn,
const char* user,
const char* password);
227 static std::auto_ptr<DB>
connect_memory(
const std::string& arg = std::string());
245 static bool is_url(
const char* str);
248 virtual db::Format
format()
const = 0;
269 virtual void reset(
const char* repinfo_file = 0) = 0;
288 virtual void update_repinfo(
const char* repinfo_file,
int* added,
int* deleted,
int* updated) = 0;
313 virtual void insert(
const Record& rec,
bool can_replace,
bool station_can_add) = 0;
327 virtual void remove(
const Record& rec) = 0;
346 virtual void vacuum() = 0;
406 virtual unsigned query_attrs(
int reference_id, wreport::Varcode id_var,
const db::AttrList& qcs,
Record& attrs) = 0;
432 virtual void attr_insert(
int reference_id, wreport::Varcode id_var,
const Record& attrs) = 0;
446 virtual void attr_remove(
int reference_id, wreport::Varcode id_var,
const db::AttrList& qcs) = 0;
462 virtual void import_msg(
const Msg& msg,
const char* repmemo,
int flags) = 0;
478 virtual void import_msgs(
const Msgs& msgs,
const char* repmemo,
int flags);
494 virtual void dump(FILE* out) = 0;
500 static std::auto_ptr<DB> instantiate_db(std::auto_ptr<db::Connection>& conn);
virtual std::auto_ptr< db::Cursor > query_stations(const Record &query)=0
Start a query on the station variables archive.
virtual unsigned query_attrs(const AttrList &qcs, Record &attrs)=0
Query attributes for the current variable.
static std::auto_ptr< DB > connect_memory(const std::string &arg=std::string())
Create an in-memory database.
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 void attr_insert(const Record &attrs)=0
Insert/overwrite new attributes for the current variable.
virtual std::auto_ptr< db::Cursor > query_data(const Record &rec)=0
Query the database.
virtual const char * get_rep_memo(const char *def=0) const =0
Get the report name.
virtual void import_msg(const Msg &msg, const char *repmemo, int flags)=0
Import a Msg message into the DB-All.e database.
Storage for related physical data.
Definition: msg.h:119
virtual int attr_reference_id() const =0
Return an integer value that can be used to refer to the current variable for attribute access...
static std::auto_ptr< DB > connect_from_url(const char *url)
Create from an url-like specification, that can be:
virtual double get_lon() const =0
Get the station longitude.
static const char * default_repinfo_file()
Return the default repinfo file pathname.
virtual Level get_level() const =0
Get the level.
virtual db::Format format() const =0
Return the format of this DB.
virtual std::map< std::string, int > get_repinfo_priorities()=0
Get a mapping between rep_memo and their priorities.
virtual DB & get_db() const =0
Get the database that created this cursor.
virtual int get_station_id() const =0
Get the station identifier.
virtual unsigned query_attrs(int reference_id, wreport::Varcode id_var, const db::AttrList &qcs, Record &attrs)=0
Query attributes.
virtual void dump(FILE *out)=0
Dump the entire contents of the database to an output stream.
virtual void attr_insert(wreport::Varcode id_var, const Record &attrs)=0
Insert new attributes into the database, reusing the reference IDs stored by the last insert...
DB-All.E record.
Definition: record.h:102
virtual void attr_remove(int reference_id, wreport::Varcode id_var, const db::AttrList &qcs)=0
Delete QC data for the variable `var' in record `rec' (coming from a previous dba_query) ...
virtual Trange get_trange() const =0
Get the level.
virtual double get_lat() const =0
Get the station latitude.
virtual wreport::Varcode get_varcode() const =0
Get the variable code.
virtual void attr_remove(const AttrList &qcs)=0
Delete attributes for the current variable.
virtual void get_datetime(int(&dt)[6]) const =0
Get the datetime.
virtual unsigned test_iterate(FILE *dump=0)
Iterate the cursor until the end, returning the number of items.
virtual void discard_rest()=0
Discard the results that have not been read yet.
virtual void export_msgs(const Record &query, MsgConsumer &cons)=0
Perform the query in `query', and return the results as a NULL-terminated array of dba_msg...
virtual void import_msgs(const Msgs &msgs, const char *repmemo, int flags)
Import Msgs 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 int last_station_id() const =0
Return the station id for the last data that was inserted.
virtual const char * get_ident(const char *def=0) const =0
Get the station identifier, or NULL if missing.
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 wreport::Var get_var() const =0
Get the variable.
Dynamic array of dba_msg.
Definition: msgs.h:38
virtual void to_record(Record &rec)=0
Fill in a record with the contents of a dba_db_cursor.
virtual std::auto_ptr< db::Cursor > query_summary(const Record &rec)=0
Query a summary of what the result would be for a query.
Consumer interface used to stream messages as they are produced.
Definition: msg.h:478
virtual bool next()=0
Get a new item from the results of a query.
virtual void vacuum()=0
Perform database cleanup operations.
static std::auto_ptr< DB > connect_test()
Start a test session with DB-All.e.
virtual int remaining() const =0
Get the number of rows still to be fetched.
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.
virtual void insert(const Record &rec, bool can_replace, bool station_can_add)=0
Insert a record into the database.
static std::auto_ptr< DB > connect_from_file(const char *pathname)
Create from a SQLite file pathname.
static std::auto_ptr< DB > connect(const char *dsn, const char *user, const char *password)
Start a session with DB-All.e.