libdballe  7.29
core/query.h
1 #ifndef DBALLE_CORE_QUERY_H
2 #define DBALLE_CORE_QUERY_H
3 
4 #include <dballe/query.h>
5 #include <dballe/core/defs.h>
6 #include <dballe/record.h>
7 #include <wreport/varinfo.h>
8 #include <set>
9 
15 #define DBA_DB_MODIFIER_BEST (1 << 0)
16 
17 #define DBA_DB_MODIFIER_UNSORTED (1 << 5)
18 
19 #define DBA_DB_MODIFIER_SORT_FOR_EXPORT (1 << 7)
20 #define DBA_DB_MODIFIER_SUMMARY_DETAILS (1 << 8)
22 
23 namespace dballe {
24 namespace core {
25 
26 struct JSONWriter;
27 
29 struct Query : public dballe::Query
30 {
31  static const uint32_t WANT_MISSING_IDENT = (1 << 0);
32  static const uint32_t WANT_MISSING_LTYPE1 = (1 << 1);
33  static const uint32_t WANT_MISSING_L1 = (1 << 2);
34  static const uint32_t WANT_MISSING_LTYPE2 = (1 << 3);
35  static const uint32_t WANT_MISSING_L2 = (1 << 4);
36  static const uint32_t WANT_MISSING_PIND = (1 << 5);
37  static const uint32_t WANT_MISSING_P1 = (1 << 6);
38  static const uint32_t WANT_MISSING_P2 = (1 << 7);
39 
45  uint32_t want_missing = 0;
46  int ana_id = MISSING_INT;
47  int prio_min = MISSING_INT;
48  int prio_max = MISSING_INT;
49  std::string rep_memo;
50  int mobile = MISSING_INT;
51  Ident ident;
52  LatRange latrange;
53  LonRange lonrange;
54  DatetimeRange datetime;
55  Level level;
56  Trange trange;
57  std::set<wreport::Varcode> varcodes;
58  std::string query;
59  std::string ana_filter;
60  std::string data_filter;
61  std::string attr_filter;
62  int limit = MISSING_INT;
63  int block = MISSING_INT;
64  int station = MISSING_INT;
65 
66  std::unique_ptr<dballe::Query> clone() const override;
67 
68  unsigned get_modifiers() const;
69 
70  DatetimeRange get_datetimerange() const override { return datetime; }
71  void set_datetimerange(const DatetimeRange& dt) override { datetime = dt; }
72  LatRange get_latrange() const override { return latrange; }
73  void set_latrange(const LatRange& lr) override { latrange = lr; }
74  LonRange get_lonrange() const override { return lonrange; }
75  void set_lonrange(const LonRange& lr) override { lonrange = lr; }
76  Level get_level() const override { return level; }
77  void set_level(const Level& level) override { this->level = level; }
78  Trange get_trange() const override { return trange; }
79  void set_trange(const Trange& trange) override { this->trange = trange; }
80 
81  void clear() override;
82 
83  void set_from_record(const dballe::Record& rec) override;
84 
92  void set_from_test_string(const std::string& s);
93 
100  bool is_subquery(const dballe::Query& other) const override;
101 
106  void foreach_key(std::function<void(const char*, wreport::Var&&)> dest) const override;
107 
109  void print(FILE* out) const override;
110 
112  void serialize(JSONWriter& out) const;
113 
118  static unsigned parse_modifiers(const dballe::Record& rec);
119 
124  static unsigned parse_modifiers(const char* str);
125 
131  static const Query& downcast(const dballe::Query& query);
132 
138  static Query& downcast(dballe::Query& query);
139 };
140 
141 }
142 }
143 #endif
void set_level(const Level &level) override
Set the level to be matched.
Definition: core/query.h:77
void foreach_key(std::function< void(const char *, wreport::Var &&)> dest) const override
Generate a sequence of dba_keyword and Var for all contents of the query that can be represented in a...
LatRange get_latrange() const override
Get the range of latitudes to be matched.
Definition: core/query.h:72
DatetimeRange get_datetimerange() const override
Get the Datetime bounds set in this query.
Definition: core/query.h:70
uint32_t want_missing
Set a bit a 1 with WANT_MISSING_* constants to specify that the query wants results in which the corr...
Definition: core/query.h:45
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:587
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:17
Standard dballe::Query implementation.
Definition: core/query.h:29
static const Query & downcast(const dballe::Query &query)
Return a reference to query downcasted as core::Query.
Vertical level or layer.
Definition: types.h:532
void clear() override
Clear the contents of the query, making it match all data.
A station identifier, that can be any string (including the empty string) or a missing value...
Definition: core/defs.h:19
Range of datetimes.
Definition: types.h:272
Range of latitudes.
Definition: types.h:407
Trange get_trange() const override
Get the time range to be matched.
Definition: core/query.h:78
void print(FILE *out) const override
Print the query contents to stderr.
void set_datetimerange(const DatetimeRange &dt) override
Set the Datetime range for this query.
Definition: core/query.h:71
void set_latrange(const LatRange &lr) override
Set the range of latitudes to be matched.
Definition: core/query.h:73
void serialize(JSONWriter &out) const
Send the contents to a JSONWriter.
Query used to filter DB-All.e data.
Definition: query.h:14
Level get_level() const override
Get the level to be matched.
Definition: core/query.h:76
JSON serializer.
Definition: json.h:23
std::unique_ptr< dballe::Query > clone() const override
Return a copy of this query.
Range of longitudes.
Definition: types.h:481
Common definitions.
void set_trange(const Trange &trange) override
Set the level to be matched.
Definition: core/query.h:79
void set_from_test_string(const std::string &s)
Set a record from a &quot;, &quot;-separated string of assignments.
void set_from_record(const dballe::Record &rec) override
Set the query values from the contents of a Record.
bool is_subquery(const dballe::Query &other) const override
Return true if this query matches a subset of the given query.
LonRange get_lonrange() const override
Get the range of longitudes to be matched.
Definition: core/query.h:74
static unsigned parse_modifiers(const dballe::Record &rec)
Parse the query=* modifiers specification inside the record, returning the ORed flags.
void set_lonrange(const LonRange &lr) override
Set the range of longitudes to be matched.
Definition: core/query.h:75