summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-10-29 13:19:59 +0000
committerrandomdan <randomdan@localhost>2010-10-29 13:19:59 +0000
commitd0c6e52cc7d11780e4650d63510f9a4d80328d68 (patch)
treeab6c908f14cc0f5c7fe52b6413eb86ccf476f714
parentFix memory leak in stringf (diff)
downloadproject2-d0c6e52cc7d11780e4650d63510f9a4d80328d68.tar.bz2
project2-d0c6e52cc7d11780e4650d63510f9a4d80328d68.tar.xz
project2-d0c6e52cc7d11780e4650d63510f9a4d80328d68.zip
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
-rw-r--r--project2/Jamfile.jam40
-rw-r--r--project2/console/consoleAppEngine.cpp49
-rw-r--r--project2/console/consoleAppEngine.h3
-rw-r--r--project2/session.cpp17
-rw-r--r--project2/session.h14
-rw-r--r--project2/sessionContainer.cpp18
-rw-r--r--project2/sessionContainer.h20
-rw-r--r--project2/sessionXml.cpp1
-rw-r--r--project2/sessionXml.h3
9 files changed, 122 insertions, 43 deletions
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 : : <name>esmtp ;
lib curl : : <name>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
:
<library>../libmisc//misc
<library>libxmlpp
- <library>boost_regex
<library>boost_filesystem
;
-lib p2session :
- [ glob session*.cpp ]
+lib p2processes :
+ procRows.cpp
+ :
+ <library>../libmisc//misc
+ <library>libxmlpp
+ ;
+
+lib p2files :
+ fileRows.cpp
+ :
+ <library>../libmisc//misc
+ <library>libxmlpp
+ ;
+
+lib p2regex :
+ regexCheck.cpp
+ :
+ <library>../libmisc//misc
+ <library>boost_regex
+ <library>libxmlpp
+ ;
+
+lib p2xmlSession :
+ sessionContainer.cpp sessionXml.cpp
:
<library>../libmisc//misc
<library>libxmlpp
@@ -64,10 +86,13 @@ lib p2mail :
exe p2web :
[ glob cgi/*.cpp ] :
<library>p2common
- <library>p2session
<library>p2url
<library>p2sql
<library>p2mail
+ <library>p2files
+ <library>p2regex
+ <library>p2processes
+ <library>p2xmlSession
<library>fcgi++
<library>fcgi
<library>cgicc
@@ -77,8 +102,11 @@ exe p2console :
[ glob console/*.cpp ] :
<library>p2common
<library>p2url
+ <library>p2files
+ <library>p2processes
<library>p2sql
<library>p2mail
+ <library>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 <stdexcept>
#include <libxml/xinclude.h>
+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 <boost/intrusive_ptr.hpp>
-#include <boost/uuid/uuid.hpp>
#include <boost/filesystem/path.hpp>
#include <libxml++/document.h>
#include <libxml++/parsers/domparser.h>
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 <syslog.h>
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 <map>
#include <glibmm/ustring.h>
-#include <boost/uuid/uuid.hpp>
#include <boost/intrusive_ptr.hpp>
#include "intrusivePtrBase.h"
@@ -27,18 +26,5 @@ class Session : public virtual IntrusivePtrBase {
};
typedef boost::intrusive_ptr<Session> 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 <boost/uuid/uuid.hpp>
+#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 <libxml++/parsers/domparser.h>
#include <libxml++/nodes/textnode.h>
#include <set>
-#include <boost/uuid/uuid.hpp>
#include <boost/foreach.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/lexical_cast.hpp>
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 <map>
+#include <boost/uuid/uuid.hpp>
class SessionContainerXml : public SessionContainer {
public: