libdballe  9.14
explorer.h
1 #ifndef DBALLE_DB_EXPLORER_H
2 #define DBALLE_DB_EXPLORER_H
3 
4 #include <dballe/core/query.h>
5 #include <dballe/db/db.h>
6 #include <dballe/db/summary.h>
7 #include <map>
8 #include <set>
9 #include <vector>
10 
11 namespace dballe {
12 namespace db {
13 
14 template <typename Station> class BaseExplorer
15 {
16 protected:
18  std::shared_ptr<dballe::db::BaseSummary<Station>> _global_summary;
19 
22 
24  std::shared_ptr<dballe::db::BaseSummary<Station>> _active_summary;
25 
27  void commit();
28 
30  void update_active_summary();
31 
32 public:
33  class Update
34  {
35  protected:
36  BaseExplorer<Station>* explorer = nullptr;
37 
38  Update(BaseExplorer<Station>* explorer);
39 
40  public:
41  Update();
42  Update(const Update&) = delete;
43  Update(Update&&);
44  ~Update();
45 
46  Update& operator=(const Update&) = delete;
47  Update& operator=(Update&&);
48 
51 
54 
56  void add_json(core::json::Stream& in);
57 
60  template <typename OStation>
61  void add_explorer(const BaseExplorer<OStation>& explorer);
62 
64  void add_message(const dballe::Message& message,
65  bool station_data = true, bool data = true);
66 
68  void add_messages(
69  const std::vector<std::shared_ptr<dballe::Message>>& messages,
70  bool station_data = true, bool data = true);
71 
72  void commit();
73 
74  friend class BaseExplorer<Station>;
75  };
76 
77  BaseExplorer();
78  BaseExplorer(const std::string& pathname);
79  BaseExplorer(const BaseExplorer&) = delete;
80  BaseExplorer(BaseExplorer&&) = delete;
81  ~BaseExplorer();
82  BaseExplorer& operator=(const BaseExplorer&) = delete;
83  BaseExplorer& operator=(BaseExplorer&&) = delete;
84 
86  const dballe::Query& get_filter() const;
87 
91  void set_filter(const dballe::Query& query);
92 
98  Update rebuild();
99 
103  Update update();
104 
107 
110 
112  void to_json(core::JSONWriter& writer) const;
113 };
114 
119 
124 
125 extern template class BaseExplorer<dballe::Station>;
127  const BaseExplorer<DBStation>&);
128 extern template class BaseExplorer<dballe::DBStation>;
130  const BaseExplorer<Station>&);
131 
132 } // namespace db
133 } // namespace dballe
134 #endif
Definition: explorer.h:33
void commit()
Commit changes to disk.
void add_message(const dballe::Message &message, bool station_data=true, bool data=true)
Merge the contents of a message.
Definition: json.h:162
Station information.
Definition: types.h:878
void add_db(dballe::db::Transaction &tr)
Merge summary data from a database.
dballe::core::Query filter
Currently active filter.
Definition: explorer.h:21
Update rebuild()
Throw away all cached data and rebuild the explorer from scratch.
Functions used to connect to DB-All.e and insert, query and delete data.
Cursor iterating over summary entries.
Definition: cursor.h:98
Standard dballe::Query implementation.
Definition: core/query.h:35
std::shared_ptr< dballe::db::BaseSummary< Station > > _global_summary
Summary of the whole database.
Definition: explorer.h:18
Definition: cmdline.h:18
const dballe::db::BaseSummary< Station > & global_summary() const
Get a reference to the global summary.
void add_explorer(const BaseExplorer< OStation > &explorer)
Merge the currently selected contents of another explorer into this one.
A bulletin that has been decoded and physically interpreted.
Definition: message.h:28
Definition: explorer.h:14
const dballe::Query & get_filter() const
Get the current filter.
void add_messages(const std::vector< std::shared_ptr< dballe::Message >> &messages, bool station_data=true, bool data=true)
Merge the contents of a vector of messages.
Definition: db/db.h:155
void to_json(core::JSONWriter &writer) const
Export the explorer to JSON.
void update_active_summary()
Regenerate _active_summary based on filter.
High level objects for working with DB-All.e DB summaries.
Definition: summary.h:70
std::shared_ptr< dballe::db::BaseSummary< Station > > _active_summary
Summary of active_filter.
Definition: explorer.h:24
JSON serializer.
Definition: json.h:29
const dballe::db::BaseSummary< Station > & active_summary() const
Get a reference to the summary for the current filter.
void set_filter(const dballe::Query &query)
Set a new filter, updating all browsing data.
Query used to filter DB-All.e data.
Definition: query.h:16
Update update()
Merge new data into the explorer.
void add_cursor(dballe::CursorSummary &cur)
Merge summary data from a database.
void add_json(core::json::Stream &in)
Load the explorer contents from JSON.