27 #include <wreport/varinfo.h>
42 #define DBA_DB_WANT_COORDS (1 << 0)
44 #define DBA_DB_WANT_IDENT (1 << 1)
46 #define DBA_DB_WANT_LEVEL (1 << 2)
48 #define DBA_DB_WANT_TIMERANGE (1 << 3)
50 #define DBA_DB_WANT_DATETIME (1 << 4)
52 #define DBA_DB_WANT_VAR_NAME (1 << 5)
54 #define DBA_DB_WANT_VAR_VALUE (1 << 6)
56 #define DBA_DB_WANT_REPCOD (1 << 7)
58 #define DBA_DB_WANT_ANA_ID (1 << 8)
60 #define DBA_DB_WANT_CONTEXT_ID (1 << 9)
128 int _last_station_id;
130 void init_after_connect();
143 DB(std::auto_ptr<Connection>& conn);
178 void reset(
const char* repinfo_file = 0);
202 void update_repinfo(
const char* repinfo_file,
int* added,
int* deleted,
int* updated);
253 int obtain_station(
const Record& rec,
bool can_add=
true);
266 int obtain_context(
const Record& rec);
268 void insert(
const Record& rec,
bool can_replace,
bool station_can_add);
279 void remove(
const Record& rec);
309 std::auto_ptr<db::Cursor>
query(
const Record&
query,
unsigned int wanted,
unsigned int modifiers);
354 unsigned query_attrs(
int reference_id, wreport::Varcode id_var,
const db::AttrList& qcs,
Record& attrs);
357 void attr_insert(
int reference_id, wreport::Varcode id_var,
const Record& attrs);
371 void attr_remove(
int reference_id, wreport::Varcode id_var,
const db::AttrList& qcs);
387 void import_msg(
const Msg& msg,
const char* repmemo,
int flags);
403 void dump(FILE* out);
void delete_tables()
Delete all the DB-ALLe tables from the database.
void remove_all()
Remove all data from the database.
DB-ALLe database connection.
Definition: v5/db.h:83
void update_repinfo(const char *repinfo_file, int *added, int *deleted, int *updated)
Update the repinfo table in the database, with the data found in the given file.
struct Data * m_data
Variable data.
Definition: v5/db.h:106
struct Context * m_context
Variable context.
Definition: v5/db.h:104
void import_msg(const Msg &msg, const char *repmemo, int flags)
Import a Msg message into the DB-All.e database.
bool check_rep_cod(int rep_cod)
Verify that a rep_cod is supported by the database.
db::Statement * stm_last_insert_id
Precompiled LAST_INSERT_ID (or equivalent) SQL statement.
Definition: v5/db.h:112
struct Station * m_station
Station information.
Definition: v5/db.h:102
Storage for related physical data.
Definition: msg.h:119
int last_station_insert_id()
Return the ID of the last inserted station.
struct Attr * m_attr
Variable attributes.
Definition: v5/db.h:108
Fast cached access to the repinfo table.
Definition: db/v5/repinfo.h:94
Precompiled queries to manipulate the context table.
Definition: db/v5/context.h:46
std::auto_ptr< db::Cursor > query_data(const Record &rec)
Query the database.
void attr_remove(int reference_id, wreport::Varcode id_var, const db::AttrList &qcs)
Delete QC data for the variable `var' in record `rec' (coming from a previous dba_query) ...
Database connection.
Definition: internals.h:124
Precompiled queries to manipulate the attr table.
Definition: v5/attr.h:48
int last_station_id() const
Return the station id for the last data that was inserted.
The ODBC specification is imperfect with regards to integer sizes on 64bit platforms, and different ODBC drivers are currently interpreting it differently.
std::auto_ptr< db::Cursor > query_stations(const Record &query)
Start a query on the station variables archive.
int last_context_insert_id()
Return the ID of the last inserted context.
DB-All.E record.
Definition: record.h:102
Context & context()
Access the context table.
Station & station()
Access the station table.
virtual std::map< std::string, int > get_repinfo_priorities()
Get a mapping between rep_memo and their priorities.
db::Connection * conn
ODBC database connection.
Definition: v5/db.h:87
Functions used to connect to DB-All.e and insert, query and delete data.
DBALLE_SQL_C_SINT_TYPE m_last_insert_id
ID of the last autogenerated primary key.
Definition: v5/db.h:114
Precompiled queries to manipulate the station table.
Definition: db/v5/station.h:46
db::Sequence * seq_station
Sequence accessors.
Definition: v5/db.h:123
Attr & attr()
Access the data table.
void run_sql(const char *query)
Run a one-off SQL query.
int rep_cod_from_memo(const char *memo)
Get the report code from a report mnemonic.
std::auto_ptr< db::Cursor > query(const Record &query, unsigned int wanted, unsigned int modifiers)
Create and execute a database query.
void fill_ana_layer(Msg &msg, int id_station, int id_report)
Fill a message station info layer with information from the given station and report IDs...
void export_msgs(const Record &query, MsgConsumer &cons)
Perform the query in `query', and return the results as a NULL-terminated array of dba_msg...
void insert(const Record &rec, bool can_replace, bool station_can_add)
Insert a record into the database.
void reset(const char *repinfo_file=0)
Reset the database, removing all existing DBALLE tables and re-creating them empty.
ODBC statement.
Definition: internals.h:220
db::Format format() const
Return the format of this DB.
Definition: v5/db.h:148
virtual std::auto_ptr< db::Cursor > query_summary(const Record &rec)
Query a summary of what the result would be for a query.
unsigned query_attrs(int reference_id, wreport::Varcode id_var, const db::AttrList &qcs, Record &attrs)
Query attributes.
void dump(FILE *out)
Dump the entire contents of the database to an output stream.
struct Repinfo * m_repinfo
Accessors for the various parts of the database.
Definition: v5/db.h:100
Consumer interface used to stream messages as they are produced.
Definition: msg.h:478
ODBC statement to read a sequence.
Definition: internals.h:299
Repinfo & repinfo()
Access the repinfo table.
int get_rep_cod(const Record &rec)
Get the report id from this record.
void disappear()
Remove all our traces from the database, if applicable.
Data & data()
Access the data table.
db::Sequence * seq_context
Context ID sequence.
Definition: v5/db.h:125
void vacuum()
Remove orphan values from the database.
Precompiled query to manipulate the data table.
Definition: v5/data.h:48
void attr_insert(wreport::Varcode id_var, const Record &attrs)
Insert new attributes into the database, reusing the reference IDs stored by the last insert...