From 0efcf2c5c91f4927ccc00ad1cf391c2f964cc2e1 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 27 Jun 2007 21:19:14 +0000 Subject: * src/qpid/framing/ChannelAdapter.cpp: Use handler chains for in and outbound frames. * src/qpid/framing/InputHandler.h, OutputHandler.h, FrameHandler.h: All handlers pass AMQFrame& and have consistent memory management. Terminal OutputHandlers used to take ownership and delete frame, now they make a shallow copy instead. * src/qpid/framing/Handler.h, FrameHandler.h: Simplified. * src/qpid/client/ClientConnection.cpp: * src/qpid/broker/Connection.cpp: * src/qpid/broker/BrokerChannel.cpp: Update for ChannelAdapter changes. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@551336 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/framing/ChannelAdapter.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'cpp/src/qpid/framing/ChannelAdapter.cpp') diff --git a/cpp/src/qpid/framing/ChannelAdapter.cpp b/cpp/src/qpid/framing/ChannelAdapter.cpp index 48a200c4e1..4ee834b561 100644 --- a/cpp/src/qpid/framing/ChannelAdapter.cpp +++ b/cpp/src/qpid/framing/ChannelAdapter.cpp @@ -19,6 +19,7 @@ #include "ChannelAdapter.h" #include "AMQFrame.h" +#include "FrameHandler.h" #include "qpid/Exception.h" using boost::format; @@ -26,13 +27,21 @@ using boost::format; namespace qpid { namespace framing { -void ChannelAdapter::init( - ChannelId i, OutputHandler& o, ProtocolVersion v) +/** Framehandler that feeds into the channel. */ +struct ChannelAdapter::ChannelAdapterHandler : public FrameHandler { + ChannelAdapterHandler(ChannelAdapter& channel_) : channel(channel_) {} + void handle(AMQFrame& frame) { channel.handleBody(frame.getBody()); } + ChannelAdapter& channel; +}; + +void ChannelAdapter::init(ChannelId i, OutputHandler& out, ProtocolVersion v) { assertChannelNotOpen(); id = i; - out = &o; version = v; + + handlers.in = make_shared_ptr(new ChannelAdapterHandler(*this)); + handlers.out= make_shared_ptr(new OutputHandlerFrameHandler(out)); } RequestId ChannelAdapter::send( @@ -58,7 +67,8 @@ RequestId ChannelAdapter::send( } // No action required for other body types. } - out->send(new AMQFrame(getVersion(), getId(), body)); + AMQFrame frame(getVersion(), getId(), body); + handlers.out->handle(frame); return requestId; } -- cgit v1.2.1