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

Last change on this file since 308 was 259, checked in by sjboddie, 25 years ago

lots of changes to lots of files - getting document action going

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1/**********************************************************************
2 *
3 * collectserver.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: collectserver.h 259 1999-05-10 03:43:49Z sjboddie $
9 *
10 *********************************************************************/
11
12
13#ifndef COLLECTSERVER_H
14#define COLLECTSERVER_H
15
16#include "gsdlconf.h"
17#include "text_t.h"
18#include "comtypes.h"
19#include "filter.h"
20#include "source.h"
21
22#if defined(GSDL_USE_OBJECTSPACE)
23# include <ospace\std\iostream>
24#elif defined(GSDL_USE_IOS_H)
25# include <iostream.h>
26#else
27# include <iostream>
28#endif
29
30#if defined(GSDL_USE_OBJECTSPACE)
31# include <ospace\std\map>
32#elif defined(GSDL_USE_STL_H)
33# include <map.h>
34#else
35# include <map>
36#endif
37
38
39struct colservrconf {
40 text_t gsdlhome;
41 text_t collection;
42 text_t collectdir;
43};
44
45
46class collectserver {
47protected:
48 colservrconf configinfo;
49 ColInfoResponse_t collectinfo;
50
51 filtermapclass filters;
52 sourcelistclass sources;
53
54public:
55 collectserver ();
56 virtual ~collectserver ();
57
58 // add_filter makes another filter available to the collection server
59 // the filter remains the property of the calling code and that
60 // code should destroy the filter after the collection server has been
61 // destroyed.
62 void add_filter (filterclass *thefilter) {filters.addfilter(thefilter);}
63 filtermapclass *get_filtermap_ptr () {return &filters;}
64
65 // add_source makes another source available to the collection server
66 // the source remains the property of the calling code and that
67 // code should destroy the source after the collection server has been
68 // destroyed.
69 void add_source (sourceclass *thesource) {sources.addsource(thesource);}
70 sourcelistclass *get_sourcelist_ptr () {return &sources;}
71
72 // configure should be called for each line in the
73 // configuration files to configure the collection server and everything
74 // it contains. The configuration should take place just before initialisation.
75 virtual void configure (const text_t &key, const text_tarray &cfgline);
76 void configure (const text_t &key, const text_t &value);
77 const colservrconf &get_configinfo () {return configinfo;}
78 text_t get_collection_name () {return configinfo.collection;}
79
80 // init should be called after the collection name has been set and
81 // all initialisation is done. init returns true if the initialisation
82 // was successful, if false is returned then no other functions
83 // should be called (without producing meaningless output).
84 virtual bool init (ostream &logout);
85
86 void get_collectinfo (ColInfoResponse_t &reponse,
87 comerror_t &err, ostream &logout);
88
89 virtual void get_filterinfo (InfoFiltersResponse_t &response,
90 comerror_t &err, ostream &logout);
91
92 virtual void get_filteroptions (const InfoFilterOptionsRequest_t &request,
93 InfoFilterOptionsResponse_t &response,
94 comerror_t &err, ostream &logout);
95
96 virtual void filter (FilterRequest_t &request,
97 FilterResponse_t &response,
98 comerror_t &err, ostream &logout);
99
100
101 virtual void get_document (const DocumentRequest_t &request,
102 DocumentResponse_t &response,
103 comerror_t &err, ostream &logout);
104
105};
106
107
108// The collectserverptr function does not 'own' the collectserver. The
109// collectserver should be deleted by the code which created it.
110class collectserverptr {
111public:
112 collectserver *c;
113
114 collectserverptr () {c=NULL;}
115};
116
117typedef map<text_t, collectserverptr, lttext_t> collectserverptrmap;
118
119// contains a list of collectservers indexed by their name
120class collectservermapclass {
121protected:
122 collectserverptrmap collectserverptrs;
123
124public:
125 // type support for collectserverptrmap
126 typedef collectserverptrmap::iterator iterator;
127 typedef collectserverptrmap::const_iterator const_iterator;
128 typedef collectserverptrmap::reference reference;
129 typedef collectserverptrmap::const_reference const_reference;
130 typedef collectserverptrmap::size_type size_type;
131
132 typedef collectserverptrmap::difference_type difference_type;
133 typedef collectserverptrmap::const_reverse_iterator const_reverse_iterator;
134 typedef collectserverptrmap::reverse_iterator reverse_iterator;
135
136 // basic container support
137 iterator begin () {return collectserverptrs.begin();}
138 const_iterator begin () const {return collectserverptrs.begin();}
139 iterator end () {return collectserverptrs.end();}
140 const_iterator end () const {return collectserverptrs.end();}
141
142 void erase(iterator pos) {collectserverptrs.erase(pos);}
143 void erase(iterator first, iterator last) {collectserverptrs.erase(first, last);}
144 collectservermapclass &operator=(const collectservermapclass &x)
145 {collectserverptrs=x.collectserverptrs;return *this;}
146
147 bool empty () const {return collectserverptrs.empty();}
148 size_type size() const {return collectserverptrs.size();}
149
150
151 // added functionality
152 void clear () {collectserverptrs.erase(collectserverptrs.begin(),collectserverptrs.end());}
153
154 // thecollectserver remains the property of the calling code but
155 // should not be deleted until it is removed from this list.
156 void addcollectserver (collectserver *thecollectserver);
157
158 // getcollectserver will return NULL if the collectserver could not be found
159 collectserver *getcollectserver (const text_t &collection);
160};
161
162
163#endif
Note: See TracBrowser for help on using the repository browser.