source: main/trunk/greenstone2/runtime-src/src/colservr/collectserver.h@ 21945

Last change on this file since 21945 was 16310, checked in by davidb, 16 years ago

Introduction of 'collecthome' which parallels 'gsdlhome' to allow the toplevel collect folder to be outside of the gsdlhome area

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