source: main/tags/2.80/gsdl/src/recpt/browserclass.cpp@ 24528

Last change on this file since 24528 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.4 KB
Line 
1/**********************************************************************
2 *
3 * browserclass.cpp --
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 *********************************************************************/
25
26#include "browserclass.h"
27#include <assert.h>
28
29
30browserclass::browserclass () {
31}
32
33browserclass::~browserclass () {
34}
35
36// configure should be called once for each configuration line
37// the default version does nothing
38void browserclass::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
39}
40
41// init should be called after all the configuration is done but
42// before any other methods are called
43bool browserclass::init (ostream &/*logout*/) {
44 return true;
45}
46
47// returns the name that specifies the browserclass type
48text_t browserclass::get_browser_name () {
49 return g_EmptyText;
50}
51
52void browserclass::processOID (cgiargsclass &/*args*/, recptproto * /*collectproto*/, ostream &/*logout*/) {
53}
54
55void browserclass::load_metadata_defaults (text_tset &/*metadata*/) {
56}
57
58text_t browserclass::get_default_formatstring () {
59 return g_EmptyText;
60}
61
62void browserclass::set_filter_options (FilterRequest_t &request, cgiargsclass &args) {
63
64 OptionValue_t option;
65
66 if (args["a"] == "q") {
67 int arg_m = args.getintarg("m");
68
69 option.name = "StartResults";
70 option.value = args["r"];
71 request.filterOptions.push_back (option);
72
73 option.name = "EndResults";
74 int endresults = args.getintarg("o") + (args.getintarg("r") - 1);
75 // int endresults = (args.getintarg("o")*3) + (args.getintarg("r") - 1);
76 if ((endresults > arg_m) && (arg_m != -1)) endresults = arg_m;
77 option.value = endresults;
78 request.filterOptions.push_back (option);
79
80 } else {
81 option.name = "StartResults";
82 option.value = args["r"];
83 request.filterOptions.push_back (option);
84
85 option.name = "EndResults";
86 int endresults = 20 + (args.getintarg("r") - 1);
87 option.value = endresults;
88 request.filterOptions.push_back (option);
89 }
90}
91
92int browserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/,
93 const text_t &/*collection*/, int /*colnumber*/,
94 format_t * /*formatlistptr*/, bool /*use_table*/,
95 text_tset &/*metadata*/, bool &/*getParents*/,
96 recptproto * /*collectproto*/, displayclass &/*disp*/,
97 outconvertclass &/*outconvert*/, ostream &/*textout*/,
98 ostream &/*logout*/) {
99 return 0;
100}
101
102int browserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/,
103 const text_t &/*labels*/, const text_t &/*collection*/, int /*colnumber*/,
104 format_t * /*formatlistptr*/, bool /*use_table*/,
105 text_tset &/*metadata*/, bool &/*getParents*/,
106 recptproto * /*collectproto*/, displayclass &/*disp*/,
107 outconvertclass &/*outconvert*/, ostream &/*textout*/,
108 ostream &/*logout*/) {
109 return 0;
110}
111
112int browserclass::output_section_group (FilterResponse_t &/*sections*/, cgiargsclass &/*args*/,
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 return 0;
120}
121
122int browserclass::output_section_group (FilterResponse_t &/*sections*/, cgiargsclass &/*args*/,
123 const text_t& /*currentSection*/, const text_t &/*labels*/, const text_t &/*collection*/, int /*colnumber*/,
124 format_t * /*formatlistptr*/, bool /*use_table*/,
125 text_tset &/*metadata*/, bool &/*getParents*/,
126 recptproto * /*collectproto*/, displayclass &/*disp*/,
127 outconvertclass &/*outconvert*/, ostream &/*textout*/,
128 ostream &/*logout*/)
129{
130 return 0;
131}
132
133bool operator==(const browserptr &x, const browserptr &y) {
134 return (x.b == y.b);
135}
136
137bool operator<(const browserptr &x, const browserptr &y) {
138 return (x.b < y.b);
139}
140
141// thebrowserclass remains the property of the calling code but
142// should not be deleted until it is removed from this list.
143void browsermapclass::addbrowser (browserclass *thebrowserclass) {
144 // can't add a null browserclass
145 assert (thebrowserclass != NULL);
146 if (thebrowserclass == NULL) return;
147
148 // can't add a browserclass with no name
149 assert (!(thebrowserclass->get_browser_name()).empty());
150 if ((thebrowserclass->get_browser_name()).empty()) return;
151
152 browserptr aptr;
153 aptr.b = thebrowserclass;
154 browserptrs[thebrowserclass->get_browser_name()] = aptr;
155}
156
157// getbrowser will return the default browser if the browser
158// could not be found
159browserclass *browsermapclass::getbrowser (const text_t &key) {
160 // can't find a browser with no name
161 if (key.empty()) return get_default_browser();
162
163 iterator here = browserptrs.find (key);
164 if (here == browserptrs.end()) return get_default_browser();
165
166 return (*here).second.b;
167}
168
169browserclass *browsermapclass::clonebrowser (const text_t &key) {
170 browserclass *browser = NULL;
171 if (key.empty()) {
172 browser = get_default_browser();
173 } else {
174 iterator here = browserptrs.find (key);
175 if (here == browserptrs.end())
176 browser = get_default_browser();
177 else
178 browser = here->second.b;
179 }
180 if (browser != NULL) {
181 browser = browser->clone();
182 }
183 return browser;
184}
185
186void browsermapclass::setdefaultbrowser (const text_t &browsername) {
187 defaultbrowser = browsername;
188}
189
190browserclass *browsermapclass::get_default_browser () {
191
192 iterator here = browserptrs.find (defaultbrowser);
193 if (here == browserptrs.end())
194 // we'll just take the first in the list if
195 // no valid default was set
196 here = browserptrs.begin();
197 return (*here).second.b;
198}
Note: See TracBrowser for help on using the repository browser.