summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-07-30 20:14:16 +0000
committerrandomdan <randomdan@localhost>2010-07-30 20:14:16 +0000
commitc83bd40522678461c5e7ab2a8f2d8be07fe0679f (patch)
treee34e53a9652a4b5029eff74a33c46ecb9287e858
parentAdd optional support for default values for variables (diff)
downloadproject2-c83bd40522678461c5e7ab2a8f2d8be07fe0679f.tar.bz2
project2-c83bd40522678461c5e7ab2a8f2d8be07fe0679f.tar.xz
project2-c83bd40522678461c5e7ab2a8f2d8be07fe0679f.zip
Accept and run checks before presentation
-rw-r--r--project2/appEngine.h8
-rw-r--r--project2/cgiAppEngine.cpp5
-rw-r--r--project2/cgiAppEngine.h2
-rw-r--r--project2/environment.h2
-rw-r--r--project2/presenter.cpp1
-rw-r--r--project2/presenter.h2
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 <glibmm/ustring.h>
#include <libxml++/parsers/domparser.h>
#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;