libdballe 9.6
message.h
1#ifndef DBALLE_MESSAGE_H
2#define DBALLE_MESSAGE_H
3
4#include <dballe/fwd.h>
5#include <dballe/types.h>
6#include <wreport/varinfo.h>
7#include <memory>
8#include <iosfwd>
9
10namespace wreport {
11struct Var;
12}
13
14namespace dballe {
15
28class Message : public std::enable_shared_from_this<Message>
29{
30public:
31 virtual ~Message();
32
34 virtual MessageType get_type() const = 0;
35
37 virtual Datetime get_datetime() const = 0;
38
40 virtual Coords get_coords() const = 0;
41
43 virtual Ident get_ident() const = 0;
44
46 virtual std::string get_report() const = 0;
47
49 virtual std::shared_ptr<Message> clone() const = 0;
50
57 const wreport::Var* get(const Level& lev, const Trange& tr, wreport::Varcode code) const;
58
65 const wreport::Var* get(const char* shortcut) const;
66
73 const wreport::Var* get(const std::string& shortcut) const;
74
88 void set(const Level& lev, const Trange& tr, wreport::Varcode code, const wreport::Var& var);
89
100 void set(const Level& lev, const Trange& tr, const wreport::Var& var);
101
114 void set(const Level& lev, const Trange& tr, std::unique_ptr<wreport::Var> var);
115
126 void set(const char* shortcut, std::unique_ptr<wreport::Var> var);
127
137 void set(const char* shortcut, const wreport::Var& var);
138
142 virtual bool foreach_var(std::function<bool(const Level&, const Trange&, const wreport::Var&)>) const = 0;
143
155 virtual std::shared_ptr<CursorStation> query_stations(const Query& query) const = 0;
156
165 virtual std::shared_ptr<CursorStationData> query_station_data(const Query& query) const = 0;
166
175 virtual std::shared_ptr<CursorData> query_data(const Query& query) const = 0;
176
178 virtual void print(FILE* out) const = 0;
179
189 virtual unsigned diff(const Message& msg) const = 0;
190
194 static std::shared_ptr<Message> create(MessageType type);
195
196protected:
198 virtual const wreport::Var* get_impl(const Level& lev, const Trange& tr, wreport::Varcode code) const = 0;
199
201 virtual void set_impl(const Level& lev, const Trange& tr, std::unique_ptr<wreport::Var> var) = 0;
202};
203
204
213const char* format_message_type(MessageType type);
214
215
217std::ostream& operator<<(std::ostream&, const dballe::MessageType&);
218
219}
220#endif
A station identifier, that can be any string (including the empty string) or a missing value.
Definition: types.h:748
A bulletin that has been decoded and physically interpreted.
Definition: message.h:29
void set(const Level &lev, const Trange &tr, const wreport::Var &var)
Add or replace a value.
virtual void print(FILE *out) const =0
Print all the contents of this message to an output stream.
virtual std::shared_ptr< Message > clone() const =0
Return a copy of this message.
virtual unsigned diff(const Message &msg) const =0
Compute the differences between two Messages.
void set(const Level &lev, const Trange &tr, std::unique_ptr< wreport::Var > var)
Add or replace a value, taking ownership of the source variable without copying it.
void set(const char *shortcut, std::unique_ptr< wreport::Var > var)
Add or replace a value, taking ownership of the source variable without copying it.
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.
virtual MessageType get_type() const =0
Return the type of the data in the message.
virtual Datetime get_datetime() const =0
Get the reference Datetime for this message.
static std::shared_ptr< Message > create(MessageType type)
Create a new empty message.
virtual bool foreach_var(std::function< bool(const Level &, const Trange &, const wreport::Var &)>) const =0
Iterate the contents of the message.
virtual void set_impl(const Level &lev, const Trange &tr, std::unique_ptr< wreport::Var > var)=0
Implementation of set(const Level& const Trange&, std::unique_ptr<wreport::Var>)
void set(const char *shortcut, const wreport::Var &var)
Add or replace a value.
virtual const wreport::Var * get_impl(const Level &lev, const Trange &tr, wreport::Varcode code) const =0
Implementation of get(const Level&, const Trange&, wreport::Varcode)
virtual Ident get_ident() const =0
Get the station identifier for this message.
const wreport::Var * get(const std::string &shortcut) const
Get a variable given its shortcut name.
virtual std::shared_ptr< CursorStationData > query_station_data(const Query &query) const =0
Query the station variables in the message.
virtual Coords get_coords() const =0
Get the reference coordinates for this message.
void set(const Level &lev, const Trange &tr, wreport::Varcode code, const wreport::Var &var)
Add or replace a value.
virtual std::string get_report() const =0
Get the report for this message.
const wreport::Var * get(const char *shortcut) const
Get a variable given its shortcut name.
virtual std::shared_ptr< CursorStation > query_stations(const Query &query) const =0
Return a Cursor to access the station information in the message.
virtual std::shared_ptr< CursorData > query_data(const Query &query) const =0
Query the variables in the message.
Query used to filter DB-All.e data.
Definition: query.h:15
uint16_t Varcode
Coordinates.
Definition: types.h:369
Date and time.
Definition: types.h:165
Vertical level or layer.
Definition: types.h:625
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:687
Common base types used by most of DB-All.e code.