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

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

finished off browser classes

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