source: main/trunk/greenstone2/runtime-src/src/protocol/recptproto.h@ 20999

Last change on this file since 20999 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

File size: 6.8 KB
Line 
1/**********************************************************************
2 *
3 * recptproto.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 *********************************************************************/
25
26
27#ifndef RECPTPROTO_H
28#define RECPTPROTO_H
29
30#include "gsdlconf.h"
31#include "text_t.h"
32#include "comtypes.h"
33
34#if defined(GSDL_USE_OBJECTSPACE)
35# include <ospace\std\vector>
36#elif defined(GSDL_USE_STL_H)
37# include <vector.h>
38#else
39# include <vector>
40#endif
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
51// recptproto is a generalisation of a protocol for communicating
52// with a collection server.
53class recptproto {
54public:
55
56 // add collection server to protocol
57 virtual void add_collection (const text_t &collection, void *recpt,
58 const text_t &gsdlhome, const text_t& collecthome,
59 const text_t &dbhome);
60
61 virtual void remove_collection (const text_t &collection, ostream &logout);
62
63 // configure should be called for each line in the configuration file
64 virtual void configure (const text_t &key, const text_tarray &cfgline, comerror_t &err);
65
66 // init should be called after the configuration but before any other
67 // functions are called. If init returns false a message will be written
68 // out to the log file and no other output should be produced.
69 virtual bool init (comerror_t &err, ostream &logout);
70
71 // get_site_name should return the name of the site used.
72 // This is trivially empty in the case of a null protocol. If a remote
73 // connection to a site is being used then this should return the name
74 // used to label a site
75 virtual text_t get_site_name(comerror_t &err);
76
77 // get_protocol_name should return the name of this protocol (e.g. recptproto)
78 // that can be used to do run time type identification and display information
79 // about the protocol.
80 virtual text_t get_protocol_name (comerror_t &err);
81
82 // get_collection_list returns the list of collections that
83 // this protocol knows about
84 virtual void get_collection_list (text_tarray &collist, comerror_t &err,
85 ostream &logout);
86
87 // has_collection sets 'hascollection' to be true if the protocol
88 // can communicate with the collection (i.e. it is within its
89 // collection list). This function should be implemented in as
90 // efficient time as possible as it will be called for each page
91 // access and for each protocol.
92 virtual void has_collection (const text_t &collection, bool &hascollection,
93 comerror_t &err, ostream &logout);
94
95 // sets 'wassuccess' to be true if a successful ping was done to
96 // the given collection.
97 virtual void ping (const text_t &collection, bool &wassuccess,
98 comerror_t &err, ostream &logout);
99
100 // obtains general information about the collection
101 virtual void get_collectinfo (const text_t &collection,
102 ColInfoResponse_t &collectinfo,
103 comerror_t &err, ostream &logout);
104
105 // gets a list of all the filters
106 virtual void get_filterinfo (const text_t &collection,
107 InfoFiltersResponse_t &response,
108 comerror_t &err, ostream &logout);
109
110 // gets all the filter options for a particular filter
111 virtual void get_filteroptions (const text_t &collection,
112 const InfoFilterOptionsRequest_t &request,
113 InfoFilterOptionsResponse_t &response,
114 comerror_t &err, ostream &logout);
115
116 // filters (search or browse) a result set and returns information
117 // about the filtered set including term frequency information and
118 // metadata
119 virtual void filter (const text_t &collection,
120 FilterRequest_t &request,
121 FilterResponse_t &response,
122 comerror_t &err, ostream &logout);
123
124 // gets a document (duh!)
125 virtual void get_document (const text_t &collection,
126 const DocumentRequest_t &request,
127 DocumentResponse_t &response,
128 comerror_t &err, ostream &logout);
129
130 virtual void is_searchable (const text_t &collection, bool &issearchable,
131 comerror_t &err, ostream &logout);
132
133};
134
135
136// The recptprotoptr function does not 'own' the recptproto. The
137// recptproto should be deleted by the code which created it.
138class recptprotoptr {
139public:
140 recptproto *p;
141
142 recptprotoptr () {p=NULL;}
143 ~recptprotoptr () {}
144};
145
146typedef vector<recptprotoptr> recptprotoptrlist;
147
148
149// contains a list of recptprotos
150class recptprotolistclass {
151protected:
152 recptprotoptrlist recptprotoptrs;
153
154public:
155 // type support for recptprotolistclass
156 typedef recptprotoptrlist::iterator iterator;
157 typedef recptprotoptrlist::const_iterator const_iterator;
158 typedef recptprotoptrlist::reference reference;
159 typedef recptprotoptrlist::const_reference const_reference;
160 typedef recptprotoptrlist::size_type size_type;
161
162 typedef recptprotoptrlist::difference_type difference_type;
163 typedef recptprotoptrlist::const_reverse_iterator const_reverse_iterator;
164 typedef recptprotoptrlist::reverse_iterator reverse_iterator;
165
166 // basic container support
167 iterator begin () {return recptprotoptrs.begin();}
168 const_iterator begin () const {return recptprotoptrs.begin();}
169 iterator end () {return recptprotoptrs.end();}
170 const_iterator end () const {return recptprotoptrs.end();}
171
172 void erase(iterator pos) {recptprotoptrs.erase(pos);}
173 void erase(iterator first, iterator last) {recptprotoptrs.erase(first, last);}
174 recptprotolistclass &operator=(const recptprotolistclass &x)
175 {recptprotoptrs=x.recptprotoptrs;return *this;}
176
177 bool empty () const {return recptprotoptrs.empty();}
178 size_type size() const {return recptprotoptrs.size();}
179
180
181 // added functionality
182 void clear () {recptprotoptrs.erase(recptprotoptrs.begin(),recptprotoptrs.end());}
183
184 // therecptproto remains the property of the calling code but
185 // should not be deleted until it is removed from this list.
186 void addrecptproto (recptproto *therecptproto);
187
188 // getrecptproto will return NULL if a recptproto for the given collection
189 // could not be found
190 recptproto *getrecptproto (const text_t &collection, ostream &logout);
191};
192
193
194#endif
Note: See TracBrowser for help on using the repository browser.