1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * recptproto.cpp --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: recptproto.cpp 257 1999-05-10 03:40:44Z sjboddie $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.6 1999/05/10 03:40:43 sjboddie
|
---|
15 | lots of changes - slowly getting document action sorted out
|
---|
16 |
|
---|
17 | Revision 1.5 1999/04/30 01:59:43 sjboddie
|
---|
18 | lots of stuff - getting documentaction working (documentaction replaces
|
---|
19 | old browseaction)
|
---|
20 |
|
---|
21 | Revision 1.4 1999/03/31 23:44:48 rjmcnab
|
---|
22 | Altered the protocol so that the metadata is part of the filter.
|
---|
23 |
|
---|
24 | Revision 1.3 1999/03/03 23:26:35 sjboddie
|
---|
25 |
|
---|
26 | Implemented more of the protocol
|
---|
27 |
|
---|
28 | Revision 1.2 1999/02/25 21:59:01 rjmcnab
|
---|
29 |
|
---|
30 | Merged sources.
|
---|
31 |
|
---|
32 | Revision 1.1 1999/02/21 22:35:24 rjmcnab
|
---|
33 |
|
---|
34 | Initial revision.
|
---|
35 |
|
---|
36 | */
|
---|
37 |
|
---|
38 |
|
---|
39 | #include "recptproto.h"
|
---|
40 | #include <assert.h>
|
---|
41 |
|
---|
42 |
|
---|
43 | // configure should be called for each line in the configuration file
|
---|
44 | void recptproto::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
|
---|
45 | }
|
---|
46 |
|
---|
47 | // init should be called after the configuration but before any other
|
---|
48 | // functions are called. If init returns false a message will be written
|
---|
49 | // out to the log file and no other output should be produced.
|
---|
50 | bool recptproto::init (ostream &/*logout*/) {
|
---|
51 | return true;
|
---|
52 | }
|
---|
53 |
|
---|
54 | // get_protocol_name should return the name of this protocol (e.g. recptproto)
|
---|
55 | // that can be used to do run time type identification and display information
|
---|
56 | // about the protocol.
|
---|
57 | text_t recptproto::get_protocol_name () {
|
---|
58 | return "recptproto";
|
---|
59 | }
|
---|
60 |
|
---|
61 | // get_collection_list returns the list of collections that
|
---|
62 | // this protocol knows about
|
---|
63 | void recptproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
64 | ostream &/*logout*/) {
|
---|
65 | collist.erase(collist.begin(),collist.end());
|
---|
66 | err = noError;
|
---|
67 | }
|
---|
68 |
|
---|
69 | // has_collection sets 'hascollection' to be true if the protocol
|
---|
70 | // can communicate with the collection (i.e. it is within its
|
---|
71 | // collection list). This function should be implemented in as
|
---|
72 | // efficient time as possible as it will be called for each page
|
---|
73 | // access and for each protocol.
|
---|
74 | void recptproto::has_collection (const text_t &/*collection*/, bool &hascollection,
|
---|
75 | comerror_t &err, ostream &/*logout*/) {
|
---|
76 | hascollection = false;
|
---|
77 | err = noError;
|
---|
78 | }
|
---|
79 |
|
---|
80 | // sets 'wassuccess' to be true if a successful ping was done to
|
---|
81 | // the given collection.
|
---|
82 | void recptproto::ping (const text_t &/*collection*/, bool &wassuccess,
|
---|
83 | comerror_t &err, ostream &/*logout*/) {
|
---|
84 | wassuccess = false; // no collections are supported by this class
|
---|
85 | err = noError;
|
---|
86 | }
|
---|
87 |
|
---|
88 | // obtains general information about the collection
|
---|
89 | void recptproto::get_collectinfo (const text_t &/*collection*/,
|
---|
90 | ColInfoResponse_t &/*collectinfo*/,
|
---|
91 | comerror_t &err, ostream &/*logout*/) {
|
---|
92 | err = protocolError;
|
---|
93 | }
|
---|
94 |
|
---|
95 | // gets a list of all the filters
|
---|
96 | void recptproto::get_filterinfo (const text_t &/*collection*/,
|
---|
97 | InfoFiltersResponse_t &/*reponse*/,
|
---|
98 | comerror_t &err, ostream &/*logout*/) {
|
---|
99 | err = protocolError;
|
---|
100 | }
|
---|
101 |
|
---|
102 | // gets all the filter options for a particular filter
|
---|
103 | void recptproto::get_filteroptions (const text_t &/*collection*/,
|
---|
104 | const InfoFilterOptionsRequest_t &/*request*/,
|
---|
105 | InfoFilterOptionsResponse_t &/*response*/,
|
---|
106 | comerror_t &err, ostream &/*logout*/) {
|
---|
107 | err = protocolError;
|
---|
108 | }
|
---|
109 |
|
---|
110 | // filters (search or browse) a result set
|
---|
111 | void recptproto::filter (const text_t &/*collection*/,
|
---|
112 | FilterRequest_t &/*request*/,
|
---|
113 | FilterResponse_t &/*response*/,
|
---|
114 | comerror_t &err, ostream &/*logout*/) {
|
---|
115 | err = protocolError;
|
---|
116 | }
|
---|
117 |
|
---|
118 | void recptproto::get_document (const text_t &/*collection*/,
|
---|
119 | const DocumentRequest_t &/*request*/,
|
---|
120 | DocumentResponse_t &/*response*/,
|
---|
121 | comerror_t &err, ostream &/*logout*/) {
|
---|
122 | err = protocolError;
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|
126 |
|
---|
127 |
|
---|
128 |
|
---|
129 |
|
---|
130 |
|
---|
131 | // therecptproto remains the property of the calling code but
|
---|
132 | // should not be deleted until it is removed from this list.
|
---|
133 | void recptprotolistclass::addrecptproto (recptproto *therecptproto) {
|
---|
134 | // can't add a protocol that doesn't exist
|
---|
135 | assert (therecptproto != NULL);
|
---|
136 | if (therecptproto == NULL) return;
|
---|
137 |
|
---|
138 | recptprotoptr rpp;
|
---|
139 | rpp.p = therecptproto;
|
---|
140 |
|
---|
141 | recptprotoptrs.push_back(rpp);
|
---|
142 | }
|
---|
143 |
|
---|
144 | // getrecptproto will return NULL if a recptproto for the given colelction
|
---|
145 | // could not be found
|
---|
146 | recptproto *recptprotolistclass::getrecptproto (const text_t &collection,
|
---|
147 | ostream &logout) {
|
---|
148 | iterator here = recptprotoptrs.begin ();
|
---|
149 | iterator end = recptprotoptrs.end ();
|
---|
150 | bool hascollection;
|
---|
151 | comerror_t err;
|
---|
152 |
|
---|
153 | while (here != end) {
|
---|
154 | assert ((*here).p != NULL);
|
---|
155 | if ((*here).p != NULL) {
|
---|
156 | (*here).p->has_collection (collection, hascollection, err, logout);
|
---|
157 | if ((err == noError) && (hascollection == true)) return (*here).p;
|
---|
158 | }
|
---|
159 |
|
---|
160 | here++;
|
---|
161 | }
|
---|
162 |
|
---|
163 | return NULL;
|
---|
164 | }
|
---|
165 |
|
---|