root/trunk/cstr/src/recpt/cstrlibrarymain.cpp @ 891

Revision 891, 5.2 KB (checked in by sjboddie, 20 years ago)

Initial revision

  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 * cstrlibrarymain.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$
25 *
26 *********************************************************************/
27
28/*
29   $Log$
30   Revision 1.1  2000/02/01 22:32:37  sjboddie
31   Initial revision
32
33   Revision 1.1  1999/09/07 21:49:43  sjboddie
34   new cstr receptionist
35
36 */
37
38#include "receptionist.h"
39#include "cgiwrapper.h"
40#include "nullproto.h"
41#include "collectserver.h"
42#include "filter.h"
43#include "browsefilter.h"
44#include "queryfilter.h"
45#include "infodbclass.h"
46#include "mgsearch.h"
47#include "mggdbmsource.h"
48#include "fileutil.h"
49#include <assert.h>
50
51#include "action.h"
52#include "statusaction.h"
53#include "pageaction.h"
54#include "pingaction.h"
55#include "queryaction.h"
56#include "cstrdocaction.h"
57#include "authenaction.h"
58#include "usersaction.h"
59#include "authenaction.h"
60
61#include "browserclass.h"
62#include "vlistbrowserclass.h"
63#include "hlistbrowserclass.h"
64#include "datelistbrowserclass.h"
65#include "invbrowserclass.h"
66#include "pagedbrowserclass.h"
67#include "htmlbrowserclass.h"
68
69#include "gsdlhome.h"
70
71
72int main () {
73  receptionist recpt;
74  nullproto nproto;
75 
76  // add a collection server
77  text_tarray collections;
78  collections.push_back ("cstr");
79
80  text_tarray::const_iterator thiscol = collections.begin();
81  text_tarray::const_iterator endcol = collections.end();
82
83  while (thiscol != endcol) {
84
85    // this memory is created but never destroyed
86    // we're also not doing any error checking to make sure we didn't
87    // run out of memory
88    collectserver *cserver = new collectserver();
89    gdbmclass *gdbmhandler = new gdbmclass();
90    mgsearchclass *mgsearch = new mgsearchclass();
91   
92    // add a null filter
93    filterclass *filter = new filterclass ();
94    cserver->add_filter (filter);
95   
96    // add a browse filter
97    browsefilterclass *browsefilter = new browsefilterclass();
98    browsefilter->set_gdbmptr (gdbmhandler);
99    cserver->add_filter (browsefilter);
100   
101    // add a query filter
102    queryfilterclass *queryfilter = new queryfilterclass();
103    queryfilter->set_gdbmptr (gdbmhandler);
104    queryfilter->set_mgsearchptr (mgsearch);
105    cserver->add_filter (queryfilter);
106
107    // add a mg and gdbm source
108    mggdbmsourceclass *mggdbmsource = new mggdbmsourceclass ();
109    mggdbmsource->set_gdbmptr (gdbmhandler);
110    mggdbmsource->set_mgsearchptr (mgsearch);
111    cserver->add_source (mggdbmsource);
112   
113    // inform collection server and everything it contains about its
114    // collection name
115    cserver->configure ("collection", *thiscol);
116   
117    nproto.add_collectserver (cserver);
118    thiscol ++;
119  }
120 
121  // add the protocol to the receptionist
122  recpt.add_protocol (&nproto);
123
124  // add other converters
125  utf8inconvertclass utf8inconvert;
126  utf8outconvertclass utf8outconvert;
127  recpt.add_converter ("u", &utf8inconvert, &utf8outconvert);
128
129  mapinconvertclass gbinconvert;
130  gbinconvert.setmapfile (GSDL_GSDLHOME, "gbku", 0x25a1);
131  mapoutconvertclass gboutconvert;
132  gboutconvert.setmapfile (GSDL_GSDLHOME, "ugbk", 0xa1f5);
133  recpt.add_converter ("g", &gbinconvert, &gboutconvert);
134
135  // the list of actions. Note: these actions will become invalid
136  // at the end of this function.
137  statusaction astatusaction;
138  astatusaction.set_receptionist (&recpt);
139  recpt.add_action (&astatusaction);
140
141  pageaction apageaction;
142  recpt.add_action (&apageaction);
143
144  pingaction apingaction;
145  recpt.add_action (&apingaction);
146
147  queryaction aqueryaction;
148  recpt.add_action (&aqueryaction);
149
150  cstrdocaction adocumentaction;
151  recpt.add_action (&adocumentaction);
152
153  usersaction ausersaction;
154  recpt.add_action (&ausersaction);
155
156  authenaction aauthenaction;
157  aauthenaction.set_receptionist(&recpt);
158  recpt.add_action (&aauthenaction);
159
160  // list of browsers
161  vlistbrowserclass avlistbrowserclass;
162  recpt.add_browser (&avlistbrowserclass);
163  recpt.setdefaultbrowser ("VList");
164
165  hlistbrowserclass ahlistbrowserclass;
166  recpt.add_browser (&ahlistbrowserclass);
167
168  datelistbrowserclass adatelistbrowserclass;
169  recpt.add_browser (&adatelistbrowserclass);
170
171  invbrowserclass ainvbrowserclass;
172  recpt.add_browser (&ainvbrowserclass);
173
174  pagedbrowserclass apagedbrowserclass;
175  recpt.add_browser (&apagedbrowserclass);
176
177  htmlbrowserclass ahtmlbrowserclass;
178  recpt.add_browser (&ahtmlbrowserclass);
179
180  cgiwrapper (recpt, "cstr");
181  return 0;
182}
183
Note: See TracBrowser for help on using the browser.