summaryrefslogtreecommitdiff
path: root/include/Action.h
blob: 329592c8b3c57867a51456a9fbf359f70588f8fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef __ACTION_H__
#define __ACTION_H__

#include <Task.h>
#include <Handle.h>
#include <Variables.h>
#include <Exceptions.h>
#include <HtmlSkinner.h>

//! This is the basic HTTP action.
/*!
  This pure virtual class contains the framework to build a basic HTTP action.
*/
class Action : public Base {
  public:
      //! The provided string should contain the url of that action.
      /*!
        If no URL is provided, one will be generated on the fly.
      */
      Action(const String & url = "", HtmlSkinner * = 0);
      virtual ~Action();
    //! Will recursively resolve an URL, and return the corresponding action, or NULL if not found.
    Action * Look4URL(const String &);
    //! This pure virtual method has to be filled. It will be launched if the URL is called.
    /*!
      This method will be called when the URL gets invoked. The vars variable will contain the POST
      or GET variables. The headers is a single list of the HTTP headers. And the out handle will
      be dumped as the output to the brower.
    */
    virtual Task * Do(Variables * vars, Variables * headers, Handle * out) = 0;
    //! This helper will dump the basic HTML headers.
    virtual void SendHead(Handle *);
    //! This helper will dump the basic HTML footers.
    virtual void SendFoot(Handle *);
    //! This helper will display a button.
    /*!
      The button will have the caption provided, and will redirect to the provided url.
    */
    virtual void ShowButton(Handle *, const String & caption = "    Ok    ", const String & url = "start");
    //! This pure virtual method has to gives the page title. Will be used in SendHead.
    virtual String GetTitle(void) = 0;
    //! This returns the recorded URL for that action.
    String GetURL(void);
    //! Mark this action to be erased as soon as the Do method ends.
    void CleanUp(void);
    //! Skinner accessor.
    HtmlSkinner * GetSkinner();
  
  protected:
    //! Mark this action as beeing accessed.
    void Accessed(void);
 
  private:
    static Action * start;
    Action * next, * prev;
    String URL;
    bool hastoclean, accessed;
    HtmlSkinner * skin;
};

#endif