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

Last change on this file since 495 was 495, checked in by rjmcnab, 25 years ago

A few changes for AIX.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 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 495 1999-08-31 22:39:59Z rjmcnab $
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 ~filterptr () {}
63};
64
65bool operator==(const filterptr &x, const filterptr &y);
66bool operator<(const filterptr &x, const filterptr &y);
67
68
69typedef map<text_t, filterptr, lttext_t> filterptrmap;
70
71// contains a list of filters indexed by their name
72class filtermapclass {
73protected:
74 filterptrmap filterptrs;
75
76public:
77 // type support for filterptrmap
78 typedef filterptrmap::iterator iterator;
79 typedef filterptrmap::const_iterator const_iterator;
80 typedef filterptrmap::reference reference;
81 typedef filterptrmap::const_reference const_reference;
82 typedef filterptrmap::size_type size_type;
83
84 typedef filterptrmap::difference_type difference_type;
85 typedef filterptrmap::const_reverse_iterator const_reverse_iterator;
86 typedef filterptrmap::reverse_iterator reverse_iterator;
87
88 // basic container support
89 iterator begin () {return filterptrs.begin();}
90 const_iterator begin () const {return filterptrs.begin();}
91 iterator end () {return filterptrs.end();}
92 const_iterator end () const {return filterptrs.end();}
93
94 void erase(iterator pos) {filterptrs.erase(pos);}
95 void erase(iterator first, iterator last) {filterptrs.erase(first, last);}
96 filtermapclass &operator=(const filtermapclass &x) {filterptrs=x.filterptrs;return *this;}
97
98 bool empty () const {return filterptrs.empty();}
99 size_type size() const {return filterptrs.size();}
100
101
102 // added functionality
103 void clear () {filterptrs.erase(filterptrs.begin(),filterptrs.end());}
104
105 // thefilter remains the property of the calling code but
106 // should not be deleted until it is removed from this list.
107 void addfilter (filterclass *thefilter);
108
109 // getfilter will return NULL if the filter could not be found
110 filterclass *getfilter (const text_t &key);
111};
112
113
114
115// some useful functions for dealing with document sets
116
117// intersect places the result in set1
118void intersect (text_tset &set1, const text_tset &set2);
119void intersect (text_tarray &set1, const text_tset &set2);
120void intersect (text_tarray &set1, const text_tarray &set2);
121
122// tests to see if el is in set
123bool in_set (const text_tset &set1, const text_t &el);
124bool in_set (const text_tarray &set1, const text_t &el);
125
126#endif
Note: See TracBrowser for help on using the repository browser.