libdballe 9.6
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
7namespace dballe {
8namespace core {
9
17class Data : public dballe::Data
18{
19public:
20 DBStation station;
21 Datetime datetime;
22 Level level;
23 Trange trange;
24 DBValues values;
25
26public:
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
120protected:
121 void setf(const char* key, unsigned len, const char* val);
122};
123
124}
125}
126#endif
127
Key/value store where keys are strings and values are wreport variables.
Definition: data.h:18
A station identifier, that can be any string (including the empty string) or a missing value.
Definition: types.h:748
Holds data for database I/O.
Definition: core/data.h:18
bool operator!=(const dballe::Data &rec) const override
Check if two records differ.
std::string to_string() const
Encode in a one-liner of comma-separated assignments.
void validate()
Check the data fields for consistency, and fill in missing values:
void clear() override
Remove all contents from the record.
static const Data & downcast(const dballe::Data &data)
Return a reference to record downcasted as core::Record.
void set_from_test_string(const std::string &s)
Set the Data from a ", "-separated string of assignments.
bool operator==(const dballe::Data &rec) const override
Check if two records are the same.
void clear_ids() override
Unset all database IDs in station and values.
static Data & downcast(dballe::Data &data)
Return a reference to record downcasted as core::Record.
void clear_vars() override
Remove all Bxxyyy keys from the record, leaving the rest intact.
void set_from_string(const char *str)
Set a value according to an assignment encoded in a string.
void print(FILE *out) const override
Print the contents of this record to the given stream.
uint16_t Varcode
Coordinates.
Definition: types.h:369
Definition: types.h:851
Collection of DBValue objects, indexed by wreport::Varcode.
Definition: values.h:192
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
Station information.
Definition: types.h:794
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:687
Structures used as input to database insert functions.