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 184 1999-03-03 23:26:35Z sjboddie $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 | /*
|
---|
13 | $Log$
|
---|
14 | Revision 1.3 1999/03/03 23:26:35 sjboddie
|
---|
15 |
|
---|
16 | Implemented more of the protocol
|
---|
17 |
|
---|
18 | Revision 1.2 1999/02/25 21:59:01 rjmcnab
|
---|
19 |
|
---|
20 | Merged sources.
|
---|
21 |
|
---|
22 | Revision 1.1 1999/02/21 22:35:24 rjmcnab
|
---|
23 |
|
---|
24 | Initial revision.
|
---|
25 |
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | #include "recptproto.h"
|
---|
30 | #include <assert.h>
|
---|
31 |
|
---|
32 |
|
---|
33 | // configure should be called for each line in the configuration file
|
---|
34 | void recptproto::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
|
---|
35 | }
|
---|
36 |
|
---|
37 | // init should be called after the configuration but before any other
|
---|
38 | // functions are called. If init returns false a message will be written
|
---|
39 | // out to the log file and no other output should be produced.
|
---|
40 | bool recptproto::init (ostream &/*logout*/) {
|
---|
41 | return true;
|
---|
42 | }
|
---|
43 |
|
---|
44 | // get_protocol_name should return the name of this protocol (e.g. recptproto)
|
---|
45 | // that can be used to do run time type identification and display information
|
---|
46 | // about the protocol.
|
---|
47 | text_t recptproto::get_protocol_name () {
|
---|
48 | return "recptproto";
|
---|
49 | }
|
---|
50 |
|
---|
51 | // get_collection_list returns the list of collections that
|
---|
52 | // this protocol knows about
|
---|
53 | void recptproto::get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
54 | ostream &/*logout*/) {
|
---|
55 | collist.erase(collist.begin(),collist.end());
|
---|
56 | err = noError;
|
---|
57 | }
|
---|
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 | void recptproto::has_collection (const text_t &/*collection*/, bool &hascollection,
|
---|
65 | comerror_t &err, ostream &/*logout*/) {
|
---|
66 | hascollection = false;
|
---|
67 | err = noError;
|
---|
68 | }
|
---|
69 |
|
---|
70 | // sets 'wassuccess' to be true if a successful ping was done to
|
---|
71 | // the given collection.
|
---|
72 | void recptproto::ping (const text_t &/*collection*/, bool &wassuccess,
|
---|
73 | comerror_t &err, ostream &/*logout*/) {
|
---|
74 | wassuccess = false; // no collections are supported by this class
|
---|
75 | err = noError;
|
---|
76 | }
|
---|
77 |
|
---|
78 | // obtains general information about the collection
|
---|
79 | void recptproto::get_collectinfo (const text_t &/*collection*/,
|
---|
80 | ColInfoResponse_t &/*collectinfo*/,
|
---|
81 | comerror_t &err, ostream &/*logout*/) {
|
---|
82 | err = protocolError;
|
---|
83 | }
|
---|
84 |
|
---|
85 | // gets all the filter options for a collection
|
---|
86 | void recptproto::get_filteroptions (const text_t &/*collection*/,
|
---|
87 | InfoFilterOptionsResponse_t &/*response*/,
|
---|
88 | comerror_t &err, ostream &/*logout*/) {
|
---|
89 | err = protocolError;
|
---|
90 | }
|
---|
91 |
|
---|
92 | // filters (search or browse) a result set
|
---|
93 | void recptproto::filter (const text_t &/*collection*/,
|
---|
94 | const FilterRequest_t &/*request*/,
|
---|
95 | FilterResponse_t &/*response*/,
|
---|
96 | comerror_t &err, ostream &/*logout*/) {
|
---|
97 | err = protocolError;
|
---|
98 | }
|
---|
99 |
|
---|
100 | // gets all the metadata options for a collection
|
---|
101 | void recptproto::get_metadataoptions (const text_t &/*collection*/,
|
---|
102 | MetadataInfoResponse_t &/*response*/,
|
---|
103 | comerror_t &err, ostream &/*logout*/) {
|
---|
104 | err = protocolError;
|
---|
105 | }
|
---|
106 |
|
---|
107 | // gets all the metadata for a result set
|
---|
108 | void recptproto::get_metadata (const text_t &/*collection*/,
|
---|
109 | const MetadataRequest_t &/*request*/,
|
---|
110 | MetadataResponse_t &/*response*/,
|
---|
111 | comerror_t &err, ostream &/*logout*/) {
|
---|
112 | err = protocolError;
|
---|
113 | }
|
---|
114 |
|
---|
115 |
|
---|
116 |
|
---|
117 |
|
---|
118 |
|
---|
119 |
|
---|
120 | // therecptproto remains the property of the calling code but
|
---|
121 | // should not be deleted until it is removed from this list.
|
---|
122 | void recptprotolistclass::addrecptproto (recptproto *therecptproto) {
|
---|
123 | // can't add a protocol that doesn't exist
|
---|
124 | assert (therecptproto != NULL);
|
---|
125 | if (therecptproto == NULL) return;
|
---|
126 |
|
---|
127 | recptprotoptr rpp;
|
---|
128 | rpp.p = therecptproto;
|
---|
129 |
|
---|
130 | recptprotoptrs.push_back(rpp);
|
---|
131 | }
|
---|
132 |
|
---|
133 | // getrecptproto will return NULL if a recptproto for the given colelction
|
---|
134 | // could not be found
|
---|
135 | recptproto *recptprotolistclass::getrecptproto (const text_t &collection,
|
---|
136 | ostream &logout) {
|
---|
137 | iterator here = recptprotoptrs.begin ();
|
---|
138 | iterator end = recptprotoptrs.end ();
|
---|
139 | bool hascollection;
|
---|
140 | comerror_t err;
|
---|
141 |
|
---|
142 | while (here != end) {
|
---|
143 | assert ((*here).p != NULL);
|
---|
144 | if ((*here).p != NULL) {
|
---|
145 | (*here).p->has_collection (collection, hascollection, err, logout);
|
---|
146 | if ((err == noError) && (hascollection == true)) return (*here).p;
|
---|
147 | }
|
---|
148 |
|
---|
149 | here++;
|
---|
150 | }
|
---|
151 |
|
---|
152 | return NULL;
|
---|
153 | }
|
---|
154 |
|
---|