source: main/tags/2.80/gsdl/src/recpt/recptproto.cpp@ 24528

Last change on this file since 24528 was 9620, checked in by kjdon, 19 years ago

added some x++ -> ++x changes submitted by Emanuel Dejanu

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 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 *********************************************************************/
25
26#include "recptproto.h"
27#include <assert.h>
28
29
30// add collection server to protocol
31void recptproto::add_collection (const text_t &/*collection*/, void * /*recpt*/,
32 const text_t &/*gsdlhome*/, const text_t &/*gdbmhome*/) {
33}
34
35void recptproto::remove_collection (const text_t &/*collection*/, ostream &/*logout*/) {
36}
37
38// configure should be called for each line in the configuration file
39void recptproto::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/, comerror_t &) {
40}
41
42// init should be called after the configuration but before any other
43// functions are called. If init returns false a message will be written
44// out to the log file and no other output should be produced.
45bool recptproto::init (comerror_t &err, ostream &/*logout*/) {
46 return true;
47}
48
49// get site name should return the name of the site used.
50// This is trivially empty in the case of a null protocol. If a remote
51// connection to a site is being used then this should return the name
52// used to label a site
53text_t recptproto::get_site_name(comerror_t &err) {
54 return "localhost";
55}
56
57// get_protocol_name should return the name of this protocol (e.g. recptproto)
58// that can be used to do run time type identification and display information
59// about the protocol.
60text_t recptproto::get_protocol_name (comerror_t &err) {
61 return "recptproto";
62}
63
64// get_collection_list returns the list of collections that
65// this protocol knows about
66void recptproto::get_collection_list (text_tarray &collist, comerror_t &err,
67 ostream &/*logout*/) {
68 collist.erase(collist.begin(),collist.end());
69 err = noError;
70}
71
72// has_collection sets 'hascollection' to be true if the protocol
73// can communicate with the collection (i.e. it is within its
74// collection list). This function should be implemented in as
75// efficient time as possible as it will be called for each page
76// access and for each protocol.
77void recptproto::has_collection (const text_t &/*collection*/, bool &hascollection,
78 comerror_t &err, ostream &/*logout*/) {
79 hascollection = false;
80 err = noError;
81}
82
83// sets 'wassuccess' to be true if a successful ping was done to
84// the given collection.
85void recptproto::ping (const text_t &/*collection*/, bool &wassuccess,
86 comerror_t &err, ostream &/*logout*/) {
87 wassuccess = false; // no collections are supported by this class
88 err = noError;
89}
90
91// obtains general information about the collection
92void recptproto::get_collectinfo (const text_t &/*collection*/,
93 ColInfoResponse_t &/*collectinfo*/,
94 comerror_t &err, ostream &/*logout*/) {
95 err = protocolError;
96}
97
98// gets a list of all the filters
99void recptproto::get_filterinfo (const text_t &/*collection*/,
100 InfoFiltersResponse_t &/*reponse*/,
101 comerror_t &err, ostream &/*logout*/) {
102 err = protocolError;
103}
104
105// gets all the filter options for a particular filter
106void recptproto::get_filteroptions (const text_t &/*collection*/,
107 const InfoFilterOptionsRequest_t &/*request*/,
108 InfoFilterOptionsResponse_t &/*response*/,
109 comerror_t &err, ostream &/*logout*/) {
110 err = protocolError;
111}
112
113// filters (search or browse) a result set
114void recptproto::filter (const text_t &/*collection*/,
115 FilterRequest_t &/*request*/,
116 FilterResponse_t &/*response*/,
117 comerror_t &err, ostream &/*logout*/) {
118 err = protocolError;
119}
120
121void recptproto::get_document (const text_t &/*collection*/,
122 const DocumentRequest_t &/*request*/,
123 DocumentResponse_t &/*response*/,
124 comerror_t &err, ostream &/*logout*/) {
125 err = protocolError;
126}
127
128// sets issearchable to true if the given colection is searchable
129void recptproto::is_searchable (const text_t &/*collection*/, bool &issearchable,
130 comerror_t &err, ostream &/*logout*/) {
131 issearchable = false; // no collections are supported by this class
132 err = noError;
133}
134
135
136
137
138
139
140
141// therecptproto remains the property of the calling code but
142// should not be deleted until it is removed from this list.
143void recptprotolistclass::addrecptproto (recptproto *therecptproto) {
144 // can't add a protocol that doesn't exist
145 assert (therecptproto != NULL);
146 if (therecptproto == NULL) return;
147
148 recptprotoptr rpp;
149 rpp.p = therecptproto;
150
151 recptprotoptrs.push_back(rpp);
152}
153
154// getrecptproto will return NULL if a recptproto for the given colelction
155// could not be found
156recptproto *recptprotolistclass::getrecptproto (const text_t &collection,
157 ostream &logout) {
158 iterator here = recptprotoptrs.begin ();
159 iterator end = recptprotoptrs.end ();
160 bool hascollection;
161 comerror_t err;
162
163 while (here != end) {
164 assert ((*here).p != NULL);
165 if ((*here).p != NULL) {
166 (*here).p->has_collection (collection, hascollection, err, logout);
167 if ((err == noError) && (hascollection == true)) return (*here).p;
168 }
169
170 ++here;
171 }
172
173 return NULL;
174}
Note: See TracBrowser for help on using the repository browser.