From 2e437e1569009d8e8ed3ed896d751994e2e85d74 Mon Sep 17 00:00:00 2001 From: Kim van der Riet Date: Fri, 20 Jul 2012 12:55:20 +0000 Subject: QPID-3858: WIP: Created many async operation classes for each op instead of a single class with op codes. git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/asyncstore@1363759 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/asyncStore/AsyncOperation.h | 208 +++++++++++++++++++++++++------ 1 file changed, 168 insertions(+), 40 deletions(-) (limited to 'cpp/src/qpid/asyncStore/AsyncOperation.h') diff --git a/cpp/src/qpid/asyncStore/AsyncOperation.h b/cpp/src/qpid/asyncStore/AsyncOperation.h index cb73ad639b..2b195d7443 100644 --- a/cpp/src/qpid/asyncStore/AsyncOperation.h +++ b/cpp/src/qpid/asyncStore/AsyncOperation.h @@ -26,57 +26,185 @@ #include "qpid/broker/AsyncStore.h" +#include + namespace qpid { namespace asyncStore { -class AsyncStoreHandle; +class AsyncStoreImpl; class AsyncOperation { public: - typedef enum {NONE=0, - TXN_PREPARE, - TXN_COMMIT, - TXN_ABORT, - CONFIG_CREATE, - CONFIG_DESTROY, - QUEUE_CREATE, - QUEUE_FLUSH, - QUEUE_DESTROY, - EVENT_CREATE, - EVENT_DESTROY, - MSG_ENQUEUE, - MSG_DEQUEUE - } opCode; - - AsyncOperation(); - AsyncOperation(const opCode op, - const AsyncStoreHandle* th, - boost::shared_ptr brokerCtxt); - AsyncOperation(const opCode op, - const AsyncStoreHandle* th, - const qpid::broker::DataSource* const dataSrc, - boost::shared_ptr brokerCtxt); - AsyncOperation(const opCode op, - const AsyncStoreHandle* th, - const qpid::broker::TxnHandle* txnHandle, - boost::shared_ptr brokerCtxt); - AsyncOperation(const opCode op, - const AsyncStoreHandle* th, - const qpid::broker::DataSource* const dataSrc, - const qpid::broker::TxnHandle* txnHandle, - boost::shared_ptr brokerCtxt); + AsyncOperation(boost::shared_ptr brokerCtxt); virtual ~AsyncOperation(); - const char* getOpStr() const; - static const char* getOpStr(const opCode op); + virtual void executeOp(boost::shared_ptr store) = 0; boost::shared_ptr getBrokerContext() const; - + virtual const char* getOpStr() const = 0; +protected: + void submitResult(); + void submitResult(const int errNo, + const std::string& errMsg); private: - opCode m_op; - const AsyncStoreHandle* m_targetHandle; - const qpid::broker::DataSource* const m_dataSrc; - const qpid::broker::TxnHandle* m_txnHandle; boost::shared_ptr const m_brokerCtxt; }; + +class AsyncOpTxnPrepare: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpTxnPrepare(qpid::broker::TxnHandle& txnHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpTxnPrepare(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::TxnHandle& m_txnHandle; +}; + + +class AsyncOpTxnCommit: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpTxnCommit(qpid::broker::TxnHandle& txnHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpTxnCommit(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::TxnHandle& m_txnHandle; +}; + + +class AsyncOpTxnAbort: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpTxnAbort(qpid::broker::TxnHandle& txnHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpTxnAbort(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::TxnHandle& m_txnHandle; +}; + + +class AsyncOpConfigCreate: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpConfigCreate(qpid::broker::ConfigHandle& cfgHandle, + const qpid::broker::DataSource* const data, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpConfigCreate(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::ConfigHandle& m_cfgHandle; + const qpid::broker::DataSource* const m_data; +}; + + +class AsyncOpConfigDestroy: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpConfigDestroy(qpid::broker::ConfigHandle& cfgHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpConfigDestroy(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::ConfigHandle& m_cfgHandle; +}; + + +class AsyncOpQueueCreate: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpQueueCreate(qpid::broker::QueueHandle& queueHandle, + const qpid::broker::DataSource* const data, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpQueueCreate(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::QueueHandle& m_queueHandle; + const qpid::broker::DataSource* const m_data; +}; + + +class AsyncOpQueueFlush: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpQueueFlush(qpid::broker::QueueHandle& queueHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpQueueFlush(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::QueueHandle& m_queueHandle; +}; + + +class AsyncOpQueueDestroy: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpQueueDestroy(qpid::broker::QueueHandle& queueHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpQueueDestroy(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::QueueHandle& m_queueHandle; +}; + + +class AsyncOpEventCreate: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpEventCreate(qpid::broker::EventHandle& evtHandle, + const qpid::broker::DataSource* const data, + qpid::broker::TxnHandle& txnHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpEventCreate(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::EventHandle& m_evtHandle; + const qpid::broker::DataSource* const m_data; + qpid::broker::TxnHandle& m_txnHandle; +}; + + +class AsyncOpEventDestroy: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpEventDestroy(qpid::broker::EventHandle& evtHandle, + qpid::broker::TxnHandle& txnHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpEventDestroy(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::EventHandle& m_evtHandle; + qpid::broker::TxnHandle& m_txnHandle; +}; + + +class AsyncOpMsgEnqueue: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpMsgEnqueue(qpid::broker::EnqueueHandle& enqHandle, + qpid::broker::TxnHandle& txnHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpMsgEnqueue(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::EnqueueHandle& m_enqHandle; + qpid::broker::TxnHandle& m_txnHandle; +}; + + +class AsyncOpMsgDequeue: public qpid::asyncStore::AsyncOperation { +public: + AsyncOpMsgDequeue(qpid::broker::EnqueueHandle& enqHandle, + qpid::broker::TxnHandle& txnHandle, + boost::shared_ptr brokerCtxt); + virtual ~AsyncOpMsgDequeue(); + virtual void executeOp(boost::shared_ptr store); + virtual const char* getOpStr() const; +private: + qpid::broker::EnqueueHandle& m_enqHandle; + qpid::broker::TxnHandle& m_txnHandle; +}; + }} // namespace qpid::asyncStore #endif // qpid_asyncStore_AsyncOperation_h_ -- cgit v1.2.1