libdballe  7.7
mem/db.h
1 #ifndef DBA_DB_MEM_H
2 #define DBA_DB_MEM_H
3 
4 #include <dballe/db/db.h>
5 #include <dballe/db/mem/repinfo.h>
6 #include <dballe/memdb/memdb.h>
7 #include <wreport/varinfo.h>
8 #include <string>
9 #include <vector>
10 #include <memory>
11 
12 namespace dballe {
13 namespace db {
14 
15 namespace mem {
16 
18 class DB : public dballe::DB
19 {
20 public:
23  Repinfo repinfo;
24 
25 protected:
26  std::string serialization_dir;
27 
30 
33 
36 
37 public:
38  DB();
39  DB(const std::string& arg);
40  virtual ~DB();
41 
42  db::Format format() const override { return MEM; }
43 
44  void disappear() override ;
45 
57  void reset(const char* repinfo_file = 0) override;
58 
76  void update_repinfo(const char* repinfo_file, int* added, int* deleted, int* updated) override;
77 
78  std::map<std::string, int> get_repinfo_priorities() override;
79 
80  void insert_station_data(StationValues& vals, bool can_replace, bool station_can_add) override;
81  void insert_data(DataValues& vals, bool can_replace, bool station_can_add) override;
82 
83  void remove_station_data(const Query& query) override;
84  void remove(const Query& rec) override;
85  void remove_all() override;
86 
96  void vacuum() override;
97 
98  std::unique_ptr<db::CursorStation> query_stations(const Query& query) override;
99  std::unique_ptr<db::CursorStationData> query_station_data(const Query& query) override;
100  std::unique_ptr<db::CursorData> query_data(const Query& query) override;
101  std::unique_ptr<db::CursorSummary> query_summary(const Query& query) override;
102 
103  void attr_query_station(int data_id, std::function<void(std::unique_ptr<wreport::Var>)>&& dest) override;
104  void attr_query_data(int data_id, std::function<void(std::unique_ptr<wreport::Var>)>&& dest) override;
105  void attr_insert_station(int data_id, const Values& attrs) override;
106  void attr_insert_data(int data_id, const Values& attrs) override;
107  void attr_remove_station(int data_id, const db::AttrList& qcs) override;
108  void attr_remove_data(int data_id, const db::AttrList& qcs) override;
109  bool is_station_variable(int data_id, wreport::Varcode varcode) override;
110 
111  void import_msg(const Message& msg, const char* repmemo, int flags) override;
112  bool export_msgs(const Query& query, std::function<bool(std::unique_ptr<Message>&&)> dest) override;
113 
117  void dump(FILE* out) override;
118 
119  friend class dballe::DB;
120 };
121 
122 }
123 }
124 }
125 #endif
void attr_insert_data(int data_id, const Values &attrs) override
Insert new attributes on a data value.
In-memory database backend.
Definition: memdb.h:78
Definition: values.h:163
void remove_all() override
Remove all data from the database.
void attr_query_data(int data_id, std::function< void(std::unique_ptr< wreport::Var >)> &&dest) override
Query attributes on a data value.
void attr_remove_data(int data_id, const db::AttrList &qcs) override
Delete attributes from a data value.
A bulletin that has been decoded and physically interpreted.
Definition: message.h:25
std::map< std::string, int > get_repinfo_priorities() override
Get a mapping between rep_memo and their priorities.
Standard dballe::Query implementation.
Definition: core/query.h:29
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
void raw_query_stations(const core::Query &rec, memdb::Results< memdb::Station > &res)
Query stations, returning a list of station IDs.
void update_repinfo(const char *repinfo_file, int *added, int *deleted, int *updated) override
Update the repinfo table in the database, with the data found in the given file.
Functions used to connect to DB-All.e and insert, query and delete data.
void dump(FILE *out) override
Dump the entire contents of the database to an output stream.
void vacuum() override
Remove orphan values from the database.
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::CursorStation > query_stations(const Query &query) override
Start a query on the station variables archive.
void attr_insert_station(int data_id, const Values &attrs) override
Insert new attributes on a station value.
void reset(const char *repinfo_file=0) override
Reset the database, removing all existing DBALLE tables and re-creating them empty.
void raw_query_station_data(const core::Query &rec, memdb::Results< memdb::StationValue > &res)
Query station data, returning a list of Value IDs.
bool is_station_variable(int data_id, wreport::Varcode varcode) override
Check if this varcode and data_id correspond to a station variable.
std::unique_ptr< db::CursorData > query_data(const Query &query) override
Query the database.
void insert_station_data(StationValues &vals, bool can_replace, bool station_can_add) override
Insert station values into the database.
Definition: db.h:182
std::unique_ptr< db::CursorStationData > query_station_data(const Query &query) override
Query the station variables in the database.
db::Format format() const override
Return the format of this DB.
Definition: mem/db.h:42
Query used to filter DB-All.e data.
Definition: query.h:14
Definition: mem/repinfo.h:33
Definition: values.h:142
void raw_query_data(const core::Query &rec, memdb::Results< memdb::Value > &res)
Query data, returning a list of Value IDs.
void import_msg(const Message &msg, const char *repmemo, int flags) override
Import a Message into the DB-All.e database.
void disappear() override
Remove all our traces from the database, if applicable.
void insert_data(DataValues &vals, bool can_replace, bool station_can_add) override
Insert data values into the database.
std::unique_ptr< db::CursorSummary > query_summary(const Query &query) override
Query a summary of what the result would be for a query.
Definition: memdb/levtr.h:16
void attr_remove_station(int data_id, const db::AttrList &qcs) override
Delete attributes from a station value.
Memdb memdb
In-memory database backend.
Definition: mem/db.h:22
Definition: values.h:106
DB-ALLe database, in-memory db implementation.
Definition: mem/db.h:18
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.
void remove_station_data(const Query &query) override
Remove data from the database.