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 220 1999-03-31 23:44:49Z rjmcnab $
|
---|
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.
|
---|
39 | class recptproto {
|
---|
40 | public:
|
---|
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 | const FilterRequest_t &request,
|
---|
93 | FilterResponse_t &response,
|
---|
94 | comerror_t &err, ostream &logout);
|
---|
95 |
|
---|
96 | // just a dummy for now - not sure where or how this
|
---|
97 | // should be done - type should be one of hierarchy, book,
|
---|
98 | // list, datelist or none. name should be one of subject,
|
---|
99 | // date, title, author, series, howto, or organization
|
---|
100 | virtual void get_classification_info (const text_t &/*OID*/, text_t &ctype, text_t &cname) {
|
---|
101 | cname = "title";
|
---|
102 | ctype = "list";
|
---|
103 | }
|
---|
104 |
|
---|
105 | // return list of all classifications supported by this collection
|
---|
106 | // e.g. "title", "subject" and "date". Should be tested somewhere I guess
|
---|
107 | // to make sure all classifications are supported by this receptionist
|
---|
108 | virtual void get_all_classifications (text_tarray &classifications) {
|
---|
109 | classifications.push_back ("subject");
|
---|
110 | classifications.push_back ("title");
|
---|
111 | classifications.push_back ("series");
|
---|
112 | }
|
---|
113 | };
|
---|
114 |
|
---|
115 |
|
---|
116 | // The recptprotoptr function does not 'own' the recptproto. The
|
---|
117 | // recptproto should be deleted by the code which created it.
|
---|
118 | class recptprotoptr {
|
---|
119 | public:
|
---|
120 | recptproto *p;
|
---|
121 |
|
---|
122 | recptprotoptr () {p=NULL;}
|
---|
123 | };
|
---|
124 |
|
---|
125 | typedef vector<recptprotoptr> recptprotoptrlist;
|
---|
126 |
|
---|
127 |
|
---|
128 | // contains a list of recptprotos
|
---|
129 | class recptprotolistclass {
|
---|
130 | protected:
|
---|
131 | recptprotoptrlist recptprotoptrs;
|
---|
132 |
|
---|
133 | public:
|
---|
134 | // type support for recptprotolistclass
|
---|
135 | typedef recptprotoptrlist::iterator iterator;
|
---|
136 | typedef recptprotoptrlist::const_iterator const_iterator;
|
---|
137 | typedef recptprotoptrlist::reference reference;
|
---|
138 | typedef recptprotoptrlist::const_reference const_reference;
|
---|
139 | typedef recptprotoptrlist::size_type size_type;
|
---|
140 |
|
---|
141 | typedef recptprotoptrlist::difference_type difference_type;
|
---|
142 | typedef recptprotoptrlist::const_reverse_iterator const_reverse_iterator;
|
---|
143 | typedef recptprotoptrlist::reverse_iterator reverse_iterator;
|
---|
144 |
|
---|
145 | // basic container support
|
---|
146 | iterator begin () {return recptprotoptrs.begin();}
|
---|
147 | const_iterator begin () const {return recptprotoptrs.begin();}
|
---|
148 | iterator end () {return recptprotoptrs.end();}
|
---|
149 | const_iterator end () const {return recptprotoptrs.end();}
|
---|
150 |
|
---|
151 | void erase(iterator pos) {recptprotoptrs.erase(pos);}
|
---|
152 | void erase(iterator first, iterator last) {recptprotoptrs.erase(first, last);}
|
---|
153 | recptprotolistclass &operator=(const recptprotolistclass &x)
|
---|
154 | {recptprotoptrs=x.recptprotoptrs;return *this;}
|
---|
155 |
|
---|
156 | bool empty () const {return recptprotoptrs.empty();}
|
---|
157 | size_type size() const {return recptprotoptrs.size();}
|
---|
158 |
|
---|
159 |
|
---|
160 | // added functionality
|
---|
161 | void clear () {recptprotoptrs.erase(recptprotoptrs.begin(),recptprotoptrs.end());}
|
---|
162 |
|
---|
163 | // therecptproto remains the property of the calling code but
|
---|
164 | // should not be deleted until it is removed from this list.
|
---|
165 | void addrecptproto (recptproto *therecptproto);
|
---|
166 |
|
---|
167 | // getrecptproto will return NULL if a recptproto for the given colelction
|
---|
168 | // could not be found
|
---|
169 | recptproto *getrecptproto (const text_t &collection, ostream &logout);
|
---|
170 | };
|
---|
171 |
|
---|
172 |
|
---|
173 | #endif
|
---|