diff options
| author | Alan Conway <aconway@apache.org> | 2007-09-21 18:26:37 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-09-21 18:26:37 +0000 |
| commit | 2f6d6ad7efd788b71204af67dff51b6233881e2e (patch) | |
| tree | a3d123bc112d12dfcef341a312f418624c98e342 /cpp/src/qpid/broker/SessionState.h | |
| parent | 3b80f903b6174b4346d7d7b537d783f628fe28d6 (diff) | |
| download | qpid-python-2f6d6ad7efd788b71204af67dff51b6233881e2e.tar.gz | |
Split broker::Session into:
broker::SessionState: session info (uuid etc.) + handler chains.
broker::SemanticState: session state for the SemanticHandler.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@578219 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/SessionState.h')
| -rw-r--r-- | cpp/src/qpid/broker/SessionState.h | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/cpp/src/qpid/broker/SessionState.h b/cpp/src/qpid/broker/SessionState.h index 7558ea7866..1334cc7005 100644 --- a/cpp/src/qpid/broker/SessionState.h +++ b/cpp/src/qpid/broker/SessionState.h @@ -23,44 +23,73 @@ */ #include "qpid/framing/Uuid.h" +#include "qpid/framing/FrameHandler.h" +#include "qpid/framing/ProtocolVersion.h" + +#include <boost/ptr_container/ptr_vector.hpp> +#include <boost/noncopyable.hpp> + namespace qpid { + +namespace framing { +class AMQP_ClientProxy; +} + namespace broker { +class SessionHandler; +class Broker; +class Connection; + /** * State of a session. + * + * An attached session has a SessionHandler which is attached to a + * connection. A suspended session has no handler. + * + * A SessionState is always associated with an open session (attached or + * suspended) it is destroyed when the session is closed. + * + * The SessionState includes the sessions handler chains, which may + * themselves have state. The handlers will be preserved as long as + * the session is alive. */ -class SessionState +class SessionState : public framing::FrameHandler::Chains, + private boost::noncopyable { public: - enum State { CLOSED, ACTIVE, SUSPENDED }; + /** SessionState for a newly opened connection. */ + SessionState(SessionHandler& h, uint32_t timeout_); - /** Initially in CLOSED state */ - SessionState() : id(false), state(CLOSED), timeout(0) {} + bool isAttached() { return handler; } - /** Make CLOSED session ACTIVE, assigns a new UUID. - * #@param timeout in seconds - */ - void open(u_int32_t timeout_) { - state=ACTIVE; id.generate(); timeout=timeout_; - } + /** @pre isAttached() */ + SessionHandler& getHandler(); - /** Close a session. */ - void close() { state=CLOSED; id.clear(); timeout=0; } + /** @pre isAttached() */ + framing::AMQP_ClientProxy& getProxy(); + + /** @pre isAttached() */ + Connection& getConnection(); - State getState() const { return state; } const framing::Uuid& getId() const { return id; } uint32_t getTimeout() const { return timeout; } - - bool isOpen() { return state == ACTIVE; } - bool isClosed() { return state == CLOSED; } - bool isSuspended() { return state == SUSPENDED; } + Broker& getBroker() { return broker; } + framing::ProtocolVersion getVersion() const { return version; } + private: - friend class SuspendedSessions; + friend class SessionHandler; // Only SessionHandler can attach/detach + void detach() { handler=0; } + void attach(SessionHandler& h) { handler = &h; } + + SessionHandler* handler; framing::Uuid id; - State state; uint32_t timeout; + Broker& broker; + boost::ptr_vector<framing::FrameHandler> chain; + framing::ProtocolVersion version; }; }} // namespace qpid::broker |
