source: trunk/gsdl/src/colservr/collectserver.h@ 9915

Last change on this file since 9915 was 4774, checked in by sjboddie, 21 years ago

No longer show search page (or search form on "about" page) if a collection
doesn't have at least one searchable index. Note that this change includes
the addition of an is_searchable() function to the protocol.

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