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

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

Included CORBA branch for first time

  • 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 * $Id: collectserver.h 1860 2001-01-25 18:26:45Z 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 // init should be called after the collection name has been set and
101 // all initialisation is done. init returns true if the initialisation
102 // was successful, if false is returned then no other functions
103 // should be called (without producing meaningless output).
104 virtual bool init (ostream &logout);
105
106 void get_collectinfo (ColInfoResponse_t &reponse,
107 comerror_t &err, ostream &logout);
108
109 virtual void get_filterinfo (InfoFiltersResponse_t &response,
110 comerror_t &err, ostream &logout);
111
112 virtual void get_filteroptions (const InfoFilterOptionsRequest_t &request,
113 InfoFilterOptionsResponse_t &response,
114 comerror_t &err, ostream &logout);
115
116 virtual void filter (FilterRequest_t &request,
117 FilterResponse_t &response,
118 comerror_t &err, ostream &logout);
119
120
121 virtual void get_document (const DocumentRequest_t &request,
122 DocumentResponse_t &response,
123 comerror_t &err, ostream &logout);
124
125};
126
127
128// The collectserverptr function does not 'own' the collectserver. The
129// collectserver should be deleted by the code which created it.
130class collectserverptr {
131public:
132 collectserver *c;
133
134 collectserverptr () {c=NULL;}
135 ~collectserverptr () {}
136};
137
138bool operator==(const collectserverptr &x, const collectserverptr &y);
139bool operator<(const collectserverptr &x, const collectserverptr &y);
140
141typedef map<text_t, collectserverptr, lttext_t> collectserverptrmap;
142
143// contains a list of collectservers indexed by their name
144class collectservermapclass {
145protected:
146 collectserverptrmap collectserverptrs;
147
148public:
149 // type support for collectserverptrmap
150 typedef collectserverptrmap::iterator iterator;
151 typedef collectserverptrmap::const_iterator const_iterator;
152 typedef collectserverptrmap::reference reference;
153 typedef collectserverptrmap::const_reference const_reference;
154 typedef collectserverptrmap::size_type size_type;
155
156 typedef collectserverptrmap::difference_type difference_type;
157 typedef collectserverptrmap::const_reverse_iterator const_reverse_iterator;
158 typedef collectserverptrmap::reverse_iterator reverse_iterator;
159
160 // basic container support
161 iterator begin () {return collectserverptrs.begin();}
162 const_iterator begin () const {return collectserverptrs.begin();}
163 iterator end () {return collectserverptrs.end();}
164 const_iterator end () const {return collectserverptrs.end();}
165
166 void erase(iterator pos) {collectserverptrs.erase(pos);}
167 void erase(iterator first, iterator last) {collectserverptrs.erase(first, last);}
168 collectservermapclass &operator=(const collectservermapclass &x)
169 {collectserverptrs=x.collectserverptrs;return *this;}
170
171 bool empty () const {return collectserverptrs.empty();}
172 size_type size() const {return collectserverptrs.size();}
173
174
175 // added functionality
176 void clear () {collectserverptrs.erase(collectserverptrs.begin(),collectserverptrs.end());}
177
178 // thecollectserver remains the property of the calling code but
179 // should not be deleted until it is removed from this list.
180 void addcollectserver (collectserver *thecollectserver);
181
182 // getcollectserver will return NULL if the collectserver could not be found
183 collectserver *getcollectserver (const text_t &collection);
184};
185
186
187#endif
Note: See TracBrowser for help on using the repository browser.