diff options
| author | Gordon Sim <gsim@apache.org> | 2007-08-28 19:38:17 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2007-08-28 19:38:17 +0000 |
| commit | 9e10f4ea3b2f8ab6650f635cada48e4735ca20d7 (patch) | |
| tree | 26ad3b8dffa17fa665fe7a033a7c8092839df011 /cpp/src/qpid/framing/AMQFrame.h | |
| parent | 6b09696b216c090b512c6af92bf7976ae3407add (diff) | |
| download | qpid-python-9e10f4ea3b2f8ab6650f635cada48e4735ca20d7.tar.gz | |
Updated message.transfer encoding to use header and content segments (including new structs).
Unified more between the basic and message classes messages.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@570538 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/AMQFrame.h')
| -rw-r--r-- | cpp/src/qpid/framing/AMQFrame.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/cpp/src/qpid/framing/AMQFrame.h b/cpp/src/qpid/framing/AMQFrame.h index 9e825a9936..84e7660218 100644 --- a/cpp/src/qpid/framing/AMQFrame.h +++ b/cpp/src/qpid/framing/AMQFrame.h @@ -37,14 +37,14 @@ namespace framing { class AMQFrame : public AMQDataBlock { public: - AMQFrame(ProtocolVersion=ProtocolVersion()) {} + AMQFrame() : channel(0) {} /** Construct a frame with a copy of b */ - AMQFrame(ProtocolVersion, ChannelId c, const AMQBody* b) : channel(c) { + AMQFrame(ChannelId c, const AMQBody* b) : channel(c) { setBody(*b); } - AMQFrame(ProtocolVersion, ChannelId c, const AMQBody& b) : channel(c) { + AMQFrame(ChannelId c, const AMQBody& b) : channel(c) { setBody(b); } @@ -52,21 +52,26 @@ class AMQFrame : public AMQDataBlock void setChannel(ChannelId c) { channel = c; } AMQBody* getBody(); - const AMQBody* getBody() const; + const AMQBody* getBody() const; /** Copy a body instance to the frame */ void setBody(const AMQBody& b) { CopyVisitor cv(*this); b.accept(cv); } /** Convenience template to cast the body to an expected type. */ template <class T> T* castBody() { - boost::polymorphic_downcast<T*>(getBody()); + return boost::polymorphic_downcast<T*>(getBody()); + } + + template <class T> const T* castBody() const { + return boost::polymorphic_downcast<const T*>(getBody()); } bool empty() { return boost::get<boost::blank>(&body); } - void encode(Buffer& buffer); + void encode(Buffer& buffer) const; bool decode(Buffer& buffer); uint32_t size() const; + static uint32_t frameOverhead(); private: struct CopyVisitor : public AMQBodyConstVisitor { @@ -77,7 +82,7 @@ class AMQFrame : public AMQDataBlock void visit(const AMQHeartbeatBody& x) { frame.body=x; } void visit(const AMQMethodBody& x) { frame.body=MethodHolder(x); } }; - friend struct CopyVisitor; + friend struct CopyVisitor; typedef boost::variant<boost::blank, AMQHeaderBody, |
