source: trunk/gsdl/src/recpt/action.h@ 206

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

altered receptionist slightly so it now passes *collectproto to
define_internal_macros and define_external_macros - need it
for browseaction

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/**********************************************************************
2 *
3 * action.h --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: action.h 206 1999-03-25 03:06:45Z sjboddie $
9 *
10 *********************************************************************/
11
12
13#ifndef ACTION_H
14#define ACTION_H
15
16#include "gsdlconf.h"
17#include "text_t.h"
18#include "cgiargs.h"
19#include "display.h"
20#include "recptproto.h"
21
22#if defined(GSDL_USE_OBJECTSPACE)
23# include <ospace\std\iostream>
24#elif defined(GSDL_USE_IOS_H)
25# include <iostream.h>
26#else
27# include <iostream>
28#endif
29
30
31class action {
32protected:
33 cgiargsinfoclass argsinfo;
34
35
36public:
37 action ();
38 virtual ~action ();
39
40 // configure should be called once for each configuration line
41 virtual void configure (const text_t &key, const text_tarray &cfgline);
42
43 // init should be called after all the configuration is done but
44 // before any other methods are called
45 virtual bool init (ostream &logout);
46
47 // returns the "a" argument value that will specify this action
48 // this name should be short but does not have to be one character
49 // long
50 virtual text_t get_action_name ();
51
52 // check_cgiargs should be called before get_cgihead_info,
53 // define_external_macros, and do_action. If an error is found
54 // a message will be written to logout, if the error is severe
55 // then the function will return false and no page content
56 // should be produced based on the arguments.
57 virtual bool check_cgiargs (cgiargsclass &args, ostream &logout);
58
59 // get_cgihead_info determines the cgi header information for
60 // a set of cgi arguments. If response contains location then
61 // response_data contains the redirect address. If reponse
62 // contains content then reponse_data contains the content-type.
63 // Note that images can now be produced by the receptionist.
64 virtual void get_cgihead_info (cgiargsclass &args, response_t &response,
65 text_t &response_data, ostream &logout);
66
67 // uses_display should return true if the receptionist should return
68 // true if the display class is needed to output the page content.
69 // The default is to return true.
70 virtual bool uses_display (cgiargsclass &args);
71
72 // define all the macros which are related to pages generated
73 // by this action
74 virtual void define_internal_macros (displayclass &disp, cgiargsclass &args,
75 recptproto *collectproto, ostream &logout);
76
77 // define all the macros which might be used by other actions
78 // to produce pages. These macros should be well documented.
79 virtual void define_external_macros (displayclass &disp, cgiargsclass &args,
80 recptproto *collectproto, ostream &logout);
81
82 // returns false if there was an error which prevented the action
83 // from outputing anything.
84 virtual bool do_action (cgiargsclass &args, recptproto *collectproto,
85 displayclass &disp, outconvertclass &outconvert,
86 ostream &textout, ostream &logout);
87
88 // getargsinfo should be called after all configuration files
89 // have been read
90 cgiargsinfoclass getargsinfo () {return argsinfo;};
91};
92
93
94// The actionptr function does not 'own' the action. The
95// action should be deleted by the code which created it.
96class actionptr {
97public:
98 action *a;
99
100 actionptr () {a=NULL;}
101};
102
103typedef map<text_t, actionptr, lttext_t> actionptrmap;
104
105// contains a list of actions indexed by their name
106class actionmapclass {
107protected:
108 actionptrmap actionptrs;
109
110public:
111 // type support for actionptrmap
112 typedef actionptrmap::iterator iterator;
113 typedef actionptrmap::const_iterator const_iterator;
114 typedef actionptrmap::reference reference;
115 typedef actionptrmap::const_reference const_reference;
116 typedef actionptrmap::size_type size_type;
117
118 typedef actionptrmap::difference_type difference_type;
119 typedef actionptrmap::const_reverse_iterator const_reverse_iterator;
120 typedef actionptrmap::reverse_iterator reverse_iterator;
121
122 // basic container support
123 iterator begin () {return actionptrs.begin();}
124 const_iterator begin () const {return actionptrs.begin();}
125 iterator end () {return actionptrs.end();}
126 const_iterator end () const {return actionptrs.end();}
127
128 void erase(iterator pos) {actionptrs.erase(pos);}
129 void erase(iterator first, iterator last) {actionptrs.erase(first, last);}
130 actionmapclass &operator=(const actionmapclass &x) {actionptrs=x.actionptrs;return *this;}
131
132 bool empty () const {return actionptrs.empty();}
133 size_type size() const {return actionptrs.size();}
134
135
136 // added functionality
137 void clear () {actionptrs.erase(actionptrs.begin(),actionptrs.end());}
138
139 // theaction remains the property of the calling code but
140 // should not be deleted until it is removed from this list.
141 void addaction (action *theaction);
142
143 // getaction will return NULL if the action could not be found
144 action *getaction (const text_t &key);
145};
146
147
148#endif
Note: See TracBrowser for help on using the repository browser.