5 #include <dballe/db/trace.h>
6 #include <dballe/db/v7/state.h>
7 #include <dballe/db/v7/data.h>
72 void init_after_connect();
74 DB(std::unique_ptr<dballe::sql::Connection>
conn);
95 db::Format
format()
const {
return V7; }
115 std::unique_ptr<dballe::Transaction>
transaction()
override;
130 void reset(
const char* repinfo_file = 0);
154 void update_repinfo(
const char* repinfo_file,
int* added,
int* deleted,
int* updated);
186 void attr_query_station(
int data_id, std::function<
void(std::unique_ptr<wreport::Var>)>&& dest)
override;
187 void attr_query_data(
int data_id, std::function<
void(std::unique_ptr<wreport::Var>)>&& dest)
override;
200 void dump(FILE* out);
v7::LevTr & levtr()
Access the levtr table.
void import_msg(dballe::Transaction &transaction, const Message &msg, const char *repmemo, int flags) override
Import a Message into the DB-All.e database.
void attr_insert_data(dballe::Transaction &transaction, int data_id, const Values &attrs) override
Insert new attributes on a data value.
A RAII transaction interface.
Definition: transaction.h:15
v7::LevTr * m_levtr
Level/timerange information.
Definition: v7/db.h:65
void attr_remove_data(dballe::Transaction &transaction, int data_id, const db::AttrList &attrs) override
Delete attributes from a data value.
v7::Repinfo & repinfo()
Access the repinfo table.
Information about a station.
Definition: values.h:21
v7::Data & data()
Access the data table.
Cache intermediate results during a database transaction, to avoid hitting the database multiple time...
Definition: state.h:140
void insert_data(dballe::Transaction &transaction, DataValues &vals, bool can_replace, bool station_can_add) override
Insert data values into the database.
Definition: db/trace.h:39
A set of measured values.
Definition: values.h:304
A bulletin that has been decoded and physically interpreted.
Definition: message.h:28
Fast cached access to the repinfo table.
Definition: v7/repinfo.h:76
Definition: v7/station.h:20
v7::Station * m_station
Station information.
Definition: v7/db.h:63
Functions used to connect to DB-All.e and insert, query and delete data.
void remove_station_data(dballe::Transaction &transaction, const Query &query) override
Remove data from the database.
v7::StationData & station_data()
Access the station_data table.
void vacuum()
Remove orphan values from the database.
bool export_msgs(dballe::Transaction &transaction, const Query &query, std::function< bool(std::unique_ptr< Message > &&)> dest) override
Perform the query in `query', and send the results to dest.
Trace trace
Database query tracing.
Definition: v7/db.h:45
void reset(const char *repinfo_file=0)
Reset the database, removing all existing DBALLE tables and re-creating them empty.
void attr_remove_station(dballe::Transaction &transaction, int data_id, const db::AttrList &attrs) override
Delete attributes from a station value.
std::unique_ptr< dballe::Transaction > transaction() override
Begin a transaction on this database, and return a Transaction object that can be used to commit it...
void attr_query_station(int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest) override
Query attributes on a station value.
dballe::sql::Connection * conn
Database connection.
Definition: v7/db.h:43
void delete_tables()
Delete all the DB-ALLe tables from the database.
std::unique_ptr< db::CursorStation > query_stations(const Query &query)
Start a query on the station variables archive.
std::map< std::string, int > get_repinfo_priorities()
Get a mapping between rep_memo and their priorities.
void disappear()
Remove all our traces from the database, if applicable.
v7::Driver & driver()
Access the backend DB driver.
Precompiled queries to manipulate the lev_tr table.
Definition: v7/levtr.h:25
bool explain_queries
True if we print an EXPLAIN trace of all queries to stderr.
Definition: v7/db.h:47
void insert_station_data(dballe::Transaction &transaction, StationValues &vals, bool can_replace, bool station_can_add) override
Insert station values into the database.
v7::Data * m_data
Variable data.
Definition: v7/db.h:69
void attr_insert_station(dballe::Transaction &transaction, int data_id, const Values &attrs) override
Insert new attributes on a station value.
Query used to filter DB-All.e data.
Definition: query.h:14
DB-ALLe database connection for database format V7.
Definition: v7/db.h:39
A set of station values.
Definition: values.h:274
std::unique_ptr< db::CursorData > query_data(const Query &query)
Query the database.
std::unique_ptr< db::CursorSummary > query_summary(const Query &query)
Query a summary of what the result would be for a query.
v7::Driver * m_driver
SQL driver backend.
Definition: v7/db.h:51
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.
void attr_query_data(int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest) override
Query attributes on a data value.
bool is_station_variable(int data_id, wreport::Varcode varcode) override
Check if this varcode and data_id correspond to a station variable.
void remove_all()
Remove all data from the database.
void dump(FILE *out)
Dump the entire contents of the database to an output stream.
v7::Repinfo * m_repinfo
Accessors for the various parts of the database.
Definition: v7/db.h:61
std::unique_ptr< db::CursorStationData > query_station_data(const Query &query) override
Query the station variables in the database.
db::Format format() const
Return the format of this DB.
Definition: v7/db.h:95
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:203
Definition: v7/driver.h:26
v7::Station & station()
Access the station table.
v7::StationData * m_station_data
Station data.
Definition: v7/db.h:67
int rep_cod_from_memo(const char *memo)
Get the report code from a report mnemonic.