summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-12-01 12:02:19 +0000
committerrandomdan <randomdan@localhost>2011-12-01 12:02:19 +0000
commitee67c0014c98ee9db85f3b53a4df75632bdcf2b1 (patch)
tree9d1e3a85de01ab3815c3e4c5ca6ec7d36e5b98dc
parentAdd the singleton view for accessing non-rowView data (diff)
downloadproject2-ee67c0014c98ee9db85f3b53a4df75632bdcf2b1.tar.bz2
project2-ee67c0014c98ee9db85f3b53a4df75632bdcf2b1.tar.xz
project2-ee67c0014c98ee9db85f3b53a4df75632bdcf2b1.zip
Control what application engine data is added to the output presenter
-rw-r--r--project2/cgi/cgiAppEngine.cpp106
-rw-r--r--project2/cgi/cgiAppEngine.h7
-rw-r--r--project2/cgi/cgiOutputOptions.cpp19
-rw-r--r--project2/cgi/cgiOutputOptions.h22
-rw-r--r--project2/cgi/cgiStagePresent.cpp1
-rw-r--r--project2/common/appEngine.h2
6 files changed, 106 insertions, 51 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index f647b0e..779b25a 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -82,8 +82,8 @@ CgiApplicationEngine::process() const
endTime = boost::date_time::microsec_clock<boost::posix_time::ptime>::universal_time();
ResponseStagePtr rs = currentStage.get<1>();
if (currentStage.get<3>()) {
- addAppData(currentStage.get<3>().get());
- addEnvData(currentStage.get<3>().get());
+ addAppData(currentStage.get<3>().get(), rs->outputOptions);
+ addEnvData(currentStage.get<3>().get(), rs->outputOptions);
}
HttpHeaderPtr header = rs->getHeader();
if (!sessionEmpty || !cursession->Empty()) {
@@ -117,40 +117,46 @@ CgiApplicationEngine::Stage::~Stage()
}
void
-CgiApplicationEngine::addEnvData(const MultiRowSetPresenter * p) const
+CgiApplicationEngine::addEnvData(const MultiRowSetPresenter * p, OutputOptionsPtr o) const
{
- // Environment set up by web server
- p->addNewRowSet("environment", env()->xmlPrefix);
- // Server stuff
- addEnvToPresenter(p, "servername", &cgicc::CgiEnvironment::getServerName);
- addEnvToPresenter(p, "serversoftware", &cgicc::CgiEnvironment::getServerSoftware);
- addEnvToPresenter(p, "serverprotocol", &cgicc::CgiEnvironment::getServerProtocol);
- addEnvToPresenter(p, "serverport", &cgicc::CgiEnvironment::getServerPort);
- addEnvToPresenter(p, "serverhttps", &cgicc::CgiEnvironment::usingHTTPS);
- // Request stuff
- addEnvToPresenter(p, "referrer", &cgicc::CgiEnvironment::getReferrer);
- addEnvToPresenter(p, "querystring", &cgicc::CgiEnvironment::getQueryString);
- p->finishRowSet();
+ if (!o || o->Environment()) {
+ // Environment set up by web server
+ p->addNewRowSet("environment", env()->xmlPrefix);
+ // Server stuff
+ addEnvToPresenter(p, "servername", &cgicc::CgiEnvironment::getServerName);
+ addEnvToPresenter(p, "serversoftware", &cgicc::CgiEnvironment::getServerSoftware);
+ addEnvToPresenter(p, "serverprotocol", &cgicc::CgiEnvironment::getServerProtocol);
+ addEnvToPresenter(p, "serverport", &cgicc::CgiEnvironment::getServerPort);
+ addEnvToPresenter(p, "serverhttps", &cgicc::CgiEnvironment::usingHTTPS);
+ // Request stuff
+ addEnvToPresenter(p, "referrer", &cgicc::CgiEnvironment::getReferrer);
+ addEnvToPresenter(p, "querystring", &cgicc::CgiEnvironment::getQueryString);
+ p->finishRowSet();
+ }
- // URL elements
- p->addNewRowSet("uriElems", env()->xmlPrefix);
- p->addAttribute("full", _env->getRedirectURL());
- BOOST_FOREACH(std::string s, _env->elems) {
- p->addNewRow("uriElem");
- p->addAttribute("text", s);
- p->finishRow();
+ if (!o || o->URL()) {
+ // URL elements
+ p->addNewRowSet("uriElems", env()->xmlPrefix);
+ p->addAttribute("full", _env->getRedirectURL());
+ BOOST_FOREACH(std::string s, _env->elems) {
+ p->addNewRow("uriElem");
+ p->addAttribute("text", s);
+ p->finishRow();
+ }
+ p->finishRowSet();
}
- p->finishRowSet();
-
- // Parameters
- p->addNewRowSet("params", env()->xmlPrefix);
- BOOST_FOREACH(cgicc::FormEntry fe, _env->cgi->getElements()) {
- p->addNewRow("param");
- p->addAttribute("name", fe.getName());
- p->addAttribute("value", fe.getValue());
- p->finishRow();
+
+ if (!o || o->Parameters()) {
+ // Parameters
+ p->addNewRowSet("params", env()->xmlPrefix);
+ BOOST_FOREACH(cgicc::FormEntry fe, _env->cgi->getElements()) {
+ p->addNewRow("param");
+ p->addAttribute("name", fe.getName());
+ p->addAttribute("value", fe.getValue());
+ p->finishRow();
+ }
+ p->finishRowSet();
}
- p->finishRowSet();
}
void
@@ -163,23 +169,29 @@ CgiApplicationEngine::addVarToPresenter(const MultiRowSetPresenter * p, const Gl
}
void
-CgiApplicationEngine::addAppData(const MultiRowSetPresenter * p) const
+CgiApplicationEngine::addAppData(const MultiRowSetPresenter * p, OutputOptionsPtr o) const
{
- addCoreAppData(p);
- // Sessions variables
- p->addNewRowSet("session", env()->xmlPrefix);
- p->addAttribute("id", cursession->ID.str());
- cursession->ForeachValue(boost::bind(&CgiApplicationEngine::addVarToPresenter, this, p, _1, _2));
- p->finishRowSet();
-
- // Timing info
- p->addNewRowSet("timing", env()->xmlPrefix);
- p->addAttribute("start", startTime);
- if (!endTime.is_not_a_date_time()) {
- p->addAttribute("end", endTime);
- p->addAttribute("duration", (endTime - startTime).total_milliseconds());
+ if (!o || o->Core()) {
+ addCoreAppData(p);
+ }
+ if (!o || o->Session()) {
+ // Sessions variables
+ p->addNewRowSet("session", env()->xmlPrefix);
+ p->addAttribute("id", cursession->ID.str());
+ cursession->ForeachValue(boost::bind(&CgiApplicationEngine::addVarToPresenter, this, p, _1, _2));
+ p->finishRowSet();
+ }
+
+ if (!o || o->Timing()) {
+ // Timing info
+ p->addNewRowSet("timing", env()->xmlPrefix);
+ p->addAttribute("start", startTime);
+ if (!endTime.is_not_a_date_time()) {
+ p->addAttribute("end", endTime);
+ p->addAttribute("duration", (endTime - startTime).total_milliseconds());
+ }
+ p->finishRowSet();
}
- p->finishRowSet();
}
SessionPtr
diff --git a/project2/cgi/cgiAppEngine.h b/project2/cgi/cgiAppEngine.h
index 88419fb..e837b9d 100644
--- a/project2/cgi/cgiAppEngine.h
+++ b/project2/cgi/cgiAppEngine.h
@@ -13,6 +13,7 @@
#include "sessionContainer.h"
#include <boost/intrusive_ptr.hpp>
#include <boost/tuple/tuple.hpp>
+#include "cgiOutputOptions.h"
class CgiEnvironment;
class Session;
@@ -36,8 +37,8 @@ class CgiApplicationEngine : public ApplicationEngine, public TransformChainLink
const Environment * env() const;
SessionPtr session() const;
virtual Glib::ustring resolveCurrentConfig() const;
- void addAppData(const MultiRowSetPresenter * p) const;
- void addEnvData(const MultiRowSetPresenter * p) const;
+ void addAppData(const MultiRowSetPresenter * p, OutputOptionsPtr) const;
+ void addEnvData(const MultiRowSetPresenter * p, OutputOptionsPtr) const;
const CgiEnvironment * _env;
private:
@@ -78,6 +79,8 @@ class CgiApplicationEngine : public ApplicationEngine, public TransformChainLink
public:
ResponseStage(const CgiEnvironment * e);
virtual HttpHeaderPtr getHeader() const = 0;
+
+ OutputOptionsPtr outputOptions;
};
/// Stage implementation used to bootstrap the iteration process based on the CGI environment
diff --git a/project2/cgi/cgiOutputOptions.cpp b/project2/cgi/cgiOutputOptions.cpp
new file mode 100644
index 0000000..6e22641
--- /dev/null
+++ b/project2/cgi/cgiOutputOptions.cpp
@@ -0,0 +1,19 @@
+#include "cgiOutputOptions.h"
+
+OutputOptions::OutputOptions(const xmlpp::Element * p) :
+ Core(p, "core", false, true),
+ Session(p, "session", false, true),
+ Timing(p, "timing", false, true),
+ Environment(p, "environment", false, true),
+ URL(p, "url", false, true),
+ Parameters(p, "parameters", false, true)
+{
+}
+
+OutputOptionsPtr
+OutputOptionsLoader::createFrom(const xmlpp::Element * e) const {
+ return new OutputOptions(e);
+}
+
+DECLARE_CUSTOM_COMPONENT_LOADER("outputoptions", OutputOptions, OutputOptionsLoader, OutputOptionsLoader)
+
diff --git a/project2/cgi/cgiOutputOptions.h b/project2/cgi/cgiOutputOptions.h
new file mode 100644
index 0000000..48579cd
--- /dev/null
+++ b/project2/cgi/cgiOutputOptions.h
@@ -0,0 +1,22 @@
+#include "intrusivePtrBase.h"
+
+#include "variables.h"
+namespace xmlpp {
+ class Element;
+}
+class OutputOptions : public IntrusivePtrBase {
+ public:
+ OutputOptions(const xmlpp::Element *);
+
+ const Variable Core;
+ const Variable Session;
+ const Variable Timing;
+ const Variable Environment;
+ const Variable URL;
+ const Variable Parameters;
+};
+typedef boost::intrusive_ptr<OutputOptions> OutputOptionsPtr;
+class OutputOptionsLoader : public ComponentLoader {
+ public:
+ virtual OutputOptionsPtr createFrom(const xmlpp::Element * e) const;
+};
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index d8af5d9..54b0e02 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -11,6 +11,7 @@ CgiApplicationEngine::PresentStage::PresentStage(const CgiEnvironment * e, const
CheckHost(path),
ViewHost(path)
{
+ loader.supportedStorers.insert(Storer::into<OutputOptionsLoader>(&outputOptions));
}
CgiApplicationEngine::NextStage
diff --git a/project2/common/appEngine.h b/project2/common/appEngine.h
index 19df823..85e7229 100644
--- a/project2/common/appEngine.h
+++ b/project2/common/appEngine.h
@@ -27,8 +27,6 @@ class ApplicationEngine : public Configuration {
virtual void process() const = 0;
virtual const Environment * env() const = 0;
virtual SessionPtr session() const = 0;
- virtual void addAppData(const MultiRowSetPresenter * p) const = 0;
- virtual void addEnvData(const MultiRowSetPresenter * p) const = 0;
static ApplicationEngine * getCurrent() { return currentEngine; }