source: trunk/gsdl/src/colservr/collectserver.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: 6.2 KB
Line 
1/**********************************************************************
2 *
3 * collectserver.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 COLLECTSERVER_H
28#define COLLECTSERVER_H
29
30#include "gsdlconf.h"
31#include "text_t.h"
32#include "comtypes.h"
33#include "filter.h"
34#include "source.h"
35#include "cfgread.h"
36
37#if defined(GSDL_USE_OBJECTSPACE)
38# include <ospace\std\iostream>
39#elif defined(GSDL_USE_IOS_H)
40# include <iostream.h>
41#else
42# include <iostream>
43#endif
44
45#if defined(GSDL_USE_OBJECTSPACE)
46# include <ospace\std\map>
47#elif defined(GSDL_USE_STL_H)
48# include <map.h>
49#else
50# include <map>
51#endif
52
53
54struct colservrconf {
55 text_t gsdlhome;
56 text_t gdbmhome;
57 text_t collection;
58 text_t collectdir;
59};
60
61
62class collectserver {
63protected:
64 colservrconf configinfo;
65 ColInfoResponse_t collectinfo;
66
67 filtermapclass filters;
68 sourcelistclass sources;
69
70public:
71 collectserver ();
72 virtual ~collectserver ();
73
74 // add_filter makes another filter available to the collection server
75 // the filter remains the property of the calling code and that
76 // code should destroy the filter after the collection server has been
77 // destroyed.
78 void add_filter (filterclass *thefilter) {filters.addfilter(thefilter);}
79 filtermapclass *get_filtermap_ptr () {return &filters;}
80
81 // add_source makes another source available to the collection server
82 // the source remains the property of the calling code and that
83 // code should destroy the source after the collection server has been
84 // destroyed.
85 void add_source (sourceclass *thesource) {sources.addsource(thesource);}
86 sourcelistclass *get_sourcelist_ptr () {return &sources;}
87
88 // configure should be called for each line in the
89 // configuration files to configure the collection server and everything
90 // it contains. The configuration should take place just before initialisation.
91 virtual void configure (const text_t &key, const text_tarray &cfgline);
92 void configure (const text_t &key, const text_t &value);
93 const colservrconf &get_configinfo () {return configinfo;}
94 text_t get_collection_name () {return configinfo.collection;}
95
96 // init should be called after the collection name has been set and
97 // all initialisation is done. init returns true if the initialisation
98 // was successful, if false is returned then no other functions
99 // should be called (without producing meaningless output).
100 virtual bool init (ostream &logout);
101
102 void get_collectinfo (ColInfoResponse_t &reponse,
103 comerror_t &err, ostream &logout);
104
105 virtual void get_filterinfo (InfoFiltersResponse_t &response,
106 comerror_t &err, ostream &logout);
107
108 virtual void get_filteroptions (const InfoFilterOptionsRequest_t &request,
109 InfoFilterOptionsResponse_t &response,
110 comerror_t &err, ostream &logout);
111
112 virtual void filter (FilterRequest_t &request,
113 FilterResponse_t &response,
114 comerror_t &err, ostream &logout);
115
116
117 virtual void get_document (const DocumentRequest_t &request,
118 DocumentResponse_t &response,
119 comerror_t &err, ostream &logout);
120
121};
122
123
124// The collectserverptr function does not 'own' the collectserver. The
125// collectserver should be deleted by the code which created it.
126class collectserverptr {
127public:
128 collectserver *c;
129
130 collectserverptr () {c=NULL;}
131 ~collectserverptr () {}
132};
133
134bool operator==(const collectserverptr &x, const collectserverptr &y);
135bool operator<(const collectserverptr &x, const collectserverptr &y);
136
137typedef map<text_t, collectserverptr, lttext_t> collectserverptrmap;
138
139// contains a list of collectservers indexed by their name
140class collectservermapclass {
141protected:
142 collectserverptrmap collectserverptrs;
143
144public:
145 // type support for collectserverptrmap
146 typedef collectserverptrmap::iterator iterator;
147 typedef collectserverptrmap::const_iterator const_iterator;
148 typedef collectserverptrmap::reference reference;
149 typedef collectserverptrmap::const_reference const_reference;
150 typedef collectserverptrmap::size_type size_type;
151
152 typedef collectserverptrmap::difference_type difference_type;
153 typedef collectserverptrmap::const_reverse_iterator const_reverse_iterator;
154 typedef collectserverptrmap::reverse_iterator reverse_iterator;
155
156 // basic container support
157 iterator begin () {return collectserverptrs.begin();}
158 const_iterator begin () const {return collectserverptrs.begin();}
159 iterator end () {return collectserverptrs.end();}
160 const_iterator end () const {return collectserverptrs.end();}
161
162 void erase(iterator pos) {collectserverptrs.erase(pos);}
163 void erase(iterator first, iterator last) {collectserverptrs.erase(first, last);}
164 collectservermapclass &operator=(const collectservermapclass &x)
165 {collectserverptrs=x.collectserverptrs;return *this;}
166
167 bool empty () const {return collectserverptrs.empty();}
168 size_type size() const {return collectserverptrs.size();}
169
170
171 // added functionality
172 void clear () {collectserverptrs.erase(collectserverptrs.begin(),collectserverptrs.end());}
173
174 // thecollectserver remains the property of the calling code but
175 // should not be deleted until it is removed from this list.
176 void addcollectserver (collectserver *thecollectserver);
177
178 // getcollectserver will return NULL if the collectserver could not be found
179 collectserver *getcollectserver (const text_t &collection);
180};
181
182
183#endif
Note: See TracBrowser for help on using the repository browser.