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

Last change on this file since 472 was 472, checked in by sjboddie, 25 years ago

changed FilterRequest_t::docSet into an array

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/**********************************************************************
2 *
3 * filter.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: filter.h 472 1999-08-25 04:50:00Z sjboddie $
9 *
10 *********************************************************************/
11
12
13#ifndef FILTER_H
14#define FILTER_H
15
16#include "gsdlconf.h"
17#include "text_t.h"
18#include "comtypes.h"
19
20
21class filterclass {
22protected:
23 text_t gsdlhome;
24 text_t collection;
25 text_t collectdir;
26
27 FilterOption_tmap filterOptions;
28
29public:
30 filterclass ();
31 virtual ~filterclass ();
32
33 // configure should be called once for each configuration line
34 // default configures the default filter options
35 virtual void configure (const text_t &key, const text_tarray &cfgline);
36
37 // init should be called after all the configuration is done but
38 // before any other methods are called
39 // default checks all the filter option defaults
40 virtual bool init (ostream &logout);
41
42 // returns the name of this filter
43 virtual text_t get_filter_name ();
44
45 // returns the current filter options
46 virtual void get_filteroptions (InfoFilterOptionsResponse_t &response,
47 comerror_t &err, ostream &logout);
48
49 virtual void filter (const FilterRequest_t &request,
50 FilterResponse_t &response,
51 comerror_t &err, ostream &logout);
52};
53
54
55// The filterptr class does not 'own' the filter. The
56// filter should be deleted by the code which created it.
57class filterptr {
58public:
59 filterclass *f;
60
61 filterptr () {f=NULL;}
62};
63
64typedef map<text_t, filterptr, lttext_t> filterptrmap;
65
66// contains a list of filters indexed by their name
67class filtermapclass {
68protected:
69 filterptrmap filterptrs;
70
71public:
72 // type support for filterptrmap
73 typedef filterptrmap::iterator iterator;
74 typedef filterptrmap::const_iterator const_iterator;
75 typedef filterptrmap::reference reference;
76 typedef filterptrmap::const_reference const_reference;
77 typedef filterptrmap::size_type size_type;
78
79 typedef filterptrmap::difference_type difference_type;
80 typedef filterptrmap::const_reverse_iterator const_reverse_iterator;
81 typedef filterptrmap::reverse_iterator reverse_iterator;
82
83 // basic container support
84 iterator begin () {return filterptrs.begin();}
85 const_iterator begin () const {return filterptrs.begin();}
86 iterator end () {return filterptrs.end();}
87 const_iterator end () const {return filterptrs.end();}
88
89 void erase(iterator pos) {filterptrs.erase(pos);}
90 void erase(iterator first, iterator last) {filterptrs.erase(first, last);}
91 filtermapclass &operator=(const filtermapclass &x) {filterptrs=x.filterptrs;return *this;}
92
93 bool empty () const {return filterptrs.empty();}
94 size_type size() const {return filterptrs.size();}
95
96
97 // added functionality
98 void clear () {filterptrs.erase(filterptrs.begin(),filterptrs.end());}
99
100 // thefilter remains the property of the calling code but
101 // should not be deleted until it is removed from this list.
102 void addfilter (filterclass *thefilter);
103
104 // getfilter will return NULL if the filter could not be found
105 filterclass *getfilter (const text_t &key);
106};
107
108
109
110// some useful functions for dealing with document sets
111
112// intersect places the result in set1
113void intersect (text_tset &set1, const text_tset &set2);
114void intersect (text_tarray &set1, const text_tset &set2);
115void intersect (text_tarray &set1, const text_tarray &set2);
116
117// tests to see if el is in set
118bool in_set (const text_tset &set1, const text_t &el);
119bool in_set (const text_tarray &set1, const text_t &el);
120
121#endif
Note: See TracBrowser for help on using the repository browser.