libdballe 5.10
|
00001 /* 00002 * dballe/matcher - Local query match infrastructure 00003 * 00004 * Copyright (C) 2009--2010 ARPA-SIM <urpsim@smr.arpa.emr.it> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00019 * 00020 * Author: Enrico Zini <enrico@enricozini.com> 00021 */ 00022 00023 #ifndef DBALLE_CORE_MATCHER_H 00024 #define DBALLE_CORE_MATCHER_H 00025 00026 #include <memory> 00027 00028 namespace dballe { 00029 struct Record; 00030 00031 namespace matcher { 00032 00033 enum Result { 00034 MATCH_YES, // Item matches 00035 MATCH_NO, // Item does not match 00036 MATCH_NA // Match not applicable to this item 00037 }; 00038 00039 } 00040 00048 struct Matched 00049 { 00050 virtual ~Matched() {} 00051 00057 virtual matcher::Result match_var_id(int val) const; 00058 00064 virtual matcher::Result match_station_id(int val) const; 00065 00071 virtual matcher::Result match_station_wmo(int block, int station=-1) const; 00072 00079 virtual matcher::Result match_date(const int* min, const int* max) const; 00080 00087 virtual matcher::Result match_coords(int latmin, int latmax, int lonmin, int lonmax) const; 00088 00094 virtual matcher::Result match_rep_memo(const char* memo) const; 00095 00102 static matcher::Result date_in_range(const int* date, const int* min, const int* max); 00103 00110 static matcher::Result int_in_range(int val, int min, int max); 00111 }; 00112 00113 struct Matcher 00114 { 00115 virtual ~Matcher() {} 00116 00117 virtual matcher::Result match(const Matched& item) const = 0; 00118 virtual void to_record(dballe::Record& query) const = 0; 00119 00120 static std::auto_ptr<Matcher> create(const dballe::Record& query); 00121 }; 00122 00123 } 00124 00125 /* vim:set ts=4 sw=4: */ 00126 #endif