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

Last change on this file since 757 was 752, checked in by sjboddie, 25 years ago

tidied things up slightly

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 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 * $Id: browserclass.cpp 752 1999-10-30 23:02:46Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.4 1999/10/30 23:02:46 sjboddie
31 tidied things up slightly
32
33 Revision 1.3 1999/10/30 22:40:00 sjboddie
34 added collection argument
35
36 Revision 1.2 1999/10/14 22:59:33 sjboddie
37 finished off browser classes
38
39 Revision 1.1 1999/10/10 08:14:03 sjboddie
40 - metadata now returns mp rather than array
41 - redesigned browsing support (although it's not finished so
42 won't currently work ;-)
43
44 */
45
46
47#include "browserclass.h"
48#include <assert.h>
49
50
51browserclass::browserclass () {
52}
53
54browserclass::~browserclass () {
55}
56
57// configure should be called once for each configuration line
58// the default version does nothing
59void browserclass::configure (const text_t &/*key*/, const text_tarray &/*cfgline*/) {
60}
61
62// init should be called after all the configuration is done but
63// before any other methods are called
64bool browserclass::init (ostream &/*logout*/) {
65 return true;
66}
67
68// returns the name that specifies the browserclass type
69text_t browserclass::get_browser_name () {
70 return "";
71}
72
73void browserclass::processOID (cgiargsclass &/*args*/, recptproto * /*collectproto*/, ostream &/*logout*/) {
74}
75
76void browserclass::load_metadata_defaults (text_tset &/*metadata*/) {
77}
78
79text_t browserclass::get_default_formatstring () {
80 return "<td>[link][icon][/link]</td><td>[highlight]{Or}{[Title],Untitled}[/highlight]</td>";
81}
82
83int browserclass::output_section_group (ResultDocInfo_t &/*section*/, cgiargsclass &/*args*/,
84 const text_t &/*collection*/, int /*colnumber*/,
85 format_t * /*formatlistptr*/, bool /*use_table*/,
86 text_tset &/*metadata*/, bool &/*getParents*/,
87 recptproto * /*collectproto*/, displayclass &/*disp*/,
88 outconvertclass &/*outconvert*/, ostream &/*textout*/,
89 ostream &/*logout*/) {
90 return 0;
91}
92
93int browserclass::output_section_group (FilterResponse_t &/*sections*/, cgiargsclass &/*args*/,
94 const text_t &/*collection*/, int /*colnumber*/,
95 format_t * /*formatlistptr*/, bool /*use_table*/,
96 text_tset &/*metadata*/, bool &/*getParents*/,
97 recptproto * /*collectproto*/, displayclass &/*disp*/,
98 outconvertclass &/*outconvert*/, ostream &/*textout*/,
99 ostream &/*logout*/) {
100 return 0;
101}
102
103bool operator==(const browserptr &x, const browserptr &y) {
104 return (x.b == y.b);
105}
106
107bool operator<(const browserptr &x, const browserptr &y) {
108 return (x.b < y.b);
109}
110
111// thebrowserclass remains the property of the calling code but
112// should not be deleted until it is removed from this list.
113void browsermapclass::addbrowser (browserclass *thebrowserclass) {
114 // can't add a null browserclass
115 assert (thebrowserclass != NULL);
116 if (thebrowserclass == NULL) return;
117
118 // can't add a browserclass with no name
119 assert (!(thebrowserclass->get_browser_name()).empty());
120 if ((thebrowserclass->get_browser_name()).empty()) return;
121
122 browserptr aptr;
123 aptr.b = thebrowserclass;
124 browserptrs[thebrowserclass->get_browser_name()] = aptr;
125}
126
127// getbrowser will return the default browser if the browser
128// could not be found
129browserclass *browsermapclass::getbrowser (const text_t &key) {
130 // can't find a browser with no name
131 if (key.empty()) return get_default_browser();
132
133 iterator here = browserptrs.find (key);
134 if (here == browserptrs.end()) return get_default_browser();
135
136 return (*here).second.b;
137}
138
139void browsermapclass::setdefaultbrowser (const text_t &browsername) {
140 defaultbrowser = browsername;
141}
142
143browserclass *browsermapclass::get_default_browser () {
144
145 iterator here = browserptrs.find (defaultbrowser);
146 if (here == browserptrs.end())
147 // we'll just take the first in the list if
148 // no valid default was set
149 here = browserptrs.begin();
150 return (*here).second.b;
151}
Note: See TracBrowser for help on using the repository browser.