source: trunk/gsdl/src/colservr/filter.h@ 1285

Last change on this file since 1285 was 1285, checked in by sjboddie, 24 years ago

Removed CVS logging information from source files

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1/**********************************************************************
2 *
3 * filter.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26
27#ifndef FILTER_H
28#define FILTER_H
29
30#include "gsdlconf.h"
31#include "text_t.h"
32#include "comtypes.h"
33
34
35class filterclass {
36protected:
37 text_t gsdlhome;
38 text_t collection;
39 text_t collectdir;
40
41 FilterOption_tmap filterOptions;
42
43public:
44 filterclass ();
45 virtual ~filterclass ();
46
47 // configure should be called once for each configuration line
48 // default configures the default filter options
49 virtual void configure (const text_t &key, const text_tarray &cfgline);
50
51 // init should be called after all the configuration is done but
52 // before any other methods are called
53 // default checks all the filter option defaults
54 virtual bool init (ostream &logout);
55
56 // returns the name of this filter
57 virtual text_t get_filter_name ();
58
59 // returns the current filter options
60 virtual void get_filteroptions (InfoFilterOptionsResponse_t &response,
61 comerror_t &err, ostream &logout);
62
63 virtual void filter (const FilterRequest_t &request,
64 FilterResponse_t &response,
65 comerror_t &err, ostream &logout);
66};
67
68
69// The filterptr class does not 'own' the filter. The
70// filter should be deleted by the code which created it.
71class filterptr {
72public:
73 filterclass *f;
74
75 filterptr () {f=NULL;}
76 ~filterptr () {}
77};
78
79bool operator==(const filterptr &x, const filterptr &y);
80bool operator<(const filterptr &x, const filterptr &y);
81
82
83typedef map<text_t, filterptr, lttext_t> filterptrmap;
84
85// contains a list of filters indexed by their name
86class filtermapclass {
87protected:
88 filterptrmap filterptrs;
89
90public:
91 // type support for filterptrmap
92 typedef filterptrmap::iterator iterator;
93 typedef filterptrmap::const_iterator const_iterator;
94 typedef filterptrmap::reference reference;
95 typedef filterptrmap::const_reference const_reference;
96 typedef filterptrmap::size_type size_type;
97
98 typedef filterptrmap::difference_type difference_type;
99 typedef filterptrmap::const_reverse_iterator const_reverse_iterator;
100 typedef filterptrmap::reverse_iterator reverse_iterator;
101
102 // basic container support
103 iterator begin () {return filterptrs.begin();}
104 const_iterator begin () const {return filterptrs.begin();}
105 iterator end () {return filterptrs.end();}
106 const_iterator end () const {return filterptrs.end();}
107
108 void erase(iterator pos) {filterptrs.erase(pos);}
109 void erase(iterator first, iterator last) {filterptrs.erase(first, last);}
110 filtermapclass &operator=(const filtermapclass &x) {filterptrs=x.filterptrs;return *this;}
111
112 bool empty () const {return filterptrs.empty();}
113 size_type size() const {return filterptrs.size();}
114
115
116 // added functionality
117 void clear () {filterptrs.erase(filterptrs.begin(),filterptrs.end());}
118
119 // thefilter remains the property of the calling code but
120 // should not be deleted until it is removed from this list.
121 void addfilter (filterclass *thefilter);
122
123 // getfilter will return NULL if the filter could not be found
124 filterclass *getfilter (const text_t &key);
125};
126
127
128
129// some useful functions for dealing with document sets
130
131// intersect places the result in set1
132void intersect (text_tset &set1, const text_tset &set2);
133void intersect (text_tarray &set1, const text_tset &set2);
134void intersect (text_tarray &set1, const text_tarray &set2);
135
136// tests to see if el is in set
137bool in_set (const text_tset &set1, const text_t &el);
138bool in_set (const text_tarray &set1, const text_t &el);
139
140#endif
Note: See TracBrowser for help on using the repository browser.