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

Last change on this file since 2173 was 2173, checked in by cs025, 23 years ago

Improvements to configure scripts in their support of various MICO
environment considerations, particularly when MICO is on the system
paths.

Fixed CORBA version of ping to correspond with parameters etc. of the
native form.

Finally, improved PING action to be more than a simple call to
the HASCOLLECTION action in the null protocol.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 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 2173 2001-03-13 15:15:23Z cs025 $
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};
130
131
132// The collectserverptr function does not 'own' the collectserver. The
133// collectserver should be deleted by the code which created it.
134class collectserverptr {
135public:
136 collectserver *c;
137
138 collectserverptr () {c=NULL;}
139 ~collectserverptr () {}
140};
141
142bool operator==(const collectserverptr &x, const collectserverptr &y);
143bool operator<(const collectserverptr &x, const collectserverptr &y);
144
145typedef map<text_t, collectserverptr, lttext_t> collectserverptrmap;
146
147// contains a list of collectservers indexed by their name
148class collectservermapclass {
149protected:
150 collectserverptrmap collectserverptrs;
151
152public:
153 // type support for collectserverptrmap
154 typedef collectserverptrmap::iterator iterator;
155 typedef collectserverptrmap::const_iterator const_iterator;
156 typedef collectserverptrmap::reference reference;
157 typedef collectserverptrmap::const_reference const_reference;
158 typedef collectserverptrmap::size_type size_type;
159
160 typedef collectserverptrmap::difference_type difference_type;
161 typedef collectserverptrmap::const_reverse_iterator const_reverse_iterator;
162 typedef collectserverptrmap::reverse_iterator reverse_iterator;
163
164 // basic container support
165 iterator begin () {return collectserverptrs.begin();}
166 const_iterator begin () const {return collectserverptrs.begin();}
167 iterator end () {return collectserverptrs.end();}
168 const_iterator end () const {return collectserverptrs.end();}
169
170 void erase(iterator pos) {collectserverptrs.erase(pos);}
171 void erase(iterator first, iterator last) {collectserverptrs.erase(first, last);}
172 collectservermapclass &operator=(const collectservermapclass &x)
173 {collectserverptrs=x.collectserverptrs;return *this;}
174
175 bool empty () const {return collectserverptrs.empty();}
176 size_type size() const {return collectserverptrs.size();}
177
178
179 // added functionality
180 void clear () {collectserverptrs.erase(collectserverptrs.begin(),collectserverptrs.end());}
181
182 // thecollectserver remains the property of the calling code but
183 // should not be deleted until it is removed from this list.
184 void addcollectserver (collectserver *thecollectserver);
185
186 // getcollectserver will return NULL if the collectserver could not be found
187 collectserver *getcollectserver (const text_t &collection);
188};
189
190
191#endif
Note: See TracBrowser for help on using the repository browser.