libdballe 9.6
matcher.h
1#ifndef DBALLE_CORE_MATCHER_H
2#define DBALLE_CORE_MATCHER_H
3
4#include <dballe/types.h>
5#include <dballe/core/fwd.h>
6#include <memory>
7
8namespace dballe {
9namespace matcher {
10
11enum Result {
12 MATCH_YES, // Item matches
13 MATCH_NO, // Item does not match
14 MATCH_NA // Match not applicable to this item
15};
16
18std::string result_format(Result res);
19
20}
21
29struct Matched
30{
31 virtual ~Matched() {}
32
38 virtual matcher::Result match_var_id(int val) const;
39
45 virtual matcher::Result match_station_id(int val) const;
46
52 virtual matcher::Result match_station_wmo(int block, int station=-1) const;
53
55 virtual matcher::Result match_datetime(const DatetimeRange& range) const;
56
63 virtual matcher::Result match_coords(const LatRange& latrange, const LonRange& lonrange) const;
64
70 virtual matcher::Result match_rep_memo(const char* memo) const;
71
78 static matcher::Result int_in_range(int val, int min, int max);
79
83 static matcher::Result lon_in_range(int val, int min, int max);
84};
85
90struct Matcher
91{
92 virtual ~Matcher() {}
93
94 virtual matcher::Result match(const Matched& item) const = 0;
95 virtual void to_query(dballe::core::Query& query) const = 0;
96
97 static std::unique_ptr<Matcher> create(const dballe::Query& query);
98};
99
100}
101
102#endif
Query used to filter DB-All.e data.
Definition: query.h:15
Range of datetimes.
Definition: types.h:295
Range of latitudes.
Definition: types.h:468
Range of longitudes.
Definition: types.h:552
Common interface for things that are matched.
Definition: matcher.h:30
virtual matcher::Result match_station_wmo(int block, int station=-1) const
Match station WMO code.
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_datetime(const DatetimeRange &range) const
Match datetime.
virtual matcher::Result match_var_id(int val) const
Match variable ID.
virtual matcher::Result match_rep_memo(const char *memo) const
Match rep_memo.
static matcher::Result lon_in_range(int val, int min, int max)
Match if val is contained inside the given longitude range.
static matcher::Result int_in_range(int val, int min, int max)
Match if min <= val <= max.
virtual matcher::Result match_station_id(int val) const
Match station ID.
Match DB-All.e objects using the same queries that can be made on DB-All.e databases.
Definition: matcher.h:91
Standard dballe::Query implementation.
Definition: core/query.h:35
Common base types used by most of DB-All.e code.