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

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

lots of stuff - getting documentaction working (documentaction replaces
old browseaction)

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