source: main/trunk/greenstone2/runtime-src/src/recpt/browserclass.h@ 22177

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

(Human Info) Added a clone method and two more output_section_group methods with different parameters.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 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 7428 2004-05-25 01:39:36Z 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 (ResultDocInfo_t &section, cgiargsclass &args,
96 const text_t &labels, 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 virtual int output_section_group (FilterResponse_t &sections, cgiargsclass &args,
104 const text_t &collection, int colnumber,
105 format_t *formatlistptr, bool use_table,
106 text_tset &metadata, bool &getParents,
107 recptproto *collectproto, displayclass &disp,
108 outconvertclass &outconvert, ostream &textout,
109 ostream &logout);
110
111 virtual int output_section_group (FilterResponse_t &sections, cgiargsclass &args,
112 const text_t& currentSection, const text_t &labels,
113 const text_t &collection, int colnumber,
114 format_t *formatlistptr, bool use_table,
115 text_tset &metadata, bool &getParents,
116 recptproto *collectproto, displayclass &disp,
117 outconvertclass &outconvert, ostream &textout,
118 ostream &logout);
119};
120
121
122// The browserptr function does not 'own' the browser. The
123// browser should be deleted by the code which created it.
124class browserptr {
125public:
126 browserclass *b;
127
128 browserptr () {b=NULL;}
129};
130
131bool operator==(const browserptr &x, const browserptr &y);
132bool operator<(const browserptr &x, const browserptr &y);
133
134typedef map<text_t, browserptr, lttext_t> browserptrmap;
135
136// contains a list of browsers indexed by their name
137class browsermapclass {
138protected:
139 browserptrmap browserptrs;
140 text_t defaultbrowser;
141
142public:
143 // type support for browserptrmap
144 typedef browserptrmap::iterator iterator;
145 typedef browserptrmap::const_iterator const_iterator;
146 typedef browserptrmap::reference reference;
147 typedef browserptrmap::const_reference const_reference;
148 typedef browserptrmap::size_type size_type;
149
150 typedef browserptrmap::difference_type difference_type;
151 typedef browserptrmap::const_reverse_iterator const_reverse_iterator;
152 typedef browserptrmap::reverse_iterator reverse_iterator;
153
154 // basic container support
155 iterator begin () {return browserptrs.begin();}
156 const_iterator begin () const {return browserptrs.begin();}
157 iterator end () {return browserptrs.end();}
158 const_iterator end () const {return browserptrs.end();}
159
160 void erase(iterator pos) {browserptrs.erase(pos);}
161 void erase(iterator first, iterator last) {browserptrs.erase(first, last);}
162 browsermapclass &operator=(const browsermapclass &x) {browserptrs=x.browserptrs;return *this;}
163
164 bool empty () const {return browserptrs.empty();}
165 size_type size() const {return browserptrs.size();}
166
167
168 // added functionality
169 void clear () {browserptrs.erase(browserptrs.begin(),browserptrs.end());}
170
171 // thebrowserclass remains the property of the calling code but
172 // should not be deleted until it is removed from this list.
173 void addbrowser (browserclass *thebrowserclass);
174
175 // getbrowser will return NULL if the browser could not be found
176 browserclass *getbrowser (const text_t &key);
177
178 // clone a browser; if not default and browser not found will return NULL
179 browserclass *clonebrowser (const text_t &key);
180
181 void setdefaultbrowser (const text_t &browsername);
182
183 browserclass *get_default_browser ();
184};
185
186
187#endif
Note: See TracBrowser for help on using the repository browser.