libdballe  9.11
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 <vector>
8 #include <map>
9 #include <set>
10 
11 namespace dballe {
12 namespace db {
13 
14 template<typename Station>
16 {
17 protected:
19  std::shared_ptr<dballe::db::BaseSummary<Station>> _global_summary;
20 
23 
25  std::shared_ptr<dballe::db::BaseSummary<Station>> _active_summary;
26 
28  void commit();
29 
31  void update_active_summary();
32 
33 public:
34  class Update
35  {
36  protected:
37  BaseExplorer<Station>* explorer = nullptr;
38 
39  Update(BaseExplorer<Station>* explorer);
40 
41  public:
42  Update();
43  Update(const Update&) = delete;
44  Update(Update&&);
45  ~Update();
46 
47  Update& operator=(const Update&) = delete;
48  Update& operator=(Update&&);
49 
52 
55 
57  void add_json(core::json::Stream& in);
58 
60  template<typename OStation>
61  void add_explorer(const BaseExplorer<OStation>& explorer);
62 
64  void add_message(const dballe::Message& message, bool station_data=true, bool data=true);
65 
67  void add_messages(const std::vector<std::shared_ptr<dballe::Message>>& messages, bool station_data=true, bool data=true);
68 
69  void commit();
70 
71  friend class BaseExplorer<Station>;
72  };
73 
74  BaseExplorer();
75  BaseExplorer(const std::string& pathname);
76  BaseExplorer(const BaseExplorer&) = delete;
77  BaseExplorer(BaseExplorer&&) = delete;
78  ~BaseExplorer();
79  BaseExplorer& operator=(const BaseExplorer&) = delete;
80  BaseExplorer& operator=(BaseExplorer&&) = delete;
81 
83  const dballe::Query& get_filter() const;
84 
88  void set_filter(const dballe::Query& query);
89 
95  Update rebuild();
96 
100  Update update();
101 
104 
107 
109  void to_json(core::JSONWriter& writer) const;
110 };
111 
112 
117 
122 
123 extern template class BaseExplorer<dballe::Station>;
125 extern template class BaseExplorer<dballe::DBStation>;
127 
128 }
129 }
130 #endif
Definition: explorer.h:34
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:165
Station information.
Definition: types.h:793
void add_db(dballe::db::Transaction &tr)
Merge summary data from a database.
dballe::core::Query filter
Currently active filter.
Definition: explorer.h:22
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:97
Standard dballe::Query implementation.
Definition: core/query.h:34
std::shared_ptr< dballe::db::BaseSummary< Station > > _global_summary
Summary of the whole database.
Definition: explorer.h:19
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:15
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:151
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:44
std::shared_ptr< dballe::db::BaseSummary< Station > > _active_summary
Summary of active_filter.
Definition: explorer.h:25
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:14
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.