[15450] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * recptproto.h --
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
| 6 | * A component of the Greenstone digital library software
|
---|
| 7 | * from the New Zealand Digital Library Project at the
|
---|
| 8 | * University of Waikato, New Zealand.
|
---|
| 9 | *
|
---|
| 10 | * This program is free software; you can redistribute it and/or modify
|
---|
| 11 | * it under the terms of the GNU General Public License as published by
|
---|
| 12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | * (at your option) any later version.
|
---|
| 14 | *
|
---|
| 15 | * This program is distributed in the hope that it will be useful,
|
---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | * GNU General Public License for more details.
|
---|
| 19 | *
|
---|
| 20 | * You should have received a copy of the GNU General Public License
|
---|
| 21 | * along with this program; if not, write to the Free Software
|
---|
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | *
|
---|
| 24 | *********************************************************************/
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | #ifndef RECPTPROTO_H
|
---|
| 28 | #define RECPTPROTO_H
|
---|
| 29 |
|
---|
| 30 | #include "gsdlconf.h"
|
---|
| 31 | #include "text_t.h"
|
---|
| 32 | #include "comtypes.h"
|
---|
| 33 |
|
---|
| 34 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
| 35 | # include <ospace\std\vector>
|
---|
| 36 | #elif defined(GSDL_USE_STL_H)
|
---|
| 37 | # include <vector.h>
|
---|
| 38 | #else
|
---|
| 39 | # include <vector>
|
---|
| 40 | #endif
|
---|
| 41 |
|
---|
| 42 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
| 43 | # include <ospace\std\iostream>
|
---|
| 44 | #elif defined(GSDL_USE_IOS_H)
|
---|
| 45 | # include <iostream.h>
|
---|
| 46 | #else
|
---|
| 47 | # include <iostream>
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | // recptproto is a generalisation of a protocol for communicating
|
---|
| 52 | // with a collection server.
|
---|
| 53 | class recptproto {
|
---|
| 54 | public:
|
---|
| 55 |
|
---|
[22142] | 56 | recptproto() {};
|
---|
| 57 | virtual ~recptproto() {};
|
---|
| 58 |
|
---|
[15450] | 59 | // add collection server to protocol
|
---|
| 60 | virtual void add_collection (const text_t &collection, void *recpt,
|
---|
[16310] | 61 | const text_t &gsdlhome, const text_t& collecthome,
|
---|
| 62 | const text_t &dbhome);
|
---|
[15450] | 63 |
|
---|
| 64 | virtual void remove_collection (const text_t &collection, ostream &logout);
|
---|
| 65 |
|
---|
| 66 | // configure should be called for each line in the configuration file
|
---|
| 67 | virtual void configure (const text_t &key, const text_tarray &cfgline, comerror_t &err);
|
---|
| 68 |
|
---|
| 69 | // init should be called after the configuration but before any other
|
---|
| 70 | // functions are called. If init returns false a message will be written
|
---|
| 71 | // out to the log file and no other output should be produced.
|
---|
| 72 | virtual bool init (comerror_t &err, ostream &logout);
|
---|
| 73 |
|
---|
| 74 | // get_site_name should return the name of the site used.
|
---|
| 75 | // This is trivially empty in the case of a null protocol. If a remote
|
---|
| 76 | // connection to a site is being used then this should return the name
|
---|
| 77 | // used to label a site
|
---|
| 78 | virtual text_t get_site_name(comerror_t &err);
|
---|
| 79 |
|
---|
| 80 | // get_protocol_name should return the name of this protocol (e.g. recptproto)
|
---|
| 81 | // that can be used to do run time type identification and display information
|
---|
| 82 | // about the protocol.
|
---|
| 83 | virtual text_t get_protocol_name (comerror_t &err);
|
---|
| 84 |
|
---|
| 85 | // get_collection_list returns the list of collections that
|
---|
| 86 | // this protocol knows about
|
---|
| 87 | virtual void get_collection_list (text_tarray &collist, comerror_t &err,
|
---|
| 88 | ostream &logout);
|
---|
| 89 |
|
---|
| 90 | // has_collection sets 'hascollection' to be true if the protocol
|
---|
| 91 | // can communicate with the collection (i.e. it is within its
|
---|
| 92 | // collection list). This function should be implemented in as
|
---|
| 93 | // efficient time as possible as it will be called for each page
|
---|
| 94 | // access and for each protocol.
|
---|
| 95 | virtual void has_collection (const text_t &collection, bool &hascollection,
|
---|
| 96 | comerror_t &err, ostream &logout);
|
---|
| 97 |
|
---|
| 98 | // sets 'wassuccess' to be true if a successful ping was done to
|
---|
| 99 | // the given collection.
|
---|
| 100 | virtual void ping (const text_t &collection, bool &wassuccess,
|
---|
| 101 | comerror_t &err, ostream &logout);
|
---|
| 102 |
|
---|
| 103 | // obtains general information about the collection
|
---|
| 104 | virtual void get_collectinfo (const text_t &collection,
|
---|
| 105 | ColInfoResponse_t &collectinfo,
|
---|
| 106 | comerror_t &err, ostream &logout);
|
---|
| 107 |
|
---|
| 108 | // gets a list of all the filters
|
---|
| 109 | virtual void get_filterinfo (const text_t &collection,
|
---|
| 110 | InfoFiltersResponse_t &response,
|
---|
| 111 | comerror_t &err, ostream &logout);
|
---|
| 112 |
|
---|
| 113 | // gets all the filter options for a particular filter
|
---|
| 114 | virtual void get_filteroptions (const text_t &collection,
|
---|
| 115 | const InfoFilterOptionsRequest_t &request,
|
---|
| 116 | InfoFilterOptionsResponse_t &response,
|
---|
| 117 | comerror_t &err, ostream &logout);
|
---|
| 118 |
|
---|
| 119 | // filters (search or browse) a result set and returns information
|
---|
| 120 | // about the filtered set including term frequency information and
|
---|
| 121 | // metadata
|
---|
| 122 | virtual void filter (const text_t &collection,
|
---|
| 123 | FilterRequest_t &request,
|
---|
| 124 | FilterResponse_t &response,
|
---|
| 125 | comerror_t &err, ostream &logout);
|
---|
| 126 |
|
---|
| 127 | // gets a document (duh!)
|
---|
| 128 | virtual void get_document (const text_t &collection,
|
---|
| 129 | const DocumentRequest_t &request,
|
---|
| 130 | DocumentResponse_t &response,
|
---|
| 131 | comerror_t &err, ostream &logout);
|
---|
| 132 |
|
---|
| 133 | virtual void is_searchable (const text_t &collection, bool &issearchable,
|
---|
| 134 | comerror_t &err, ostream &logout);
|
---|
| 135 |
|
---|
| 136 | };
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | // The recptprotoptr function does not 'own' the recptproto. The
|
---|
| 140 | // recptproto should be deleted by the code which created it.
|
---|
| 141 | class recptprotoptr {
|
---|
| 142 | public:
|
---|
| 143 | recptproto *p;
|
---|
| 144 |
|
---|
| 145 | recptprotoptr () {p=NULL;}
|
---|
| 146 | ~recptprotoptr () {}
|
---|
| 147 | };
|
---|
| 148 |
|
---|
| 149 | typedef vector<recptprotoptr> recptprotoptrlist;
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 | // contains a list of recptprotos
|
---|
| 153 | class recptprotolistclass {
|
---|
| 154 | protected:
|
---|
| 155 | recptprotoptrlist recptprotoptrs;
|
---|
| 156 |
|
---|
| 157 | public:
|
---|
| 158 | // type support for recptprotolistclass
|
---|
| 159 | typedef recptprotoptrlist::iterator iterator;
|
---|
| 160 | typedef recptprotoptrlist::const_iterator const_iterator;
|
---|
| 161 | typedef recptprotoptrlist::reference reference;
|
---|
| 162 | typedef recptprotoptrlist::const_reference const_reference;
|
---|
| 163 | typedef recptprotoptrlist::size_type size_type;
|
---|
| 164 |
|
---|
| 165 | typedef recptprotoptrlist::difference_type difference_type;
|
---|
| 166 | typedef recptprotoptrlist::const_reverse_iterator const_reverse_iterator;
|
---|
| 167 | typedef recptprotoptrlist::reverse_iterator reverse_iterator;
|
---|
| 168 |
|
---|
| 169 | // basic container support
|
---|
| 170 | iterator begin () {return recptprotoptrs.begin();}
|
---|
| 171 | const_iterator begin () const {return recptprotoptrs.begin();}
|
---|
| 172 | iterator end () {return recptprotoptrs.end();}
|
---|
| 173 | const_iterator end () const {return recptprotoptrs.end();}
|
---|
| 174 |
|
---|
| 175 | void erase(iterator pos) {recptprotoptrs.erase(pos);}
|
---|
| 176 | void erase(iterator first, iterator last) {recptprotoptrs.erase(first, last);}
|
---|
| 177 | recptprotolistclass &operator=(const recptprotolistclass &x)
|
---|
| 178 | {recptprotoptrs=x.recptprotoptrs;return *this;}
|
---|
| 179 |
|
---|
| 180 | bool empty () const {return recptprotoptrs.empty();}
|
---|
| 181 | size_type size() const {return recptprotoptrs.size();}
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 | // added functionality
|
---|
| 185 | void clear () {recptprotoptrs.erase(recptprotoptrs.begin(),recptprotoptrs.end());}
|
---|
| 186 |
|
---|
| 187 | // therecptproto remains the property of the calling code but
|
---|
| 188 | // should not be deleted until it is removed from this list.
|
---|
| 189 | void addrecptproto (recptproto *therecptproto);
|
---|
| 190 |
|
---|
| 191 | // getrecptproto will return NULL if a recptproto for the given collection
|
---|
| 192 | // could not be found
|
---|
| 193 | recptproto *getrecptproto (const text_t &collection, ostream &logout);
|
---|
| 194 | };
|
---|
| 195 |
|
---|
| 196 |
|
---|
| 197 | #endif
|
---|