source: trunk/gsdl/src/recpt/browserclass.h@ 793

Last change on this file since 793 was 765, checked in by sjboddie, 25 years ago

just a few small changes (that means I can't remember ;)

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
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 765 1999-11-01 22:04:12Z 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
48class browserclass {
49protected:
50
51public:
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
65 virtual void processOID (cgiargsclass &args, recptproto *collectproto, ostream &logout);
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 void set_filter_options (FilterRequest_t &request, cgiargsclass &args);
77
78 // returns the number of tabs to add before displaying the
79 // next section group
80 virtual int output_section_group (ResultDocInfo_t &section, cgiargsclass &args,
81 const text_t &collection, int colnumber,
82 format_t *formatlistptr, bool use_table,
83 text_tset &metadata, bool &getParents,
84 recptproto *collectproto, displayclass &disp,
85 outconvertclass &outconvert, ostream &textout,
86 ostream &logout);
87
88 virtual int output_section_group (FilterResponse_t &sections, cgiargsclass &args,
89 const text_t &collection, int colnumber,
90 format_t *formatlistptr, bool use_table,
91 text_tset &metadata, bool &getParents,
92 recptproto *collectproto, displayclass &disp,
93 outconvertclass &outconvert, ostream &textout,
94 ostream &logout);
95};
96
97
98// The browserptr function does not 'own' the browser. The
99// browser should be deleted by the code which created it.
100class browserptr {
101public:
102 browserclass *b;
103
104 browserptr () {b=NULL;}
105};
106
107bool operator==(const browserptr &x, const browserptr &y);
108bool operator<(const browserptr &x, const browserptr &y);
109
110typedef map<text_t, browserptr, lttext_t> browserptrmap;
111
112// contains a list of browsers indexed by their name
113class browsermapclass {
114protected:
115 browserptrmap browserptrs;
116 text_t defaultbrowser;
117
118public:
119 // type support for browserptrmap
120 typedef browserptrmap::iterator iterator;
121 typedef browserptrmap::const_iterator const_iterator;
122 typedef browserptrmap::reference reference;
123 typedef browserptrmap::const_reference const_reference;
124 typedef browserptrmap::size_type size_type;
125
126 typedef browserptrmap::difference_type difference_type;
127 typedef browserptrmap::const_reverse_iterator const_reverse_iterator;
128 typedef browserptrmap::reverse_iterator reverse_iterator;
129
130 // basic container support
131 iterator begin () {return browserptrs.begin();}
132 const_iterator begin () const {return browserptrs.begin();}
133 iterator end () {return browserptrs.end();}
134 const_iterator end () const {return browserptrs.end();}
135
136 void erase(iterator pos) {browserptrs.erase(pos);}
137 void erase(iterator first, iterator last) {browserptrs.erase(first, last);}
138 browsermapclass &operator=(const browsermapclass &x) {browserptrs=x.browserptrs;return *this;}
139
140 bool empty () const {return browserptrs.empty();}
141 size_type size() const {return browserptrs.size();}
142
143
144 // added functionality
145 void clear () {browserptrs.erase(browserptrs.begin(),browserptrs.end());}
146
147 // thebrowserclass remains the property of the calling code but
148 // should not be deleted until it is removed from this list.
149 void addbrowser (browserclass *thebrowserclass);
150
151 // getbrowser will return NULL if the browser could not be found
152 browserclass *getbrowser (const text_t &key);
153
154 void setdefaultbrowser (const text_t &browsername);
155
156 browserclass *get_default_browser ();
157};
158
159
160#endif
Note: See TracBrowser for help on using the repository browser.