libdballe  8.6
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:
20 
23 
26 
28  void update_active_summary();
29 
30 public:
31  class Update
32  {
33  protected:
34  BaseExplorer<Station>* explorer = nullptr;
35 
36  Update(BaseExplorer<Station>* explorer);
37 
38  public:
39  Update();
40  Update(const Update&) = delete;
41  Update(Update&&);
42  ~Update();
43 
44  Update& operator=(const Update&) = delete;
45  Update& operator=(Update&&);
46 
49 
52 
54  void add_json(core::json::Stream& in);
55 
57  template<typename OStation>
58  void add_explorer(const BaseExplorer<OStation>& explorer);
59 
61  void add_message(const dballe::Message& message);
62 
64  void add_messages(const std::vector<std::shared_ptr<dballe::Message>>& messages);
65 
66  void commit();
67 
68  friend class BaseExplorer<Station>;
69  };
70 
71  BaseExplorer();
72  BaseExplorer(const BaseExplorer&) = delete;
73  BaseExplorer(BaseExplorer&&) = delete;
74  ~BaseExplorer();
75  BaseExplorer& operator=(const BaseExplorer&) = delete;
76  BaseExplorer& operator=(BaseExplorer&&) = delete;
77 
79  const dballe::Query& get_filter() const;
80 
84  void set_filter(const dballe::Query& query);
85 
91  Update rebuild();
92 
96  Update update();
97 
100 
103 
105  void to_json(core::JSONWriter& writer) const;
106 };
107 
108 
113 
118 
119 extern template class BaseExplorer<dballe::Station>;
121 extern template class BaseExplorer<dballe::DBStation>;
123 
124 }
125 }
126 #endif
dballe::db::BaseExplorer::get_filter
const dballe::Query & get_filter() const
Get the current filter.
dballe::db::BaseExplorer::to_json
void to_json(core::JSONWriter &writer) const
Export the explorer to JSON.
dballe::db::BaseExplorer::Update::add_db
void add_db(dballe::db::Transaction &tr)
Merge summary data from a database.
dballe::CursorSummary
Cursor iterating over summary entries.
Definition: cursor.h:97
dballe::Message
A bulletin that has been decoded and physically interpreted.
Definition: message.h:28
dballe::db::BaseExplorer::_active_summary
dballe::db::BaseSummary< Station > * _active_summary
Summary of active_filter.
Definition: explorer.h:25
dballe::db::BaseExplorer::Update::add_messages
void add_messages(const std::vector< std::shared_ptr< dballe::Message >> &messages)
Merge the contents of a vector of messages.
dballe::db::BaseExplorer::update_active_summary
void update_active_summary()
Regenerate _active_summary based on filter.
dballe::Station
Station information.
Definition: types.h:793
dballe::db::BaseExplorer::active_summary
const dballe::db::BaseSummary< Station > & active_summary() const
Get a reference to the summary for the current filter.
dballe::db::BaseExplorer::Update::add_cursor
void add_cursor(dballe::CursorSummary &cur)
Merge summary data from a database.
dballe::db::BaseExplorer::_global_summary
dballe::db::BaseSummary< Station > * _global_summary
Summary of the whole database.
Definition: explorer.h:19
dballe::db::BaseExplorer::Update::add_explorer
void add_explorer(const BaseExplorer< OStation > &explorer)
Merge the contents of another explorer into this one.
dballe::db::BaseExplorer::Update::add_json
void add_json(core::json::Stream &in)
Load the explorer contents from JSON.
dballe::db::BaseExplorer::Update::add_message
void add_message(const dballe::Message &message)
Merge the contents of a message.
dballe::core::json::Stream
Definition: json.h:165
dballe::db::BaseExplorer::update
Update update()
Merge new data into the explorer.
dballe::db::BaseExplorer::set_filter
void set_filter(const dballe::Query &query)
Set a new filter, updating all browsing data.
db.h
dballe::db::Transaction
Definition: db/db.h:151
dballe::db::BaseSummary
High level objects for working with DB-All.e DB summaries.
Definition: summary.h:285
dballe::db::BaseExplorer::Update
Definition: explorer.h:31
dballe::db::BaseExplorer::rebuild
Update rebuild()
Throw away all cached data and rebuild the explorer from scratch.
dballe::core::JSONWriter
JSON serializer.
Definition: json.h:29
dballe::db::BaseExplorer::filter
dballe::core::Query filter
Currently active filter.
Definition: explorer.h:22
dballe::core::Query
Standard dballe::Query implementation.
Definition: core/query.h:31
dballe::Query
Query used to filter DB-All.e data.
Definition: query.h:14
dballe::db::BaseExplorer
Definition: explorer.h:15
dballe::db::BaseExplorer::global_summary
const dballe::db::BaseSummary< Station > & global_summary() const
Get a reference to the global summary.