libdballe  9.11
core/data.h
1 #ifndef DBALLE_CORE_DATA_H
2 #define DBALLE_CORE_DATA_H
3 
4 #include <dballe/data.h>
5 #include <dballe/values.h>
6 
7 namespace dballe {
8 namespace core {
9 
17 class Data : public dballe::Data
18 {
19 public:
20  DBStation station;
21  Datetime datetime;
22  Level level;
23  Trange trange;
24  DBValues values;
25 
26 public:
27  Data() = default;
28  Data(const Data& rec) = default;
29  Data(Data&& rec) = default;
30  ~Data();
31 
32  Data& operator=(const Data& rec) = default;
33  Data& operator=(Data&& rec) = default;
34 
35  bool operator==(const dballe::Data& rec) const override;
36  bool operator!=(const dballe::Data& rec) const override;
37 
46  void validate();
47 
48  void clear() override;
49  void clear_vars() override;
50  void clear_ids() override;
51 #if 0
52  void set_datetime(const Datetime& dt) override;
53  void set_datetimerange(const DatetimeRange& range) override;
54  void set_coords(const Coords& c) override;
55  void set_latrange(const LatRange& lr) override;
56  void set_lonrange(const LonRange& lr) override;
57  void set_level(const Level& lev) override;
58  void set_trange(const Trange& tr) override;
59  void set_var(const wreport::Var& var) override;
60  void set_var_acquire(std::unique_ptr<wreport::Var>&& var) override;
61  void set_station(const Station& s) override;
62  void set_dbstation(const DBStation& s) override;
63 #endif
64  void print(FILE* out) const override;
65 
71  static const Data& downcast(const dballe::Data& data);
72 
78  static Data& downcast(dballe::Data& data);
79 
80 #if 0
81  Coords get_coords() const override;
82  Ident get_ident() const override;
83  Level get_level() const override;
84  Trange get_trange() const override;
85  Datetime get_datetime() const override;
86  DatetimeRange get_datetimerange() const override;
87  Station get_station() const override;
88  DBStation get_dbstation() const override;
89  const wreport::Var* get_var(wreport::Varcode code) const override;
90 #endif
91 
104  void set_from_string(const char* str);
105 
113  void set_from_test_string(const std::string& s);
114 
118  std::string to_string() const;
119 
120 protected:
121  void setf(const char* key, unsigned len, const char* val);
122 };
123 
124 }
125 }
126 #endif
127 
bool operator==(const dballe::Data &rec) const override
Check if two records are the same.
void print(FILE *out) const override
Print the contents of this record to the given stream.
Station information.
Definition: types.h:793
Coordinates.
Definition: types.h:368
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:686
static const Data & downcast(const dballe::Data &data)
Return a reference to record downcasted as core::Record.
Definition: cmdline.h:18
Collection of DBValue objects, indexed by wreport::Varcode.
Definition: values.h:191
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
uint16_t Varcode
Range of datetimes.
Definition: types.h:294
Key/value store where keys are strings and values are wreport variables.
Definition: data.h:17
Range of latitudes.
Definition: types.h:467
Date and time.
Definition: types.h:164
void clear() override
Remove all contents from the record.
void validate()
Check the data fields for consistency, and fill in missing values:
Holds data for database I/O.
Definition: core/data.h:17
void set_from_test_string(const std::string &s)
Set the Data from a ", "-separated string of assignments.
Definition: types.h:850
void clear_ids() override
Unset all database IDs in station and values.
std::string to_string() const
Encode in a one-liner of comma-separated assignments.
Range of longitudes.
Definition: types.h:551
Structures used as input to database insert functions.
void clear_vars() override
Remove all Bxxyyy keys from the record, leaving the rest intact.
bool operator!=(const dballe::Data &rec) const override
Check if two records differ.
void set_from_string(const char *str)
Set a value according to an assignment encoded in a string.