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

Last change on this file since 919 was 722, checked in by davidb, 25 years ago

Collection building support through web pages
and internal and external link handling for collection documents

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