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

Last change on this file since 7379 was 7379, checked in by mdewsnip, 20 years ago

(Human Info) Allow some browser classes to be easily switched off. Also added a clone function to every browser class.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 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 7379 2004-05-24 02:55:33Z mdewsnip $
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 virtual browserclass* clone() = 0;
63
64 // returns the name that specifies the browserclass type
65 virtual text_t get_browser_name ();
66
67 virtual void processOID (cgiargsclass &args, recptproto *collectproto, ostream &logout);
68
69 // load_metadata_defaults should be called before
70 // doing protocol call to get metadata for OID to
71 // be displayed by this browserclass. it adds fields
72 // to the metadata set that are needed by browserclass
73 // during display
74 virtual void load_metadata_defaults (text_tset &metadata);
75
76 virtual text_t get_default_formatstring ();
77
78 void set_filter_options (FilterRequest_t &request, cgiargsclass &args);
79
80 // output_section_group returns the number of tabs to add before displaying the
81 // next section group
82 // The first version takes one result of a search/query action, the
83 // second takes all the results; ResultDocInfo_t is actually a child struct
84 // of FilterResponse_t items. The second version tends to output parts of an
85 // abstract structure (e.g. for a table of contents/classifier list, the first
86 // for an individual document
87 virtual int output_section_group (ResultDocInfo_t &section, cgiargsclass &args,
88 const text_t &collection, int colnumber,
89 format_t *formatlistptr, bool use_table,
90 text_tset &metadata, bool &getParents,
91 recptproto *collectproto, displayclass &disp,
92 outconvertclass &outconvert, ostream &textout,
93 ostream &logout);
94
95 virtual int output_section_group (FilterResponse_t &sections, cgiargsclass &args,
96 const text_t &collection, int colnumber,
97 format_t *formatlistptr, bool use_table,
98 text_tset &metadata, bool &getParents,
99 recptproto *collectproto, displayclass &disp,
100 outconvertclass &outconvert, ostream &textout,
101 ostream &logout);
102};
103
104
105// The browserptr function does not 'own' the browser. The
106// browser should be deleted by the code which created it.
107class browserptr {
108public:
109 browserclass *b;
110
111 browserptr () {b=NULL;}
112};
113
114bool operator==(const browserptr &x, const browserptr &y);
115bool operator<(const browserptr &x, const browserptr &y);
116
117typedef map<text_t, browserptr, lttext_t> browserptrmap;
118
119// contains a list of browsers indexed by their name
120class browsermapclass {
121protected:
122 browserptrmap browserptrs;
123 text_t defaultbrowser;
124
125public:
126 // type support for browserptrmap
127 typedef browserptrmap::iterator iterator;
128 typedef browserptrmap::const_iterator const_iterator;
129 typedef browserptrmap::reference reference;
130 typedef browserptrmap::const_reference const_reference;
131 typedef browserptrmap::size_type size_type;
132
133 typedef browserptrmap::difference_type difference_type;
134 typedef browserptrmap::const_reverse_iterator const_reverse_iterator;
135 typedef browserptrmap::reverse_iterator reverse_iterator;
136
137 // basic container support
138 iterator begin () {return browserptrs.begin();}
139 const_iterator begin () const {return browserptrs.begin();}
140 iterator end () {return browserptrs.end();}
141 const_iterator end () const {return browserptrs.end();}
142
143 void erase(iterator pos) {browserptrs.erase(pos);}
144 void erase(iterator first, iterator last) {browserptrs.erase(first, last);}
145 browsermapclass &operator=(const browsermapclass &x) {browserptrs=x.browserptrs;return *this;}
146
147 bool empty () const {return browserptrs.empty();}
148 size_type size() const {return browserptrs.size();}
149
150
151 // added functionality
152 void clear () {browserptrs.erase(browserptrs.begin(),browserptrs.end());}
153
154 // thebrowserclass remains the property of the calling code but
155 // should not be deleted until it is removed from this list.
156 void addbrowser (browserclass *thebrowserclass);
157
158 // getbrowser will return NULL if the browser could not be found
159 browserclass *getbrowser (const text_t &key);
160
161 void setdefaultbrowser (const text_t &browsername);
162
163 browserclass *get_default_browser ();
164};
165
166
167#endif
Note: See TracBrowser for help on using the repository browser.