4#include <dballe/message.h>
6#include <dballe/core/fwd.h>
7#include <dballe/msg/fwd.h>
9#include <dballe/core/matcher.h>
11#include <dballe/importer.h>
12#include <dballe/exporter.h>
33 using dballe::ImporterOptions::operator==;
34 using dballe::ImporterOptions::operator!=;
45 using dballe::ExporterOptions::operator==;
46 using dballe::ExporterOptions::operator!=;
50typedef std::vector<std::shared_ptr<dballe::Message>> Messages;
64void messages_to_csv(
const Messages& msgs,
CSVWriter& out);
75unsigned messages_diff(
const Messages& msgs1,
const Messages& msgs2);
78void messages_print(
const Messages& msgs, FILE* out);
84 typedef std::vector<msg::Context>::const_iterator const_iterator;
85 typedef std::vector<msg::Context>::iterator iterator;
86 typedef std::vector<msg::Context>::const_reverse_iterator const_reverse_iterator;
87 typedef std::vector<msg::Context>::reverse_iterator reverse_iterator;
90 std::vector<msg::Context> m_contexts;
92 iterator insert_new(
const Level& level,
const Trange& trange);
101 const_iterator begin()
const {
return m_contexts.begin(); }
102 const_iterator end()
const {
return m_contexts.end(); }
103 iterator begin() {
return m_contexts.begin(); }
104 iterator end() {
return m_contexts.end(); }
105 const_reverse_iterator rbegin()
const {
return m_contexts.rbegin(); }
106 const_reverse_iterator rend()
const {
return m_contexts.rend(); }
107 const_iterator cbegin()
const {
return m_contexts.cbegin(); }
108 const_iterator cend()
const {
return m_contexts.cend(); }
110 const_iterator find(
const Level& level,
const Trange& trange)
const;
111 iterator find(
const Level& level,
const Trange& trange);
113 iterator obtain(
const Level& level,
const Trange& trange);
114 bool drop(
const Level& level,
const Trange& trange);
116 size_t size()
const {
return m_contexts.size(); }
117 bool empty()
const {
return m_contexts.empty(); }
118 void clear() {
return m_contexts.clear(); }
119 void reserve(
typename std::vector<Value>::size_type size) { m_contexts.reserve(size); }
120 iterator erase(iterator pos) {
return m_contexts.erase(pos); }
153 MessageType
type = MessageType::GENERIC;
157 static std::shared_ptr<Message> create();
178 static std::shared_ptr<Message>
downcast(std::shared_ptr<dballe::Message> o);
180 std::shared_ptr<dballe::Message>
clone()
const override;
187 void print(FILE* out)
const override;
328 std::shared_ptr<dballe::CursorData> query_station_and_data(
const Query& query)
const;
343#include <dballe/msg/msg-extravars.h>
371 const std::vector<std::shared_ptr<dballe::Message>>& m;
373 MatchedMessages(
const std::vector<std::shared_ptr<dballe::Message>>& m);
Options to control message export.
Definition: exporter.h:25
A station identifier, that can be any string (including the empty string) or a missing value.
Definition: types.h:748
Options to control message import.
Definition: importer.h:25
A bulletin that has been decoded and physically interpreted.
Definition: message.h:29
const wreport::Var * get(const Level &lev, const Trange &tr, wreport::Varcode code) const
Get a variable given its code, level and time range information.
void set(const Level &lev, const Trange &tr, wreport::Varcode code, const wreport::Var &var)
Add or replace a value.
Query used to filter DB-All.e data.
Definition: query.h:15
Storage for related physical data.
Definition: msg.h:131
static const Message & downcast(const dballe::Message &o)
Return a reference to o downcasted as an impl::Message.
static const char * repmemo_from_type(MessageType type)
Get the report code corresponding to the given message source type.
MessageType type
Source of the data.
Definition: msg.h:153
void clear()
Reset the messages as if it was just created.
void to_csv(CSVWriter &out) const
Output in CSV format.
void set_datetime(const Datetime &dt)
Shortcut to set year...second variables in a single call.
wreport::Var * edit(wreport::Varcode code, const Level &lev, const Trange &tr)
Find a variable given its description.
bool foreach_var(std::function< bool(const Level &, const Trange &, const wreport::Var &)>) const override
Iterate the contents of the message.
msg::Context * edit_context(const Level &lev, const Trange &tr)
Find a msg::Context given its description.
msg::Context & obtain_context(const Level &lev, const Trange &tr)
Find a msg::Context given its description, creating it if it does not exist.
unsigned diff(const dballe::Message &msg) const override
Compute the differences between two Messages.
const wreport::Var * get(const Shortcut &shortcut) const
Find a datum given its shortcut.
std::string get_report() const override
Get the report for this message.
void set_impl(const Level &lev, const Trange &tr, std::unique_ptr< wreport::Var > var) override
Implementation of set(const Level& const Trange&, std::unique_ptr<wreport::Var>)
bool remove_context(const Level &lev, const Trange &tr)
Remove a context from the message.
Coords get_coords() const override
Get the reference coordinates for this message.
int find_index(const Level &lev, const Trange &tr) const
Return the index of the given context, or -1 if it was not found.
static std::shared_ptr< Message > downcast(std::shared_ptr< dballe::Message > o)
Returns a pointer to o downcasted as an impl::Message.
const Values & find_station_context() const
Find the station info context.
void print(FILE *out) const override
Print all the contents of this message to an output stream.
MessageType get_type() const override
Return the type of the data in the message.
Definition: msg.h:185
std::shared_ptr< dballe::CursorData > query_data(const Query &query) const override
Query the variables in the message.
std::shared_ptr< dballe::CursorStationData > query_station_data(const Query &query) const override
Query the station variables in the message.
const msg::Context * find_context(const Level &lev, const Trange &tr) const
Find a msg::Context given its description.
const wreport::Var * get_impl(const Level &lev, const Trange &tr, wreport::Varcode code) const override
Implementation of get(const Level&, const Trange&, wreport::Varcode)
static void csv_header(CSVWriter &out)
Output the CSV header.
void sounding_pack_levels()
Remove the sounding significance from the level descriptions and pack together the data at the same p...
static MessageType type_from_repmemo(const char *repmemo)
Get the message source type corresponding to the given report code.
void set(const Shortcut &shortcut, const wreport::Var &var)
Add or replace a value.
std::shared_ptr< dballe::CursorStation > query_stations(const Query &query) const override
Return a Cursor to access the station information in the message.
static Message & downcast(dballe::Message &o)
Return a reference to o downcasted as an impl::Message.
Datetime get_datetime() const override
Get the reference Datetime for this message.
std::shared_ptr< dballe::Message > clone() const override
Return a copy of this message.
Ident get_ident() const override
Get the station identifier for this message.
bool from_csv(CSVReader &in)
Read data from a CSV input.
Store an array of physical data all on the same level.
Definition: context.h:24
Sorted storage for all the dba_msg_datum present on one level.
Coordinates.
Definition: types.h:369
Range of datetimes.
Definition: types.h:295
Date and time.
Definition: types.h:165
Range of latitudes.
Definition: types.h:468
Vertical level or layer.
Definition: types.h:625
Range of longitudes.
Definition: types.h:552
Common interface for things that are matched.
Definition: matcher.h:30
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:687
Collection of Value objects, indexed by wreport::Varcode.
Definition: values.h:177
ExporterOptions with default constructor usable.
Definition: msg.h:39
ImporterOptions with default constructor usable.
Definition: msg.h:26
Match adapter for Messages.
Definition: msg.h:370
matcher::Result match_datetime(const DatetimeRange &range) const override
Match datetime.
matcher::Result match_station_id(int val) const override
Match station ID.
matcher::Result match_coords(const LatRange &latrange, const LonRange &lonrange) const override
Match coordinates, with bounds in 1/100000 of degree.
matcher::Result match_rep_memo(const char *memo) const override
Match rep_memo.
matcher::Result match_var_id(int val) const override
Match variable ID.
matcher::Result match_station_wmo(int block, int station=-1) const override
Match station WMO code.
Match adapter for impl::Message.
Definition: msg.h:351
matcher::Result match_coords(const LatRange &latrange, const LonRange &lonrange) const override
Match coordinates, with bounds in 1/100000 of degree.
matcher::Result match_rep_memo(const char *memo) const override
Match rep_memo.
matcher::Result match_datetime(const DatetimeRange &range) const override
Match datetime.
matcher::Result match_station_wmo(int block, int station=-1) const override
Match station WMO code.
matcher::Result match_var_id(int val) const override
Match variable ID.
matcher::Result match_station_id(int val) const override
Match station ID.
Definition: shortcuts.h:12
Create wreport variables from the DB-All.e B table.