1#ifndef DBALLE_DB_SUMMARY_H
2#define DBALLE_DB_SUMMARY_H
5#include <dballe/core/fwd.h>
21 wreport::Varcode varcode;
26 wreport::Varcode varcode)
27 : level(level), trange(trange), varcode(varcode)
31 VarDesc(
const VarDesc&) =
default;
33 bool operator==(
const VarDesc& o)
const
35 return std::tie(level, trange, varcode) ==
36 std::tie(o.level, o.trange, o.varcode);
38 bool operator!=(
const VarDesc& o)
const
40 return std::tie(level, trange, varcode) !=
41 std::tie(o.level, o.trange, o.varcode);
43 bool operator<(
const VarDesc& o)
const
45 return std::tie(level, trange, varcode) <
46 std::tie(o.level, o.trange, o.varcode);
48 bool operator<=(
const VarDesc& o)
const
50 return std::tie(level, trange, varcode) <=
51 std::tie(o.level, o.trange, o.varcode);
53 bool operator>(
const VarDesc& o)
const
55 return std::tie(level, trange, varcode) >
56 std::tie(o.level, o.trange, o.varcode);
58 bool operator>=(
const VarDesc& o)
const
60 return std::tie(level, trange, varcode) >=
61 std::tie(o.level, o.trange, o.varcode);
70template <
typename Station>
class BaseSummary
76 BaseSummary(
const BaseSummary&) =
delete;
77 BaseSummary(BaseSummary&&) =
delete;
78 BaseSummary& operator=(
const BaseSummary&) =
delete;
79 BaseSummary& operator=(BaseSummary&&) =
delete;
80 virtual ~BaseSummary();
84 virtual bool stations(std::function<
bool(
const Station&)>)
const = 0;
85 virtual bool reports(std::function<
bool(
const std::string&)>)
const = 0;
86 virtual bool levels(std::function<
bool(
const Level&)>)
const = 0;
87 virtual bool tranges(std::function<
bool(
const Trange&)>)
const = 0;
89 varcodes(std::function<
bool(
const wreport::Varcode&)>)
const = 0;
98 virtual Datetime datetime_max()
const = 0;
99 virtual unsigned data_count()
const = 0;
111 virtual std::shared_ptr<dballe::CursorSummary>
126 bool station_data =
true,
bool data =
true);
130 add_messages(
const std::vector<std::shared_ptr<dballe::Message>>& messages,
131 bool station_data =
true,
bool data =
true);
134 virtual void add_summary(
const BaseSummary<dballe::Station>& summary);
137 virtual void add_summary(
const BaseSummary<dballe::DBStation>& summary);
165 DBALLE_TEST_ONLY
virtual void dump(FILE* out)
const = 0;
Cursor iterating over summary entries.
Definition cursor.h:99
A bulletin that has been decoded and physically interpreted.
Definition message.h:29
Query used to filter DB-All.e data.
Definition query.h:17
JSON serializer.
Definition json.h:30
High level objects for working with DB-All.e DB summaries.
Definition summary.h:71
virtual std::shared_ptr< dballe::CursorSummary > query_summary(const Query &query) const
Query the contents of the summary.
virtual Datetime datetime_min() const =0
Recompute reports, levels, tranges, and varcodes.
virtual bool iter_filtered(const dballe::Query &query, std::function< bool(const Station &, const summary::VarDesc &, const DatetimeRange &, size_t)>) const =0
Iterate the contents of this summary.
virtual void to_json(core::JSONWriter &writer) const =0
Serialize to JSON.
virtual void add_cursor(const dballe::CursorSummary &cur)
Add an entry to the summary taken from the current status of cur.
virtual void add_messages(const std::vector< std::shared_ptr< dballe::Message > > &messages, bool station_data=true, bool data=true)
Add the contents of a Messages.
virtual void add_summary(const BaseSummary< dballe::DBStation > &summary)
Merge the copy of another summary into this one.
virtual void add_message(const dballe::Message &message, bool station_data=true, bool data=true)
Add the contents of a Message.
virtual void load_json(core::json::Stream &in)
Load contents from JSON, merging with the current contents.
virtual void add_summary(const BaseSummary< dballe::Station > &summary)
Merge the copy of another summary into this one.
virtual void clear()=0
Completely empty the summary.
virtual bool iter(std::function< bool(const Station &, const summary::VarDesc &, const DatetimeRange &, size_t)>) const =0
Iterate the contents of this summary.
virtual void add(const Station &station, const summary::VarDesc &vd, const dballe::DatetimeRange &dtrange, size_t count)=0
Add an entry to the summary.
virtual void add_filtered(const BaseSummary< Station > &summary, const dballe::Query &query)
Merge the copy of another summary into this one.
virtual void commit()=0
Write changes to disk.
Range of datetimes.
Definition types.h:297
Date and time.
Definition types.h:164
Vertical level or layer.
Definition types.h:625
Station information.
Definition types.h:879
Information on how a value has been sampled or computed with regards to time.
Definition types.h:689
Description of a variable, independent of where and when it was measured.
Definition summary.h:18
Common base types used by most of DB-All.e code.