[15492] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * z3950proxy.h --
|
---|
| 4 | * Copyright (C) 2000 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 | #ifndef Z3950PROXY_H
|
---|
| 27 | #define Z3050PROXY_H
|
---|
| 28 |
|
---|
| 29 | #include "comtypes.h"
|
---|
| 30 |
|
---|
| 31 | // each "proxy to server" (i.e. collection) consists of a {z39.50 server + database} pair.
|
---|
| 32 | class z3950_proxy {
|
---|
| 33 | protected:
|
---|
| 34 | text_t title; // Descriptive name
|
---|
| 35 | text_t z_initstr; // a string returned when the connection is initialised.
|
---|
| 36 | text_tmap meta; // metadata for this collection (ie server/database pair)
|
---|
| 37 | text_tmap format;
|
---|
| 38 | text_tmap about; // langauge/abouttext pair for collection.
|
---|
| 39 | ShortColInfo_t *info; // has (database) name, host and port
|
---|
| 40 | text_tarray *titles;
|
---|
| 41 | bool connect();
|
---|
| 42 | bool connected; // tcp connection to the z39.50 server (target)
|
---|
| 43 | bool gotsinglerecord; // if we do, then we don't need all titles...
|
---|
| 44 |
|
---|
| 45 | public:
|
---|
| 46 | z3950_proxy();
|
---|
| 47 | ~z3950_proxy();
|
---|
| 48 | void setName(const text_t &newname);
|
---|
| 49 | const text_t getName() {return title;}
|
---|
| 50 | void setMeta(const text_t &key, const text_t &value);
|
---|
| 51 | const text_tmap *getMeta() {return &meta;}
|
---|
| 52 | const text_tmap *getFormat() {return &format;}
|
---|
| 53 | void setInfo(ShortColInfo_t *newinfo) {info=newinfo;}
|
---|
| 54 | const ShortColInfo_t *getInfo() {return info;}
|
---|
| 55 | void addcfgAbout(const text_t &lang, const text_t &abouttext);
|
---|
| 56 | bool getcfgAbout(const text_t &lang, text_t &abouttext);
|
---|
| 57 | // now the functions that actually talk to the target (ie zserver) over tcp
|
---|
| 58 | text_t &getzAbout(); // gets any name, id, MOTD, etc from server.
|
---|
| 59 | text_tarray *getrecordTitles(const text_t &query,
|
---|
| 60 | const int andor_querytype,
|
---|
| 61 | const text_t &fields,
|
---|
| 62 | const int first, const int count,
|
---|
| 63 | int *nummatches, comerror_t &err);
|
---|
| 64 | /* only get one record at a time? (Eventually we could buffer them, but
|
---|
| 65 | for now... */
|
---|
| 66 | bool getfullrecord(const text_t &query, const int andor_querytype,
|
---|
| 67 | const text_t &fields,
|
---|
| 68 | const int ID, text_t &rettitle,
|
---|
| 69 | text_t &rettext,comerror_t &err);
|
---|
| 70 | private:
|
---|
| 71 | void parseQuery(const text_t &query, const int andor_querytype,
|
---|
| 72 | const text_t &fields,
|
---|
| 73 | text_t &parsed_query);
|
---|
| 74 | text_t previousquery; // for caching purposes
|
---|
| 75 | };
|
---|
| 76 |
|
---|
| 77 | typedef vector<z3950_proxy *> z3950_proxy_array;
|
---|
| 78 |
|
---|
| 79 | #endif
|
---|