From c83bd40522678461c5e7ab2a8f2d8be07fe0679f Mon Sep 17 00:00:00 2001 From: randomdan Date: Fri, 30 Jul 2010 20:14:16 +0000 Subject: Accept and run checks before presentation --- project2/appEngine.h | 8 ++++---- project2/cgiAppEngine.cpp | 5 +++++ project2/cgiAppEngine.h | 2 +- project2/environment.h | 2 +- project2/presenter.cpp | 1 + project2/presenter.h | 2 ++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/project2/appEngine.h b/project2/appEngine.h index 54a8cec..ab8b588 100644 --- a/project2/appEngine.h +++ b/project2/appEngine.h @@ -8,10 +8,10 @@ class ApplicationEngine { public: - class UriElementOutOfRange : std::exception { }; - class ParamNotFound : std::exception { }; - class DataSourceNotFound : std::exception { }; - class DataSourceNotCompatible : std::exception { }; + class UriElementOutOfRange : public std::exception { }; + class ParamNotFound : public std::exception { }; + class DataSourceNotFound : public std::exception { }; + class DataSourceNotCompatible : public std::exception { }; ApplicationEngine(const Environment *); virtual ~ApplicationEngine() = 0; diff --git a/project2/cgiAppEngine.cpp b/project2/cgiAppEngine.cpp index 98009a1..51bc089 100644 --- a/project2/cgiAppEngine.cpp +++ b/project2/cgiAppEngine.cpp @@ -86,6 +86,11 @@ CgiApplicationEngine::PresentStage::~PresentStage() CgiApplicationEngine::Stage * CgiApplicationEngine::PresentStage::run() { + BOOST_FOREACH(OrderedParamCheckers::value_type pc, parameterChecks) { + if (!pc.second->performCheck(appEngine)) { + return new PresentStage(appEngine, pc.second->present); + } + } appEngine->doc = getDataDocument(); sessionsContainer->CleanUp(); return NULL; diff --git a/project2/cgiAppEngine.h b/project2/cgiAppEngine.h index a42cedd..c3bd137 100644 --- a/project2/cgiAppEngine.h +++ b/project2/cgiAppEngine.h @@ -43,7 +43,6 @@ class CgiApplicationEngine : public ApplicationEngine { virtual Stage * run() = 0; protected: const CgiApplicationEngine * appEngine; - OrderedParamCheckers parameterChecks; }; class RequestStage : public Stage { public: @@ -52,6 +51,7 @@ class CgiApplicationEngine : public ApplicationEngine { virtual Stage * run(); std::string present; protected: + OrderedParamCheckers parameterChecks; NoOutputExecutes tasks; }; class PresentStage : public Stage, public Presenter { diff --git a/project2/environment.h b/project2/environment.h index a8c6396..97ae4f1 100644 --- a/project2/environment.h +++ b/project2/environment.h @@ -6,7 +6,7 @@ class Environment { public: - class ParameterTypeNotSupported : std::exception { }; + class ParameterTypeNotSupported : public std::exception { }; Environment(); virtual ~Environment() = 0; diff --git a/project2/presenter.cpp b/project2/presenter.cpp index a471b3d..ee529ba 100644 --- a/project2/presenter.cpp +++ b/project2/presenter.cpp @@ -13,6 +13,7 @@ Presenter::Presenter(const std::string & group, const std::string & file) : Loaders loaders; _DataSource::AddLoaders(loaders, ApplicationEngine::getCurrent()->datasources); _View::AddLoaders(loaders, views); + _ParamChecker::AddLoaders(loaders, parameterChecks); _LoaderBase::collectAll(loaders, "project2", present.get_document()->get_root_node(), true, true); } diff --git a/project2/presenter.h b/project2/presenter.h index d862f1f..ae0a12b 100644 --- a/project2/presenter.h +++ b/project2/presenter.h @@ -5,6 +5,7 @@ #include #include #include "view.h" +#include "paramChecker.h" class Presenter { public: @@ -16,6 +17,7 @@ class Presenter { protected: Views views; + OrderedParamCheckers parameterChecks; xmlpp::DomParser present; public: const Glib::ustring responseRootNodeName; -- cgit v1.2.3