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 184 1999-03-03 23:26:35Z 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.
|
---|
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 all the filter options for a collection
|
---|
78 | virtual void get_filteroptions (const text_t &collection,
|
---|
79 | InfoFilterOptionsResponse_t &response,
|
---|
80 | comerror_t &err, ostream &logout);
|
---|
81 |
|
---|
82 | // filters (search or browse) a result set
|
---|
83 | virtual void filter (const text_t &collection,
|
---|
84 | const FilterRequest_t &request,
|
---|
85 | FilterResponse_t &response,
|
---|
86 | comerror_t &err, ostream &logout);
|
---|
87 |
|
---|
88 | // gets all the metadata options for a collection
|
---|
89 | virtual void get_metadataoptions (const text_t &collection,
|
---|
90 | MetadataInfoResponse_t &response,
|
---|
91 | comerror_t &err, ostream &logout);
|
---|
92 |
|
---|
93 | // gets all the metadata for a result set
|
---|
94 | virtual void get_metadata (const text_t &collection,
|
---|
95 | const MetadataRequest_t &request,
|
---|
96 | MetadataResponse_t &response,
|
---|
97 | comerror_t &err, ostream &logout);
|
---|
98 | };
|
---|
99 |
|
---|
100 |
|
---|
101 | // The recptprotoptr function does not 'own' the recptproto. The
|
---|
102 | // recptproto should be deleted by the code which created it.
|
---|
103 | class recptprotoptr {
|
---|
104 | public:
|
---|
105 | recptproto *p;
|
---|
106 |
|
---|
107 | recptprotoptr () {p=NULL;}
|
---|
108 | };
|
---|
109 |
|
---|
110 | typedef vector<recptprotoptr> recptprotoptrlist;
|
---|
111 |
|
---|
112 |
|
---|
113 | // contains a list of recptprotos
|
---|
114 | class recptprotolistclass {
|
---|
115 | protected:
|
---|
116 | recptprotoptrlist recptprotoptrs;
|
---|
117 |
|
---|
118 | public:
|
---|
119 | // type support for recptprotolistclass
|
---|
120 | typedef recptprotoptrlist::iterator iterator;
|
---|
121 | typedef recptprotoptrlist::const_iterator const_iterator;
|
---|
122 | typedef recptprotoptrlist::reference reference;
|
---|
123 | typedef recptprotoptrlist::const_reference const_reference;
|
---|
124 | typedef recptprotoptrlist::size_type size_type;
|
---|
125 |
|
---|
126 | typedef recptprotoptrlist::difference_type difference_type;
|
---|
127 | typedef recptprotoptrlist::const_reverse_iterator const_reverse_iterator;
|
---|
128 | typedef recptprotoptrlist::reverse_iterator reverse_iterator;
|
---|
129 |
|
---|
130 | // basic container support
|
---|
131 | iterator begin () {return recptprotoptrs.begin();}
|
---|
132 | const_iterator begin () const {return recptprotoptrs.begin();}
|
---|
133 | iterator end () {return recptprotoptrs.end();}
|
---|
134 | const_iterator end () const {return recptprotoptrs.end();}
|
---|
135 |
|
---|
136 | void erase(iterator pos) {recptprotoptrs.erase(pos);}
|
---|
137 | void erase(iterator first, iterator last) {recptprotoptrs.erase(first, last);}
|
---|
138 | recptprotolistclass &operator=(const recptprotolistclass &x)
|
---|
139 | {recptprotoptrs=x.recptprotoptrs;return *this;}
|
---|
140 |
|
---|
141 | bool empty () const {return recptprotoptrs.empty();}
|
---|
142 | size_type size() const {return recptprotoptrs.size();}
|
---|
143 |
|
---|
144 |
|
---|
145 | // added functionality
|
---|
146 | void clear () {recptprotoptrs.erase(recptprotoptrs.begin(),recptprotoptrs.end());}
|
---|
147 |
|
---|
148 | // therecptproto remains the property of the calling code but
|
---|
149 | // should not be deleted until it is removed from this list.
|
---|
150 | void addrecptproto (recptproto *therecptproto);
|
---|
151 |
|
---|
152 | // getrecptproto will return NULL if a recptproto for the given colelction
|
---|
153 | // could not be found
|
---|
154 | recptproto *getrecptproto (const text_t &collection, ostream &logout);
|
---|
155 | };
|
---|
156 |
|
---|
157 |
|
---|
158 | #endif
|
---|