source: trunk/gsdl/src/recpt/browserclass.cpp@ 1861

Last change on this file since 1861 was 1285, checked in by sjboddie, 24 years ago

Removed CVS logging information from source files

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 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 "";
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 "";
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 (FilterResponse_t &/*sections*/, cgiargsclass &/*args*/,
103 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
112bool operator==(const browserptr &x, const browserptr &y) {
113 return (x.b == y.b);
114}
115
116bool operator<(const browserptr &x, const browserptr &y) {
117 return (x.b < y.b);
118}
119
120// thebrowserclass remains the property of the calling code but
121// should not be deleted until it is removed from this list.
122void browsermapclass::addbrowser (browserclass *thebrowserclass) {
123 // can't add a null browserclass
124 assert (thebrowserclass != NULL);
125 if (thebrowserclass == NULL) return;
126
127 // can't add a browserclass with no name
128 assert (!(thebrowserclass->get_browser_name()).empty());
129 if ((thebrowserclass->get_browser_name()).empty()) return;
130
131 browserptr aptr;
132 aptr.b = thebrowserclass;
133 browserptrs[thebrowserclass->get_browser_name()] = aptr;
134}
135
136// getbrowser will return the default browser if the browser
137// could not be found
138browserclass *browsermapclass::getbrowser (const text_t &key) {
139 // can't find a browser with no name
140 if (key.empty()) return get_default_browser();
141
142 iterator here = browserptrs.find (key);
143 if (here == browserptrs.end()) return get_default_browser();
144
145 return (*here).second.b;
146}
147
148void browsermapclass::setdefaultbrowser (const text_t &browsername) {
149 defaultbrowser = browsername;
150}
151
152browserclass *browsermapclass::get_default_browser () {
153
154 iterator here = browserptrs.find (defaultbrowser);
155 if (here == browserptrs.end())
156 // we'll just take the first in the list if
157 // no valid default was set
158 here = browserptrs.begin();
159 return (*here).second.b;
160}
Note: See TracBrowser for help on using the repository browser.