libdballe  8.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 
10 namespace wreport {
11 struct Var;
12 }
13 
14 namespace dballe {
15 
28 class Message
29 {
30 public:
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::unique_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::unique_ptr<CursorStation> query_stations(const Query& query) const = 0;
156 
165  virtual std::unique_ptr<CursorStationData> query_station_data(const Query& query) const = 0;
166 
175  virtual std::unique_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::unique_ptr<Message> create(MessageType type);
195 
196 protected:
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 
213 const char* format_message_type(MessageType type);
214 
215 
217 std::ostream& operator<<(std::ostream&, const dballe::MessageType&);
218 
219 }
220 #endif
Common base types used by most of DB-All.e code.
Coordinates.
Definition: types.h:368
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:686
Definition: cmdline.h:18
Vertical level or layer.
Definition: types.h:624
A station identifier, that can be any string (including the empty string) or a missing value...
Definition: types.h:747
A bulletin that has been decoded and physically interpreted.
Definition: message.h:28
uint16_t Varcode
Date and time.
Definition: types.h:164
Query used to filter DB-All.e data.
Definition: query.h:14