[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 |
|
---|
[24959] | 119 | // returns the contents of a collection's rss-items.rdf file (generated by BasePlugout)
|
---|
| 120 | virtual void get_rss_items (const text_t &collection,
|
---|
| 121 | const text_t &gsdlhome,
|
---|
| 122 | text_t &rss_items,
|
---|
| 123 | comerror_t &err,
|
---|
| 124 | ostream &logout);
|
---|
| 125 |
|
---|
[15450] | 126 | // filters (search or browse) a result set and returns information
|
---|
| 127 | // about the filtered set including term frequency information and
|
---|
| 128 | // metadata
|
---|
| 129 | virtual void filter (const text_t &collection,
|
---|
| 130 | FilterRequest_t &request,
|
---|
| 131 | FilterResponse_t &response,
|
---|
| 132 | comerror_t &err, ostream &logout);
|
---|
| 133 |
|
---|
| 134 | // gets a document (duh!)
|
---|
| 135 | virtual void get_document (const text_t &collection,
|
---|
| 136 | const DocumentRequest_t &request,
|
---|
| 137 | DocumentResponse_t &response,
|
---|
| 138 | comerror_t &err, ostream &logout);
|
---|
| 139 |
|
---|
| 140 | virtual void is_searchable (const text_t &collection, bool &issearchable,
|
---|
| 141 | comerror_t &err, ostream &logout);
|
---|
| 142 |
|
---|
| 143 | };
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | // The recptprotoptr function does not 'own' the recptproto. The
|
---|
| 147 | // recptproto should be deleted by the code which created it.
|
---|
| 148 | class recptprotoptr {
|
---|
| 149 | public:
|
---|
| 150 | recptproto *p;
|
---|
| 151 |
|
---|
| 152 | recptprotoptr () {p=NULL;}
|
---|
| 153 | ~recptprotoptr () {}
|
---|
| 154 | };
|
---|
| 155 |
|
---|
| 156 | typedef vector<recptprotoptr> recptprotoptrlist;
|
---|
| 157 |
|
---|
| 158 |
|
---|
| 159 | // contains a list of recptprotos
|
---|
| 160 | class recptprotolistclass {
|
---|
| 161 | protected:
|
---|
| 162 | recptprotoptrlist recptprotoptrs;
|
---|
| 163 |
|
---|
| 164 | public:
|
---|
| 165 | // type support for recptprotolistclass
|
---|
| 166 | typedef recptprotoptrlist::iterator iterator;
|
---|
| 167 | typedef recptprotoptrlist::const_iterator const_iterator;
|
---|
| 168 | typedef recptprotoptrlist::reference reference;
|
---|
| 169 | typedef recptprotoptrlist::const_reference const_reference;
|
---|
| 170 | typedef recptprotoptrlist::size_type size_type;
|
---|
| 171 |
|
---|
| 172 | typedef recptprotoptrlist::difference_type difference_type;
|
---|
| 173 | typedef recptprotoptrlist::const_reverse_iterator const_reverse_iterator;
|
---|
| 174 | typedef recptprotoptrlist::reverse_iterator reverse_iterator;
|
---|
| 175 |
|
---|
| 176 | // basic container support
|
---|
| 177 | iterator begin () {return recptprotoptrs.begin();}
|
---|
| 178 | const_iterator begin () const {return recptprotoptrs.begin();}
|
---|
| 179 | iterator end () {return recptprotoptrs.end();}
|
---|
| 180 | const_iterator end () const {return recptprotoptrs.end();}
|
---|
| 181 |
|
---|
| 182 | void erase(iterator pos) {recptprotoptrs.erase(pos);}
|
---|
| 183 | void erase(iterator first, iterator last) {recptprotoptrs.erase(first, last);}
|
---|
| 184 | recptprotolistclass &operator=(const recptprotolistclass &x)
|
---|
| 185 | {recptprotoptrs=x.recptprotoptrs;return *this;}
|
---|
| 186 |
|
---|
| 187 | bool empty () const {return recptprotoptrs.empty();}
|
---|
| 188 | size_type size() const {return recptprotoptrs.size();}
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 | // added functionality
|
---|
| 192 | void clear () {recptprotoptrs.erase(recptprotoptrs.begin(),recptprotoptrs.end());}
|
---|
| 193 |
|
---|
| 194 | // therecptproto remains the property of the calling code but
|
---|
| 195 | // should not be deleted until it is removed from this list.
|
---|
| 196 | void addrecptproto (recptproto *therecptproto);
|
---|
| 197 |
|
---|
| 198 | // getrecptproto will return NULL if a recptproto for the given collection
|
---|
| 199 | // could not be found
|
---|
| 200 | recptproto *getrecptproto (const text_t &collection, ostream &logout);
|
---|
| 201 | };
|
---|
| 202 |
|
---|
| 203 |
|
---|
| 204 | #endif
|
---|