From 4d01f7e59b02e90ab1cc15c55d130fa249b4cc70 Mon Sep 17 00:00:00 2001 From: randomdan Date: Thu, 1 Jul 2010 20:13:49 +0000 Subject: Keep the source DOM tree in memory and use it to implement rawview --- project2/cgiAppEngine.cpp | 6 +++--- project2/cgiAppEngine.h | 2 ++ project2/p2webMain.cpp | 1 + project2/rawView.cpp | 28 ++++++++++++++++++++++++++++ project2/rawView.h | 24 ++++++++++++++++++++++++ project2/sessionClearTask.cpp | 3 ++- project2/view.cpp | 2 ++ 7 files changed, 62 insertions(+), 4 deletions(-) create mode 100644 project2/rawView.cpp create mode 100644 project2/rawView.h diff --git a/project2/cgiAppEngine.cpp b/project2/cgiAppEngine.cpp index d3fbe80..60b1ed3 100644 --- a/project2/cgiAppEngine.cpp +++ b/project2/cgiAppEngine.cpp @@ -3,7 +3,6 @@ #include #include #include "cgiEnvironment.h" -#include #include #include "xmlObjectLoader.h" #include "rdbmsDataSource.h" @@ -71,9 +70,10 @@ CgiApplicationEngine::Stage::~Stage() { } -CgiApplicationEngine::PresentStage::PresentStage(const CgiApplicationEngine * e, const std::string & id) : CgiApplicationEngine::Stage(e) +CgiApplicationEngine::PresentStage::PresentStage(const CgiApplicationEngine * e, const std::string & id) : + CgiApplicationEngine::Stage(e), + present("present/" + id + ".xml") { - xmlpp::DomParser present("present/" + id + ".xml"); while (xmlXIncludeProcessFlags(present.get_document()->cobj(), XML_PARSE_NOXINCNODE) > 0); xmlpp::Element * presentRoot = present.get_document()->get_root_node(); responseRootNodeName = presentRoot->get_attribute_value("root"); diff --git a/project2/cgiAppEngine.h b/project2/cgiAppEngine.h index 9532ed4..f6f37d0 100644 --- a/project2/cgiAppEngine.h +++ b/project2/cgiAppEngine.h @@ -7,6 +7,7 @@ #include #include #include +#include class CgiEnvironment; namespace cgicc { @@ -59,6 +60,7 @@ class CgiApplicationEngine : public ApplicationEngine { Views views; Glib::ustring responseRootNodeName; Glib::ustring responseStyle; + xmlpp::DomParser present; }; mutable Stage * currentStage; mutable boost::uuids::uuid sessionID; diff --git a/project2/p2webMain.cpp b/project2/p2webMain.cpp index f424e0a..a526f8d 100644 --- a/project2/p2webMain.cpp +++ b/project2/p2webMain.cpp @@ -33,6 +33,7 @@ int main(void) cgicc::HTTPContentHeader header("text/xml-xslt"); CgiApplicationEngine app(&env, &header); app.process(); + IO << "Cache-control: no-cache" << std::endl; header.render(IO); xmlOutputBufferPtr out = xmlOutputBufferCreateIO( xmlWrite, NULL, &IO, xmlGetCharEncodingHandler(XML_CHAR_ENCODING_UTF8)); diff --git a/project2/rawView.cpp b/project2/rawView.cpp new file mode 100644 index 0000000..1b79815 --- /dev/null +++ b/project2/rawView.cpp @@ -0,0 +1,28 @@ +#include +#include "rawView.h" +#include "xml.h" +#include "xmlObjectLoader.h" +#include "environment.h" +#include "appEngine.h" + +_RawView::_RawView(const xmlpp::Element * p) : + _SourceObject(p), + _View(p), + copyRoot(p) +{ +} + +Glib::ustring +_RawView::getCurrentValue(const Glib::ustring & id) const +{ + return ""; +} + +void _RawView::execute(xmlpp::Element * par, const ApplicationEngine * ep, const _View * parent) const +{ + BOOST_FOREACH(xmlpp::Node * node, copyRoot->get_children()) { + par->import_node(node); + } +} + + diff --git a/project2/rawView.h b/project2/rawView.h new file mode 100644 index 0000000..8d069b0 --- /dev/null +++ b/project2/rawView.h @@ -0,0 +1,24 @@ +#ifndef RAWVIEW_H +#define RAWVIEW_H + +#include +#include +#include +#include "view.h" + +class ApplicationEngine; + +class _RawView : public _View { + public: + _RawView(const xmlpp::Element * p); + void execute(xmlpp::Element *, const ApplicationEngine *, const _View * parent = NULL) const; + Glib::ustring getCurrentValue(const Glib::ustring & id) const; + private: + const xmlpp::Element * copyRoot; +}; +typedef boost::shared_ptr<_RawView> RawView; +typedef std::map RawViews; + +#endif + + diff --git a/project2/sessionClearTask.cpp b/project2/sessionClearTask.cpp index c5d6d0d..963ebeb 100644 --- a/project2/sessionClearTask.cpp +++ b/project2/sessionClearTask.cpp @@ -5,7 +5,8 @@ _SessionClearTask::_SessionClearTask(const xmlpp::Element * p) : _SourceObject(p), - _Task(p) + _Task(p), + key(p->get_attribute_value("key")) { } diff --git a/project2/view.cpp b/project2/view.cpp index 799d1ae..c36c43d 100644 --- a/project2/view.cpp +++ b/project2/view.cpp @@ -2,6 +2,7 @@ #include #include "xmlObjectLoader.h" #include "sqlView.h" +#include "rawView.h" _View::_View(const xmlpp::Element * p) : _SourceObject(p), @@ -17,6 +18,7 @@ void _View::AddLoaders(Loaders & l, Views & views) { l.insert(LoadersVT("sqlview", _LoaderBase::Make<_SqlView, _View, std::string, _SourceObject, &_SourceObject::name>(&views))); + l.insert(LoadersVT("rawview", _LoaderBase::Make<_RawView, _View, std::string, _SourceObject, &_SourceObject::name>(&views))); } void -- cgit v1.2.3