libdballe  7.7
matcher.h
1 #ifndef DBALLE_CORE_MATCHER_H
2 #define DBALLE_CORE_MATCHER_H
3 
4 #include <dballe/types.h>
5 #include <memory>
6 
7 namespace dballe {
8 struct Record;
9 struct Query;
10 
11 namespace matcher {
12 
13 enum Result {
14  MATCH_YES, // Item matches
15  MATCH_NO, // Item does not match
16  MATCH_NA // Match not applicable to this item
17 };
18 
20 std::string result_format(Result res);
21 
22 }
23 
31 struct Matched
32 {
33  virtual ~Matched() {}
34 
40  virtual matcher::Result match_var_id(int val) const;
41 
47  virtual matcher::Result match_station_id(int val) const;
48 
54  virtual matcher::Result match_station_wmo(int block, int station=-1) const;
55 
57  virtual matcher::Result match_datetime(const DatetimeRange& range) const;
58 
65  virtual matcher::Result match_coords(const LatRange& latrange, const LonRange& lonrange) const;
66 
72  virtual matcher::Result match_rep_memo(const char* memo) const;
73 
80  static matcher::Result int_in_range(int val, int min, int max);
81 
85  static matcher::Result lon_in_range(int val, int min, int max);
86 };
87 
92 struct Matcher
93 {
94  virtual ~Matcher() {}
95 
96  virtual matcher::Result match(const Matched& item) const = 0;
97  virtual void to_record(dballe::Record& query) const = 0;
98 
99  static std::unique_ptr<Matcher> create(const dballe::Query& query);
100 };
101 
102 }
103 
104 /* vim:set ts=4 sw=4: */
105 #endif
Common base types used by most of DB-All.e code.
static matcher::Result int_in_range(int val, int min, int max)
Match if min <= val <= max.
Common interface for things that are matched.
Definition: matcher.h:31
Key/value store where keys are strings and values are wreport variables.
Definition: record.h:16
virtual matcher::Result match_datetime(const DatetimeRange &range) const
Match datetime.
Copyright (C) 2008–2010 ARPA-SIM urpsim@smr.arpa.emr.it
Definition: cmdline.h:17
virtual matcher::Result match_var_id(int val) const
Match variable ID.
virtual matcher::Result match_station_wmo(int block, int station=-1) const
Match station WMO code.
virtual matcher::Result match_station_id(int val) const
Match station ID.
static matcher::Result lon_in_range(int val, int min, int max)
Match if val is contained inside the given longitude range.
Range of datetimes.
Definition: types.h:255
Match DB-All.e objects using the same queries that can be made on DB-All.e databases.
Definition: matcher.h:92
virtual matcher::Result match_coords(const LatRange &latrange, const LonRange &lonrange) const
Match coordinates, with bounds in 1/100000 of degree.
virtual matcher::Result match_rep_memo(const char *memo) const
Match rep_memo.
Range of latitudes.
Definition: types.h:390
Query used to filter DB-All.e data.
Definition: query.h:14
Range of longitudes.
Definition: types.h:464