1 #ifndef DBALLE_DB_SUMMARY_MEMORY_H 2 #define DBALLE_DB_SUMMARY_MEMORY_H 4 #include <dballe/core/fwd.h> 5 #include <dballe/db/summary.h> 6 #include <dballe/db/summary_utils.h> 15 template<
typename Station>
22 std::filesystem::path path;
29 mutable size_t count = 0;
31 mutable bool dirty =
false;
33 void recompute_summaries()
const;
41 bool stations(std::function<
bool(
const Station&)>)
const override;
42 bool reports(std::function<
bool(
const std::string&)>)
const override;
43 bool levels(std::function<
bool(
const Level&)>)
const override;
44 bool tranges(std::function<
bool(
const Trange&)>)
const override;
48 Datetime datetime_max()
const override {
if (dirty) recompute_summaries();
return dtrange.
max; }
49 unsigned data_count()
const override {
if (dirty) recompute_summaries();
return count; }
61 std::shared_ptr<dballe::CursorSummary>
query_summary(
const Query& query)
const override;
63 bool iter(std::function<
bool(
const Station&,
const summary::VarDesc&,
const DatetimeRange&,
size_t)>)
const override;
64 bool iter_filtered(
const dballe::Query& query, std::function<
bool(
const Station&,
const summary::VarDesc&,
const DatetimeRange&,
size_t)>)
const override;
66 void clear()
override;
69 void add(
const Station& station,
const summary::VarDesc& vd,
const dballe::DatetimeRange& dtrange,
size_t count)
override;
72 void add_summary(
const BaseSummary<dballe::Station>& summary)
override;
75 void add_summary(
const BaseSummary<dballe::DBStation>& summary)
override;
83 void to_json(core::JSONWriter& writer)
const override;
86 void load_json(core::json::Stream& in)
override;
88 DBALLE_TEST_ONLY
void dump(FILE* out)
const override;
94 typedef BaseSummaryMemory<dballe::Station> SummaryMemory;
99 typedef BaseSummaryMemory<dballe::DBStation> DBSummaryMemory;
101 extern template class BaseSummaryMemory<dballe::Station>;
102 extern template class BaseSummaryMemory<dballe::DBStation>;
Station information.
Definition: types.h:793
bool iter(std::function< bool(const Station &, const summary::VarDesc &, const DatetimeRange &, size_t)>) const override
Iterate the contents of this summary. There is no guarantee on sorting order.
bool iter_filtered(const dballe::Query &query, std::function< bool(const Station &, const summary::VarDesc &, const DatetimeRange &, size_t)>) const override
Iterate the contents of this summary. There is no guarantee on sorting order.
High level objects for working with DB-All.e DB summaries.
Definition: summary_memory.h:16
void load_json(core::json::Stream &in) override
Load contents from JSON, merging with the current contents.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:686
void add_summary(const BaseSummary< dballe::Station > &summary) override
Merge the copy of another summary into this one.
Vertical level or layer.
Definition: types.h:624
Range of datetimes.
Definition: types.h:294
void add(const Station &station, const summary::VarDesc &vd, const dballe::DatetimeRange &dtrange, size_t count) override
Add an entry to the summary.
Datetime max
Upper bound of the range.
Definition: types.h:299
Datetime datetime_min() const override
Recompute reports, levels, tranges, and varcodes.
Definition: summary_memory.h:47
Datetime min
Lower bound of the range.
Definition: types.h:297
void to_json(core::JSONWriter &writer) const override
Serialize to JSON.
High level objects for working with DB-All.e DB summaries.
Definition: summary.h:44
Date and time.
Definition: types.h:164
std::shared_ptr< dballe::CursorSummary > query_summary(const Query &query) const override
Query the contents of the summary.
void commit() override
Write changes to disk.
Index of all stations known to a summary.
Definition: summary_utils.h:122
void clear() override
Completely empty the summary.
Query used to filter DB-All.e data.
Definition: query.h:14
void add_filtered(const BaseSummary< Station > &summary, const dballe::Query &query) override
Merge the copy of another summary into this one.