26 #include <dballe/db/trace.h>
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)
122 void init_after_connect();
124 DB(std::unique_ptr<Connection> conn);
140 int obtain_station(
const Station& st,
bool can_add=
true);
181 void reset(
const char* repinfo_file = 0);
205 void update_repinfo(
const char* repinfo_file,
int* added,
int* deleted,
int* updated);
218 void remove(
const Query& query);
237 void attr_query_station(
int data_id, std::function<
void(std::unique_ptr<wreport::Var>)>&& dest)
override;
238 void attr_query_data(
int data_id, std::function<
void(std::unique_ptr<wreport::Var>)>&& dest)
override;
246 bool export_msgs(
const Query& query, std::function<
bool(std::unique_ptr<Message>&&)> dest)
override;
251 void dump(FILE* out);
void attr_query_station(int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest) override
Query attributes on a station value.
std::unique_ptr< db::CursorSummary > query_summary(const Query &query)
Query a summary of what the result would be for a query.
sql::LevTrCache & lev_tr_cache()
Access the lev_tr cache.
sql::AttrV6 & attr()
Access the data table.
Definition: db/trace.h:39
void attr_remove_station(int data_id, const db::AttrList &qcs) override
Delete attributes from a station value.
Trace trace
Database query tracing.
Definition: v6/db.h:93
void insert_data(DataValues &vals, bool can_replace, bool station_can_add) override
Insert data values into the database.
std::unique_ptr< db::CursorData > query_data(const Query &query)
Query the database.
struct sql::DataV6 * m_data
Variable data.
Definition: v6/db.h:117
Precompiled queries to manipulate the attr table.
Definition: sql/attrv6.h:46
bool explain_queries
True if we print an EXPLAIN trace of all queries to stderr.
Definition: v6/db.h:95
A bulletin that has been decoded and physically interpreted.
Definition: message.h:25
sql::DataV6 & data()
Access the data table.
void vacuum()
Remove orphan values from the database.
std::unique_ptr< db::CursorStation > query_stations(const Query &query)
Start a query on the station variables archive.
db::Format format() const
Return the format of this DB.
Definition: v6/db.h:145
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
void reset(const char *repinfo_file=0)
Reset the database, removing all existing DBALLE tables and re-creating them empty.
sql::Driver & driver()
Access the backend DB driver.
Functions used to connect to DB-All.e and insert, query and delete data.
void insert_station_data(StationValues &vals, bool can_replace, bool station_can_add) override
Insert station values into the database.
bool is_station_variable(int data_id, wreport::Varcode varcode) override
Check if this varcode and data_id correspond to a station variable.
struct sql::LevTr * m_lev_tr
Level/timerange information.
Definition: v6/db.h:113
db::Connection * conn
Database connection.
Definition: v6/db.h:91
void attr_insert_data(int data_id, const Values &attrs) override
Insert new attributes on a data value.
struct sql::Repinfo * m_repinfo
Accessors for the various parts of the database.
Definition: v6/db.h:109
sql::Station & station()
Access the station 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.
Fast cached access to the repinfo table.
Definition: sql/repinfo.h:77
void disappear()
Remove all our traces from the database, if applicable.
void delete_tables()
Delete all the DB-ALLe tables from the database.
Definition: db/sql/levtr.h:86
void remove_all()
Remove all data from the database.
Definition: sql/driver.h:84
Definition: db/sql/station.h:46
struct sql::Station * m_station
Station information.
Definition: v6/db.h:111
void attr_insert_station(int data_id, const Values &attrs) override
Insert new attributes on a station value.
void attr_remove_data(int data_id, const db::AttrList &qcs) override
Delete attributes from a data value.
Query used to filter DB-All.e data.
Definition: query.h:14
sql::Driver * m_driver
SQL driver backend.
Definition: v6/db.h:99
sql::Repinfo & repinfo()
Access the repinfo table.
std::unique_ptr< db::CursorStationData > query_station_data(const Query &query) override
Query the station variables in the database.
sql::LevTr & lev_tr()
Access the lev_tr table.
bool export_msgs(const Query &query, std::function< bool(std::unique_ptr< Message > &&)> dest) override
Perform the query in `query', and send the results to dest.
DB-ALLe database connection.
Definition: v6/db.h:87
void dump(FILE *out)
Dump the entire contents of the database to an output stream.
void import_msg(const Message &msg, const char *repmemo, int flags) override
Import a Message into the DB-All.e database.
std::map< std::string, int > get_repinfo_priorities()
Get a mapping between rep_memo and their priorities.
struct sql::LevTrCache * m_lev_tr_cache
Level/timerange cache.
Definition: v6/db.h:115
Precompiled queries to manipulate the lev_tr table.
Definition: db/sql/levtr.h:46
int rep_cod_from_memo(const char *memo)
Get the report code from a report mnemonic.
void attr_query_data(int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest) override
Query attributes on a data value.
struct sql::AttrV6 * m_attr
Variable attributes.
Definition: v6/db.h:119
void remove_station_data(const Query &query) override
Remove data from the database.
Precompiled query to manipulate the data table.
Definition: sql/datav6.h:57