summaryrefslogtreecommitdiff
path: root/project2/cgi/cgiAppEngine.h
diff options
context:
space:
mode:
Diffstat (limited to 'project2/cgi/cgiAppEngine.h')
-rw-r--r--project2/cgi/cgiAppEngine.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h
new file mode 100644
index 0000000..112e672
--- /dev/null
+++ b/project2/cgi/cgiAppEngine.h
@@ -0,0 +1,71 @@
+#ifndef CGIAPPENGINE_H
+#define CGIAPPENGINE_H
+
+#include "../appEngine.h"
+#include "../task.h"
+#include "../paramChecker.h"
+#include "../presenter.h"
+#include <boost/shared_ptr.hpp>
+#include <boost/uuid/uuid.hpp>
+#include <libxml++/document.h>
+#include <libxml++/parsers/domparser.h>
+
+class CgiEnvironment;
+class Session;
+namespace cgicc {
+ class HTTPContentHeader;
+}
+
+class CgiApplicationEngine : public ApplicationEngine {
+ public:
+ CgiApplicationEngine(const CgiEnvironment *);
+ virtual ~CgiApplicationEngine();
+
+ void process() const;
+ const cgicc::HTTPContentHeader * getHeader() const { return header; }
+ template <class Writer>
+ void write(const Writer & w) const
+ {
+ w(doc->cobj());
+ }
+ const Environment * env() const;
+ SessionPtr session() const;
+ PresenterPtr getPresenter(const std::string & group, const std::string & id) const;
+ const CgiEnvironment * _env;
+ protected:
+ mutable cgicc::HTTPContentHeader * header;
+ private:
+ mutable boost::shared_ptr<xmlpp::Document> doc;
+ class Stage {
+ public:
+ Stage(const CgiApplicationEngine *);
+ virtual ~Stage() = 0;
+ virtual Stage * run() = 0;
+ protected:
+ const CgiApplicationEngine * appEngine;
+ };
+ class RequestStage : public Stage {
+ public:
+ RequestStage(const CgiApplicationEngine *, const std::string & id);
+ virtual ~RequestStage();
+ virtual Stage * run();
+ std::string present;
+ protected:
+ OrderedParamCheckers parameterChecks;
+ NoOutputExecutes tasks;
+ };
+ class PresentStage : public Stage, public Presenter {
+ public:
+ PresentStage(const CgiApplicationEngine *, const std::string & id);
+ PresentStage(const CgiApplicationEngine *, const std::string & group, const std::string & id);
+ virtual ~PresentStage();
+ virtual Stage * run();
+ protected:
+ XmlDocumentPtr getDataDocument() const;
+ };
+ mutable Stage * currentStage;
+ mutable boost::uuids::uuid sessionID;
+};
+
+#endif
+