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

Last change on this file since 1437 was 1285, checked in by sjboddie, 24 years ago

Removed CVS logging information from source files

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