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