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

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

Tidied up collectoraction some more and created an add_collection
function in nullproto that does all the work of setting up a
local collection server

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