1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * queryfilter.h -- abstract base class for queryfilters
|
---|
4 | * mgqueryfilter, mgppqueryfilter and lucenequeryfilter
|
---|
5 | * implement this
|
---|
6 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
7 | *
|
---|
8 | * A component of the Greenstone digital library software
|
---|
9 | * from the New Zealand Digital Library Project at the
|
---|
10 | * University of Waikato, New Zealand.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or modify
|
---|
13 | * it under the terms of the GNU General Public License as published by
|
---|
14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
15 | * (at your option) any later version.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful,
|
---|
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | * GNU General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, write to the Free Software
|
---|
24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 |
|
---|
29 | #ifndef QUERYFILTER_H
|
---|
30 | #define QUERYFILTER_H
|
---|
31 |
|
---|
32 |
|
---|
33 | #include "gsdlconf.h"
|
---|
34 | #include "text_t.h"
|
---|
35 | #include "comtypes.h"
|
---|
36 | #include "filter.h"
|
---|
37 | #include "infodbclass.h"
|
---|
38 | #include "maptools.h"
|
---|
39 | #include "search.h"
|
---|
40 | #include "queryinfo.h"
|
---|
41 |
|
---|
42 |
|
---|
43 | class queryfilterclass : public filterclass {
|
---|
44 | protected:
|
---|
45 |
|
---|
46 | stringmap indexmap;
|
---|
47 | stringmap subcollectionmap;
|
---|
48 | stringmap languagemap;
|
---|
49 |
|
---|
50 | text_t gdbm_filename;
|
---|
51 | gdbmclass *gdbmptr;
|
---|
52 |
|
---|
53 | searchclass *textsearchptr;
|
---|
54 |
|
---|
55 | // get the query parameters
|
---|
56 | void parse_query_params (const FilterRequest_t &request,
|
---|
57 | vector<queryparamclass> &query_params,
|
---|
58 | int &startresults, int &endresults,
|
---|
59 | text_t &phrasematch, ostream &logout);
|
---|
60 |
|
---|
61 | // do query that might involve multiple sub queries
|
---|
62 | // textsearchptr and gdbmptr are assumed to be valid
|
---|
63 | virtual void do_multi_query (const FilterRequest_t &request,
|
---|
64 | const vector<queryparamclass> &query_params,
|
---|
65 | queryresultsclass &multiresults,
|
---|
66 | comerror_t &err, ostream &logout)=0;
|
---|
67 |
|
---|
68 | public:
|
---|
69 | queryfilterclass ();
|
---|
70 | virtual ~queryfilterclass ();
|
---|
71 |
|
---|
72 | // the gdbmptr remains the responsability of the calling code
|
---|
73 | void set_gdbmptr (gdbmclass *thegdbmptr) {gdbmptr=thegdbmptr;}
|
---|
74 |
|
---|
75 | // the testsearchptr remains the responsability of the calling code
|
---|
76 | void set_textsearchptr (searchclass *thetextsearchptr) {textsearchptr=thetextsearchptr;}
|
---|
77 |
|
---|
78 | virtual void configure (const text_t &key, const text_tarray &cfgline);
|
---|
79 | bool init (ostream &logout);
|
---|
80 |
|
---|
81 | text_t get_filter_name () {return "QueryFilter";}
|
---|
82 | bool translate(gdbmclass *gdbmptr, int docnum, text_t &trans_OID);
|
---|
83 | bool need_matching_docs (int filterResultOptions);
|
---|
84 | bool need_term_info (int filterResultOptions);
|
---|
85 |
|
---|
86 |
|
---|
87 | virtual void filter (const FilterRequest_t &request,
|
---|
88 | FilterResponse_t &response,
|
---|
89 | comerror_t &err, ostream &logout)=0;
|
---|
90 |
|
---|
91 |
|
---|
92 |
|
---|
93 | };
|
---|
94 |
|
---|
95 |
|
---|
96 | #endif
|
---|
97 |
|
---|