From 6a0739b27d3f89361447442304eabc8716df89bf Mon Sep 17 00:00:00 2001 From: randomdan Date: Fri, 29 Oct 2010 13:19:59 +0000 Subject: Split up libs even more Remove need for Boost UUID in p2console needed for XML session management by having app engines handle their own sessions p2web now implements XML sessions by depending on libp2xmlSession --- project2/Jamfile.jam | 40 +++++++++++++++++++++++----- project2/console/consoleAppEngine.cpp | 49 +++++++++++++++++++++++++++++++++-- project2/console/consoleAppEngine.h | 3 +-- project2/session.cpp | 17 ------------ project2/session.h | 14 ---------- project2/sessionContainer.cpp | 18 +++++++++++++ project2/sessionContainer.h | 20 ++++++++++++++ project2/sessionXml.cpp | 1 - project2/sessionXml.h | 3 ++- 9 files changed, 122 insertions(+), 43 deletions(-) create mode 100644 project2/sessionContainer.cpp create mode 100644 project2/sessionContainer.h diff --git a/project2/Jamfile.jam b/project2/Jamfile.jam index b396887..754adbf 100644 --- a/project2/Jamfile.jam +++ b/project2/Jamfile.jam @@ -18,18 +18,40 @@ lib esmtp : : esmtp ; lib curl : : curl ; lib p2common : - appEngine.cpp dataSource.cpp environment.cpp fileRows.cpp fileStarGlibIoChannel.cpp iHaveParameters.cpp - iterate.cpp paramChecker.cpp perRowValues.cpp presenter.cpp procRows.cpp rawView.cpp regexCheck.cpp + appEngine.cpp dataSource.cpp environment.cpp fileStarGlibIoChannel.cpp iHaveParameters.cpp + iterate.cpp paramChecker.cpp perRowValues.cpp presenter.cpp rawView.cpp sourceObject.cpp task.cpp variables.cpp view.cpp xmlObjectLoader.cpp + sessionClearTask.cpp session.cpp sessionSetTask.cpp : ../libmisc//misc libxmlpp - boost_regex boost_filesystem ; -lib p2session : - [ glob session*.cpp ] +lib p2processes : + procRows.cpp + : + ../libmisc//misc + libxmlpp + ; + +lib p2files : + fileRows.cpp + : + ../libmisc//misc + libxmlpp + ; + +lib p2regex : + regexCheck.cpp + : + ../libmisc//misc + boost_regex + libxmlpp + ; + +lib p2xmlSession : + sessionContainer.cpp sessionXml.cpp : ../libmisc//misc libxmlpp @@ -64,10 +86,13 @@ lib p2mail : exe p2web : [ glob cgi/*.cpp ] : p2common - p2session p2url p2sql p2mail + p2files + p2regex + p2processes + p2xmlSession fcgi++ fcgi cgicc @@ -77,8 +102,11 @@ exe p2console : [ glob console/*.cpp ] : p2common p2url + p2files + p2processes p2sql p2mail + p2regex ; explicit install ; diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp index e58bf5d..d46d091 100644 --- a/project2/console/consoleAppEngine.cpp +++ b/project2/console/consoleAppEngine.cpp @@ -4,9 +4,54 @@ #include #include +class ConsoleSession : public Session { + public: + ConsoleSession() : expiry(0) + { + } + virtual ~ConsoleSession() + { + } + + virtual Glib::ustring GetValue(const Glib::ustring & name) const + { + Values::const_iterator i = vars.find(name); + if (i == vars.end()) { + throw Session::VariableNotFound(); + } + return i->second; + } + virtual Values GetValuesCopy() const + { + return vars; + } + virtual void SetValue(const Glib::ustring & name, const Glib::ustring & value) + { + vars[name] = value; + } + virtual void ClearValue(const Glib::ustring & name) + { + vars.erase(name); + } + virtual time_t ExpiryTime() const + { + return expiry; + } + + protected: + virtual void ExpiryTime(time_t t) + { + expiry = t; + } + private: + time_t expiry; + Values vars; +}; + ConsoleApplicationEngine::ConsoleApplicationEngine(const ConsoleEnvironment * env, const boost::filesystem::path & f) : ApplicationEngine(), - _env(env) + _env(env), + runtime(new ConsoleSession()) { xmlpp::DomParser request(f.string()); while (xmlXIncludeProcessFlags(request.get_document()->cobj(), XML_PARSE_NOXINCNODE) > 0); @@ -58,7 +103,7 @@ ConsoleApplicationEngine::env() const SessionPtr ConsoleApplicationEngine::session() const { - return SessionPtr(); + return runtime; } PresenterPtr diff --git a/project2/console/consoleAppEngine.h b/project2/console/consoleAppEngine.h index fb9597e..b40ef8a 100644 --- a/project2/console/consoleAppEngine.h +++ b/project2/console/consoleAppEngine.h @@ -6,13 +6,11 @@ #include "../paramChecker.h" #include "../presenter.h" #include -#include #include #include #include class ConsoleEnvironment; -class Session; class ConsoleApplicationEngine : public ApplicationEngine { public: @@ -36,6 +34,7 @@ class ConsoleApplicationEngine : public ApplicationEngine { }; OrderedParamCheckers parameterChecks; NoOutputExecutes tasks; + SessionPtr runtime; }; #endif diff --git a/project2/session.cpp b/project2/session.cpp index 87bea0c..6246068 100644 --- a/project2/session.cpp +++ b/project2/session.cpp @@ -1,5 +1,4 @@ #include "session.h" -#include Session::Session() { @@ -9,19 +8,3 @@ Session::~Session() { } -SessionContainer::SessionContainer() -{ -} - -SessionContainer::~SessionContainer() -{ -} - -SessionPtr -SessionContainer::GetSession(boost::uuids::uuid & id) -{ - SessionPtr s = getSession(id); - s->ExpiryTime(time(NULL) + 3600); - return s; -} - diff --git a/project2/session.h b/project2/session.h index c0101fe..8266acb 100644 --- a/project2/session.h +++ b/project2/session.h @@ -3,7 +3,6 @@ #include #include -#include #include #include "intrusivePtrBase.h" @@ -27,18 +26,5 @@ class Session : public virtual IntrusivePtrBase { }; typedef boost::intrusive_ptr SessionPtr; -class SessionContainer { - public: - SessionContainer(); - virtual ~SessionContainer() = 0; - - SessionPtr GetSession(boost::uuids::uuid & sid); - virtual void CleanUp() { } - - protected: - virtual SessionPtr getSession(boost::uuids::uuid & sid) = 0; -}; - - #endif diff --git a/project2/sessionContainer.cpp b/project2/sessionContainer.cpp new file mode 100644 index 0000000..5a73e3b --- /dev/null +++ b/project2/sessionContainer.cpp @@ -0,0 +1,18 @@ +#include "sessionContainer.h" + +SessionContainer::SessionContainer() +{ +} + +SessionContainer::~SessionContainer() +{ +} + +SessionPtr +SessionContainer::GetSession(boost::uuids::uuid & id) +{ + SessionPtr s = getSession(id); + s->ExpiryTime(time(NULL) + 3600); + return s; +} + diff --git a/project2/sessionContainer.h b/project2/sessionContainer.h new file mode 100644 index 0000000..08ad0e9 --- /dev/null +++ b/project2/sessionContainer.h @@ -0,0 +1,20 @@ +#ifndef SESSIONCONTAINER_H +#define SESSIONCONTAINER_H + +#include +#include "session.h" + +class SessionContainer { + public: + SessionContainer(); + virtual ~SessionContainer() = 0; + + SessionPtr GetSession(boost::uuids::uuid & sid); + virtual void CleanUp() { } + + protected: + virtual SessionPtr getSession(boost::uuids::uuid & sid) = 0; +}; + +#endif + diff --git a/project2/sessionXml.cpp b/project2/sessionXml.cpp index 68e19ea..3b42924 100644 --- a/project2/sessionXml.cpp +++ b/project2/sessionXml.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include diff --git a/project2/sessionXml.h b/project2/sessionXml.h index 6995826..f9d0059 100644 --- a/project2/sessionXml.h +++ b/project2/sessionXml.h @@ -1,8 +1,9 @@ #ifndef SESSIONXML_H #define SESSIONXML_H -#include "session.h" +#include "sessionContainer.h" #include +#include class SessionContainerXml : public SessionContainer { public: -- cgit v1.2.3