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)
97 wreport::Varcode code;
98 DBALLE_SQL_C_SINT_TYPE id;
99 VarID(wreport::Varcode code, DBALLE_SQL_C_SINT_TYPE
id) : code(code), id(
id) {}
138 int _last_station_id;
140 void init_after_connect();
145 void run_sql(
const char* query);
147 DB(std::auto_ptr<Connection>& conn);
185 void reset(
const char* repinfo_file = 0);
209 void update_repinfo(
const char* repinfo_file,
int* added,
int* deleted,
int* updated);
260 int obtain_station(
const Record& rec,
bool can_add=
true);
273 int obtain_lev_tr(
const Record& rec);
289 void insert(
const Record& rec,
bool can_replace,
bool station_can_add);
300 void remove(
const Record& rec);
356 unsigned query_attrs(
int id_data, wreport::Varcode id_var,
const db::AttrList& qcs,
Record& attrs);
373 void attr_remove(
int id_data, wreport::Varcode id_var,
const db::AttrList& qcs);
389 void import_msg(
const Msg& msg,
const char* repmemo,
int flags);
405 void dump(FILE* out);
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...
Definition: db/v6/repinfo.h:31
Store information about the database ID of a variable.
Definition: v6/db.h:95
v5::Station & station()
Access the station table.
LevTrCache & lev_tr_cache()
Access the lev_tr cache.
struct LevTr * m_lev_tr
Level/timerange information.
Definition: v6/db.h:117
Storage for related physical data.
Definition: msg.h:119
void attr_remove(int id_data, 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
unsigned query_attrs(int id_data, wreport::Varcode id_var, const db::AttrList &qcs, Record &attrs)
Query attributes.
Precompiled queries to manipulate the attr table.
Definition: v6/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_summary(const Record &rec)
Query a summary of what the result would be for a query.
void vacuum()
Remove orphan values from the database.
db::Sequence * seq_lev_tr
Sequence accessors.
Definition: v6/db.h:133
DB-All.E record.
Definition: record.h:102
db::Format format() const
Return the format of this DB.
Definition: v6/db.h:152
void reset(const char *repinfo_file=0)
Reset the database, removing all existing DBALLE tables and re-creating them empty.
std::auto_ptr< db::Cursor > query_data(const Record &rec)
Query the database.
struct Data * m_data
Variable data.
Definition: v6/db.h:121
struct LevTrCache * m_lev_tr_cache
Level/timerange cache.
Definition: v6/db.h:119
Functions used to connect to DB-All.e and insert, query and delete data.
Precompiled queries to manipulate the station table.
Definition: db/v5/station.h:46
std::vector< VarID > last_insert_varids
Store database variable IDs for all last inserted variables.
Definition: v6/db.h:103
struct v5::Station * m_station
Station information.
Definition: v6/db.h:115
db::Connection * conn
ODBC database connection.
Definition: v6/db.h:91
LevTr & lev_tr()
Access the lev_tr table.
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.
int last_data_insert_id()
Return the ID of the last inserted data.
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...
Attr & attr()
Access the data table.
void disappear()
Remove all our traces from the database, if applicable.
void delete_tables()
Delete all the DB-ALLe tables from the database.
void remove_all()
Remove all data from the database.
struct v6::Repinfo * m_repinfo
Accessors for the various parts of the database.
Definition: v6/db.h:113
db::Sequence * seq_data
data ID sequence
Definition: v6/db.h:135
Precompiled queries to manipulate the lev_tr table.
Definition: lev_tr.h:55
bool check_rep_cod(int rep_cod)
Verify that a rep_cod is supported by the database.
Data & data()
Access the data table.
Consumer interface used to stream messages as they are produced.
Definition: msg.h:478
void insert(const Record &rec, bool can_replace, bool station_can_add)
Insert a record into the database.
ODBC statement to read a sequence.
Definition: internals.h:299
struct Attr * m_attr
Variable attributes.
Definition: v6/db.h:123
std::auto_ptr< db::Cursor > query_stations(const Record &query)
Start a query on the station archive.
int get_rep_cod(const Record &rec)
Get the report id from this record.
DB-ALLe database connection.
Definition: v6/db.h:87
v6::Repinfo & repinfo()
Access the repinfo table.
void dump(FILE *out)
Dump the entire contents of the database to an output stream.
void run_sql(const char *query)
Run a one-off SQL query.
int last_lev_tr_insert_id()
Return the ID of the last inserted lev_tr.
std::map< std::string, int > get_repinfo_priorities()
Get a mapping between rep_memo and their priorities.
int rep_cod_from_memo(const char *memo)
Get the report code from a report mnemonic.
Precompiled query to manipulate the data table.
Definition: v6/data.h:48
void import_msg(const Msg &msg, const char *repmemo, int flags)
Import a Msg message into the DB-All.e database.