summaryrefslogtreecommitdiff
path: root/server/src/session.cc
diff options
context:
space:
mode:
authordeva <deva>2010-06-10 07:03:06 +0000
committerdeva <deva>2010-06-10 07:03:06 +0000
commit198b0d886817f2c5bc97cfd11857d4b314dffae3 (patch)
tree4fc2d51de46ab69b9e67149abf0ab6a332032f27 /server/src/session.cc
parent730eb796bbce6f124be9194f1565b7dda1daddf1 (diff)
Add transaction support on database pr. pracro session. Makes it possible to discard all edited macros.
Diffstat (limited to 'server/src/session.cc')
-rw-r--r--server/src/session.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/server/src/session.cc b/server/src/session.cc
index 803a515..e53565b 100644
--- a/server/src/session.cc
+++ b/server/src/session.cc
@@ -36,6 +36,7 @@
#include <errno.h>
#include "journalwriter.h"
+#include "database.h"
#include "configuration.h"
#include "connectionpool.h"
#include "sessionserialiser.h"
@@ -44,11 +45,13 @@ Session::Session(std::string sessionid)
{
_id = sessionid;
_journal = NULL;
+ _database = NULL;
}
Session::~Session()
{
if(_journal) delete _journal;
+ if(_database) delete _database;
}
std::string Session::id()
@@ -73,6 +76,11 @@ void Session::commit()
delete _journal;
_journal = NULL;
}
+ if(_database != NULL) {
+ _database->commit();
+ delete _database;
+ _database = NULL;
+ }
}
void Session::discard()
@@ -81,6 +89,11 @@ void Session::discard()
delete _journal;
_journal = NULL;
}
+ if(_database != NULL) {
+ _database->discard();
+ delete _database;
+ _database = NULL;
+ }
}
JournalWriter *Session::journal()
@@ -92,6 +105,16 @@ JournalWriter *Session::journal()
return _journal;
}
+Database *Session::database()
+{
+ if(_database == NULL) {
+ _database =
+ new Database(Conf::database_backend, Conf::database_addr, "",
+ Conf::database_user, Conf::database_passwd, "");
+ }
+ return _database;
+}
+
Sessions::Sessions()
{
}