source: trunk/gsdl/src/recpt/receptionist.h@ 155

Last change on this file since 155 was 155, checked in by rjmcnab, 25 years ago

Got the receptionist producing something using the statusaction.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.7 KB
Line 
1/**********************************************************************
2 *
3 * receptionist.h -- a web interface for the gsdl
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: receptionist.h 155 1999-02-08 01:28:04Z rjmcnab $
9 *
10 *********************************************************************/
11
12
13#ifndef RECEPTIONIST_H
14#define RECEPTIONIST_H
15
16#include "gsdlconf.h"
17#include "text_t.h"
18#include "cgiargs.h"
19#include "display.h"
20#include "action.h"
21
22#ifndef MACROPRECEDENCE
23#define MACROPRECEDENCE "style,collection,queryversion,version,language"
24#endif
25
26
27class receptionist {
28public:
29 receptionist () {}
30 virtual ~receptionist() {}
31
32 // this version of set_gsdlhome should be used if the receptionist
33 // is being run for multiple collections ("general" mode).
34 void set_gsdlhome (const text_t &thegsdlhome);
35 text_t get_gsdlhome () {return gsdlhome;}
36
37 // this version of set_gsdlhome should be used if the receptionist
38 // is being run for a single collection ("collection specific" mode).
39 void set_gsdlhome (const text_t &thegsdlhome, const text_t &thecollection);
40 text_t get_collection () {return collection;}
41
42 // sets the http address of the images directory. This is used to
43 // speed up the access to the images which are a part of the general
44 // interface. If this is not set the interface will have to get the
45 // images via gwcgi which will be a lot slower (especially if the
46 // browser does not cache the images).
47 void set_httpimg (const text_t &thehttpimg) {httpimg=thehttpimg;}
48 text_t get_httpimg () {return httpimg;}
49
50 // sets the http address of the gateway cgi program (ie. the program
51 // that contains this receptionist).
52 void set_gwcgi (const text_t &thegwcgi) {gwcgi=thegwcgi;}
53 text_t get_gwcgi () {return gwcgi;}
54
55 // set_macrofiles defines the macro files which will be read when
56 // the init function is called.
57 void set_macrofiles (const text_tarray &themacrofiles) {macrofiles=themacrofiles;}
58 text_tarray get_macrofiles () {return macrofiles;}
59
60 // set_saveconf defines what should be included in the compressed
61 // arguments. This string should consist of cgi argument names
62 // seperated by "-".
63 void set_saveconf (const text_t &thesaveconf) {saveconf=thesaveconf;}
64 text_t get_saveconf () {return saveconf;}
65
66 // add_action makes another action available to the receptionist
67 // the action becomes the property of the receptionist
68 void add_action (action *theaction) {actions.addaction(theaction);}
69
70 // configure_actions should be called for each line in the
71 // configuration files to configure the actions. The configuration
72 // should take place after all the actions have been added.
73 void configure_actions (const text_t &key, const text_tarray &cfgline);
74
75 // init should be called after setgsdhome has been called.
76 // It returns true on success and false on failure. If false is
77 // returned getpage should not be called (without producing
78 // meaningless output), instead an error page should be
79 // produced by the calling code.
80 bool init (ostream &logout);
81
82 // There are two ways to produce a page. You can either call parse_cgi_args,
83 // get_cgihead_info, and produce_content or you can just call parse_cgi_args and
84 // produce_cgi_page (which will be satisfactory in most cases). You might want to call
85 // parse_cgi_args, get_cgihead_info, and produce_content when you want to
86 // interface directly with a web server for which the standard header is inappropriate.
87
88 // parse_cgi_args parses cgi arguments into an argument class.
89 // This function should be called for each page request. It returns false
90 // if there was a major problem with the cgi arguments.
91 bool parse_cgi_args (const text_t &argstr, cgiargsclass &args, ostream &logout);
92
93 // produce_cgi_page will call get_cgihead_info and
94 // produce_content in the appropriate way to output a cgi header and
95 // the page content (if needed). If a page could not be created it
96 // will return false
97 bool produce_cgi_page (cgiargsclass &args, ostream &contentout,
98 ostream &logout);
99
100 // get_cgihead_info determines the cgi header information for
101 // a set of cgi arguments. If response contains location then
102 // response_data contains the redirect address. If reponse
103 // contains content then reponse_data contains the content-type.
104 // Note that images can now be produced by the receptionist.
105 void get_cgihead_info (cgiargsclass &args, response_t &response,
106 text_t &response_data, ostream &logout);
107
108 // produce the page content
109 bool produce_content (cgiargsclass &args, ostream &contentout,
110 ostream &logout);
111
112 // returns the compressed argument ("e") corresponding to the argument
113 // list. This can be used to save preferences between sessions.
114 text_t get_compressed_arg (const cgiargsclass &args);
115
116protected:
117 text_t gsdlhome;
118 text_t collectdir; // will equal gsdlhome in 'general' mode
119 text_t collection; // will equal "" in 'general' mode
120 text_t httpimg;
121 text_t gwcgi;
122
123 displayclass disp;
124 text_tarray macrofiles;
125
126 text_t saveconf;
127 cgiargsinfoclass argsinfo;
128 actionmapclass actions;
129
130 // will read in all the macro files. If one is not found an
131 // error message will be written to logout and the method will
132 // return false.
133 bool read_macrofiles (ostream &logout);
134
135 // Will define the main general arguments used by the receptionist.
136 // If an error occurs a message will be written to logout and the
137 // method will return false.
138 virtual bool define_mainargs (ostream &logout);
139
140 // check_mainargs will check all the main arguments. If a major
141 // error is found it will return false and no cgi page should
142 // be created using the arguments.
143 virtual bool check_mainargs (cgiargsclass &args, ostream &logout);
144};
145
146
147#endif
Note: See TracBrowser for help on using the repository browser.