From dd86a8562275d411ba6af54b6651154b6abc08ef Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 5 Jun 2007 15:54:22 +0000 Subject: Some tests and fixes for dtx preview. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@544522 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/broker/NullMessageStore.cpp | 37 ++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'cpp/src/qpid/broker/NullMessageStore.cpp') diff --git a/cpp/src/qpid/broker/NullMessageStore.cpp b/cpp/src/qpid/broker/NullMessageStore.cpp index 49feb163bf..7742902cc9 100644 --- a/cpp/src/qpid/broker/NullMessageStore.cpp +++ b/cpp/src/qpid/broker/NullMessageStore.cpp @@ -25,6 +25,26 @@ #include +namespace qpid{ +namespace broker{ + +const std::string nullxid = ""; + +class DummyCtxt : public TPCTransactionContext +{ + const std::string xid; +public: + DummyCtxt(const std::string& _xid) : xid(_xid) {} + static std::string getXid(TransactionContext& ctxt) + { + DummyCtxt* c(dynamic_cast(&ctxt)); + return c ? c->xid : nullxid; + } +}; + +} +} + using namespace qpid::broker; NullMessageStore::NullMessageStore(bool _warn) : warn(_warn){} @@ -92,24 +112,27 @@ std::auto_ptr NullMessageStore::begin() return std::auto_ptr(); } -std::auto_ptr NullMessageStore::begin(const std::string&) +std::auto_ptr NullMessageStore::begin(const std::string& xid) { - return std::auto_ptr(); + return std::auto_ptr(new DummyCtxt(xid)); } -void NullMessageStore::prepare(TPCTransactionContext&) +void NullMessageStore::prepare(TPCTransactionContext& ctxt) { + prepared.insert(DummyCtxt::getXid(ctxt)); } -void NullMessageStore::commit(TransactionContext&) +void NullMessageStore::commit(TransactionContext& ctxt) { + prepared.erase(DummyCtxt::getXid(ctxt)); } -void NullMessageStore::abort(TransactionContext&) +void NullMessageStore::abort(TransactionContext& ctxt) { + prepared.erase(DummyCtxt::getXid(ctxt)); } -void NullMessageStore::collectPreparedXids(std::set&) +void NullMessageStore::collectPreparedXids(std::set& out) { - + out.insert(prepared.begin(), prepared.end()); } -- cgit v1.2.1