libdballe  7.6
query.h
1 #ifndef DBALLE_QUERY_H
2 #define DBALLE_QUERY_H
3 
4 #include <wreport/var.h>
5 #include <dballe/types.h>
6 #include <string>
7 #include <functional>
8 #include <memory>
9 
10 namespace dballe {
11 struct Record;
12 
14 struct Query
15 {
16  virtual ~Query() {}
17 
19  virtual void set_from_record(const dballe::Record& rec) = 0;
20 
22  virtual DatetimeRange get_datetimerange() const = 0;
23 
25  virtual void set_datetimerange(const DatetimeRange& dt) = 0;
26 
28  virtual LatRange get_latrange() const = 0;
29 
31  virtual void set_latrange(const LatRange& latrange) = 0;
32 
34  virtual LonRange get_lonrange() const = 0;
35 
37  virtual void set_lonrange(const LonRange& lonrange) = 0;
38 
40  virtual Level get_level() const = 0;
41 
43  virtual void set_level(const Level& level) = 0;
44 
46  virtual Trange get_trange() const = 0;
47 
49  virtual void set_trange(const Trange& trange) = 0;
50 
52  virtual void clear() = 0;
53 
60  virtual bool is_subquery(const Query& other) const = 0;
61 
66  virtual void foreach_key(std::function<void(const char*, wreport::Var&&)> dest) const = 0;
67 
69  virtual void print(FILE* out) const = 0;
70 
72  virtual std::unique_ptr<Query> clone() const = 0;
73 
75  static std::unique_ptr<Query> create();
76 
78  static std::unique_ptr<Query> from_record(const Record& rec);
79 };
80 
81 }
82 #endif
Common base types used by most of DB-All.e code.
Information on how a value has been sampled or computed with regards to time.
Definition: types.h:565
virtual LonRange get_lonrange() const =0
Get the range of longitudes to be matched.
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
static std::unique_ptr< Query > from_record(const Record &rec)
Create a new Query.
virtual void foreach_key(std::function< void(const char *, wreport::Var &&)> dest) const =0
Generate a sequence of key names and unique_ptr for all the contents of the query.
virtual void clear()=0
Clear the contents of the query, making it match all data.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
static std::unique_ptr< Query > create()
Create a new Query.
virtual void set_lonrange(const LonRange &lonrange)=0
Set the range of longitudes to be matched.
virtual void set_level(const Level &level)=0
Set the level to be matched.
virtual void print(FILE *out) const =0
Print the query contents to stderr.
Vertical level or layer.
Definition: types.h:515
virtual Trange get_trange() const =0
Get the time range to be matched.
Range of datetimes.
Definition: types.h:255
Range of latitudes.
Definition: types.h:390
virtual std::unique_ptr< Query > clone() const =0
Return a copy of this query.
virtual void set_from_record(const dballe::Record &rec)=0
Set the query values from the contents of a Record.
virtual Level get_level() const =0
Get the level to be matched.
Query used to filter DB-All.e data.
Definition: query.h:14
virtual void set_latrange(const LatRange &latrange)=0
Set the range of latitudes to be matched.
virtual void set_datetimerange(const DatetimeRange &dt)=0
Set the Datetime range for this query.
virtual DatetimeRange get_datetimerange() const =0
Get the Datetime bounds set in this query.
Range of longitudes.
Definition: types.h:464
virtual LatRange get_latrange() const =0
Get the range of latitudes to be matched.
virtual bool is_subquery(const Query &other) const =0
Return true if this query matches a subset of the given query.
virtual void set_trange(const Trange &trange)=0
Set the level to be matched.