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

Last change on this file since 15757 was 15587, checked in by mdewsnip, 16 years ago

(Adding new DB support) Changed a lot of "gdbmhome" to "dbhome".

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