diff options
| author | Alan Conway <aconway@apache.org> | 2007-06-27 21:19:14 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-06-27 21:19:14 +0000 |
| commit | 0efcf2c5c91f4927ccc00ad1cf391c2f964cc2e1 (patch) | |
| tree | a9318ac4787cf588dd1329c2e557d8f870be20cc /cpp/src/qpid/framing/ChannelAdapter.cpp | |
| parent | 548abd065f91bc1f238ac98c24edf410edf10356 (diff) | |
| download | qpid-python-0efcf2c5c91f4927ccc00ad1cf391c2f964cc2e1.tar.gz | |
* 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
Diffstat (limited to 'cpp/src/qpid/framing/ChannelAdapter.cpp')
| -rw-r--r-- | cpp/src/qpid/framing/ChannelAdapter.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
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; } |
