[649] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * browserclass.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 | * $Id: browserclass.h 668 1999-10-14 22:59:35Z sjboddie $
|
---|
| 25 | *
|
---|
| 26 | *********************************************************************/
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | #ifndef BROWSERCLASS_H
|
---|
| 30 | #define BROWSERCLASS_H
|
---|
| 31 |
|
---|
| 32 | #include "gsdlconf.h"
|
---|
| 33 | #include "text_t.h"
|
---|
| 34 | #include "cgiargs.h"
|
---|
| 35 | #include "display.h"
|
---|
| 36 | #include "recptproto.h"
|
---|
| 37 | #include "formattools.h"
|
---|
| 38 |
|
---|
| 39 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
| 40 | # include <ospace\std\iostream>
|
---|
| 41 | #elif defined(GSDL_USE_IOS_H)
|
---|
| 42 | # include <iostream.h>
|
---|
| 43 | #else
|
---|
| 44 | # include <iostream>
|
---|
| 45 | #endif
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | class browserclass {
|
---|
| 49 | protected:
|
---|
| 50 |
|
---|
| 51 | public:
|
---|
| 52 | browserclass ();
|
---|
| 53 | virtual ~browserclass ();
|
---|
| 54 |
|
---|
| 55 | // configure should be called once for each configuration line
|
---|
| 56 | virtual void configure (const text_t &key, const text_tarray &cfgline);
|
---|
| 57 |
|
---|
| 58 | // init should be called after all the configuration is done but
|
---|
| 59 | // before any other methods are called
|
---|
| 60 | virtual bool init (ostream &logout);
|
---|
| 61 |
|
---|
| 62 | // returns the name that specifies the browserclass type
|
---|
| 63 | virtual text_t get_browser_name ();
|
---|
| 64 |
|
---|
[668] | 65 | virtual void processOID (cgiargsclass &args, recptproto *collectproto, ostream &logout);
|
---|
[649] | 66 |
|
---|
| 67 | // load_metadata_defaults should be called before
|
---|
| 68 | // doing protocol call to get metadata for OID to
|
---|
| 69 | // be displayed by this browserclass. it adds fields
|
---|
| 70 | // to the metadata set that are needed by browserclass
|
---|
| 71 | // during display
|
---|
| 72 | virtual void load_metadata_defaults (text_tset &metadata);
|
---|
| 73 |
|
---|
| 74 | virtual text_t get_default_formatstring ();
|
---|
| 75 |
|
---|
| 76 | // returns the number of tabs to add before displaying the
|
---|
| 77 | // next section group
|
---|
| 78 | virtual int output_section_group (ResultDocInfo_t §ion, cgiargsclass &args,
|
---|
[668] | 79 | int colnumber, format_t *formatlistptr,
|
---|
| 80 | bool use_table, text_tset &metadata, bool &getParents,
|
---|
| 81 | recptproto *collectproto, displayclass &disp,
|
---|
| 82 | outconvertclass &outconvert, ostream &textout, ostream &logout);
|
---|
| 83 |
|
---|
| 84 | virtual int output_section_group (FilterResponse_t §ions, cgiargsclass &args,
|
---|
| 85 | int colnumber, format_t *formatlistptr,
|
---|
| 86 | bool use_table, text_tset &metadata, bool &getParents,
|
---|
| 87 | recptproto *collectproto, displayclass &disp,
|
---|
[649] | 88 | outconvertclass &outconvert, ostream &textout,
|
---|
| 89 | ostream &logout);
|
---|
| 90 | };
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 | // The browserptr function does not 'own' the browser. The
|
---|
| 94 | // browser should be deleted by the code which created it.
|
---|
| 95 | class browserptr {
|
---|
| 96 | public:
|
---|
| 97 | browserclass *b;
|
---|
| 98 |
|
---|
| 99 | browserptr () {b=NULL;}
|
---|
| 100 | };
|
---|
| 101 |
|
---|
| 102 | bool operator==(const browserptr &x, const browserptr &y);
|
---|
| 103 | bool operator<(const browserptr &x, const browserptr &y);
|
---|
| 104 |
|
---|
| 105 | typedef map<text_t, browserptr, lttext_t> browserptrmap;
|
---|
| 106 |
|
---|
| 107 | // contains a list of browsers indexed by their name
|
---|
| 108 | class browsermapclass {
|
---|
| 109 | protected:
|
---|
| 110 | browserptrmap browserptrs;
|
---|
| 111 | text_t defaultbrowser;
|
---|
| 112 |
|
---|
| 113 | public:
|
---|
| 114 | // type support for browserptrmap
|
---|
| 115 | typedef browserptrmap::iterator iterator;
|
---|
| 116 | typedef browserptrmap::const_iterator const_iterator;
|
---|
| 117 | typedef browserptrmap::reference reference;
|
---|
| 118 | typedef browserptrmap::const_reference const_reference;
|
---|
| 119 | typedef browserptrmap::size_type size_type;
|
---|
| 120 |
|
---|
| 121 | typedef browserptrmap::difference_type difference_type;
|
---|
| 122 | typedef browserptrmap::const_reverse_iterator const_reverse_iterator;
|
---|
| 123 | typedef browserptrmap::reverse_iterator reverse_iterator;
|
---|
| 124 |
|
---|
| 125 | // basic container support
|
---|
| 126 | iterator begin () {return browserptrs.begin();}
|
---|
| 127 | const_iterator begin () const {return browserptrs.begin();}
|
---|
| 128 | iterator end () {return browserptrs.end();}
|
---|
| 129 | const_iterator end () const {return browserptrs.end();}
|
---|
| 130 |
|
---|
| 131 | void erase(iterator pos) {browserptrs.erase(pos);}
|
---|
| 132 | void erase(iterator first, iterator last) {browserptrs.erase(first, last);}
|
---|
| 133 | browsermapclass &operator=(const browsermapclass &x) {browserptrs=x.browserptrs;return *this;}
|
---|
| 134 |
|
---|
| 135 | bool empty () const {return browserptrs.empty();}
|
---|
| 136 | size_type size() const {return browserptrs.size();}
|
---|
| 137 |
|
---|
| 138 |
|
---|
| 139 | // added functionality
|
---|
| 140 | void clear () {browserptrs.erase(browserptrs.begin(),browserptrs.end());}
|
---|
| 141 |
|
---|
| 142 | // thebrowserclass remains the property of the calling code but
|
---|
| 143 | // should not be deleted until it is removed from this list.
|
---|
| 144 | void addbrowser (browserclass *thebrowserclass);
|
---|
| 145 |
|
---|
| 146 | // getbrowser will return NULL if the browser could not be found
|
---|
| 147 | browserclass *getbrowser (const text_t &key);
|
---|
| 148 |
|
---|
| 149 | void setdefaultbrowser (const text_t &browsername);
|
---|
| 150 |
|
---|
| 151 | browserclass *get_default_browser ();
|
---|
| 152 | };
|
---|
| 153 |
|
---|
| 154 |
|
---|
| 155 | #endif
|
---|