source: trunk/gsdl/src/recpt/recptproto.cpp@ 919

Last change on this file since 919 was 533, checked in by sjboddie, 25 years ago

added GPL notice

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1/**********************************************************************
2 *
3 * recptproto.cpp --
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: recptproto.cpp 533 1999-09-07 04:57:01Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.7 1999/09/07 04:56:59 sjboddie
31 added GPL notice
32
33 Revision 1.6 1999/05/10 03:40:43 sjboddie
34 lots of changes - slowly getting document action sorted out
35
36 Revision 1.5 1999/04/30 01:59:43 sjboddie
37 lots of stuff - getting documentaction working (documentaction replaces
38 old browseaction)
39
40 Revision 1.4 1999/03/31 23:44:48 rjmcnab
41 Altered the protocol so that the metadata is part of the filter.
42
43 Revision 1.3 1999/03/03 23:26:35 sjboddie
44
45 Implemented more of the protocol
46
47 Revision 1.2 1999/02/25 21:59:01 rjmcnab
48
49 Merged sources.
50
51 Revision 1.1 1999/02/21 22:35:24 rjmcnab
52
53 Initial revision.
54
55 */
56
57
58#include "recptproto.h"
59#include <assert.h>
60
61
62// configure should be called for each line in the configuration file
63void recptproto::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
64}
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.
69bool recptproto::init (ostream &/*logout*/) {
70 return true;
71}
72
73// get_protocol_name should return the name of this protocol (e.g. recptproto)
74// that can be used to do run time type identification and display information
75// about the protocol.
76text_t recptproto::get_protocol_name () {
77 return "recptproto";
78}
79
80// get_collection_list returns the list of collections that
81// this protocol knows about
82void recptproto::get_collection_list (text_tarray &collist, comerror_t &err,
83 ostream &/*logout*/) {
84 collist.erase(collist.begin(),collist.end());
85 err = noError;
86}
87
88// has_collection sets 'hascollection' to be true if the protocol
89// can communicate with the collection (i.e. it is within its
90// collection list). This function should be implemented in as
91// efficient time as possible as it will be called for each page
92// access and for each protocol.
93void recptproto::has_collection (const text_t &/*collection*/, bool &hascollection,
94 comerror_t &err, ostream &/*logout*/) {
95 hascollection = false;
96 err = noError;
97}
98
99// sets 'wassuccess' to be true if a successful ping was done to
100// the given collection.
101void recptproto::ping (const text_t &/*collection*/, bool &wassuccess,
102 comerror_t &err, ostream &/*logout*/) {
103 wassuccess = false; // no collections are supported by this class
104 err = noError;
105}
106
107// obtains general information about the collection
108void recptproto::get_collectinfo (const text_t &/*collection*/,
109 ColInfoResponse_t &/*collectinfo*/,
110 comerror_t &err, ostream &/*logout*/) {
111 err = protocolError;
112}
113
114// gets a list of all the filters
115void recptproto::get_filterinfo (const text_t &/*collection*/,
116 InfoFiltersResponse_t &/*reponse*/,
117 comerror_t &err, ostream &/*logout*/) {
118 err = protocolError;
119}
120
121// gets all the filter options for a particular filter
122void recptproto::get_filteroptions (const text_t &/*collection*/,
123 const InfoFilterOptionsRequest_t &/*request*/,
124 InfoFilterOptionsResponse_t &/*response*/,
125 comerror_t &err, ostream &/*logout*/) {
126 err = protocolError;
127}
128
129// filters (search or browse) a result set
130void recptproto::filter (const text_t &/*collection*/,
131 FilterRequest_t &/*request*/,
132 FilterResponse_t &/*response*/,
133 comerror_t &err, ostream &/*logout*/) {
134 err = protocolError;
135}
136
137void recptproto::get_document (const text_t &/*collection*/,
138 const DocumentRequest_t &/*request*/,
139 DocumentResponse_t &/*response*/,
140 comerror_t &err, ostream &/*logout*/) {
141 err = protocolError;
142}
143
144
145
146
147
148
149
150// therecptproto remains the property of the calling code but
151// should not be deleted until it is removed from this list.
152void recptprotolistclass::addrecptproto (recptproto *therecptproto) {
153 // can't add a protocol that doesn't exist
154 assert (therecptproto != NULL);
155 if (therecptproto == NULL) return;
156
157 recptprotoptr rpp;
158 rpp.p = therecptproto;
159
160 recptprotoptrs.push_back(rpp);
161}
162
163// getrecptproto will return NULL if a recptproto for the given colelction
164// could not be found
165recptproto *recptprotolistclass::getrecptproto (const text_t &collection,
166 ostream &logout) {
167 iterator here = recptprotoptrs.begin ();
168 iterator end = recptprotoptrs.end ();
169 bool hascollection;
170 comerror_t err;
171
172 while (here != end) {
173 assert ((*here).p != NULL);
174 if ((*here).p != NULL) {
175 (*here).p->has_collection (collection, hascollection, err, logout);
176 if ((err == noError) && (hascollection == true)) return (*here).p;
177 }
178
179 here++;
180 }
181
182 return NULL;
183}
184
Note: See TracBrowser for help on using the repository browser.