#ifndef __ACTION_H__ #define __ACTION_H__ #include #include #include #include //! 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 = ""); 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); protected: //! Mark this action as beeing accessed. void Accessed(void); private: static Action * start; Action * next, * prev; String URL; bool hastoclean, accessed; }; #endif