diff options
| author | Alan Conway <aconway@apache.org> | 2007-08-16 20:12:33 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2007-08-16 20:12:33 +0000 |
| commit | 49c7a491c98c26fe7d4f017a7ba655dfc029278c (patch) | |
| tree | 304d51ba039a5391b4ebde08caab3da978b465fb /cpp/src/qpid/framing/AMQMethodBody.h | |
| parent | dc13ca80ff893f74ab57fee6543de6543aa366bc (diff) | |
| download | qpid-python-49c7a491c98c26fe7d4f017a7ba655dfc029278c.tar.gz | |
AMQBodies are no longer allocated on the heap and passed with shared_ptr.
AMQFrame contains a boost::variant of AMQHeaderBody,AMQContentBody,
AMQHeatbeatBody, and MethodHolder. A variant is basically a type-safe
union, it can allocate any of the types in-place.
MethodHolder contains a Blob, a less sophisticated kind of variant,
which can contain any of the concrete method body types.
Using variants for all the method types causes outrageous compile
times and bloated library symbol names. Blob lacks some of the finer
features of variant and needs help from generated code. For now both
are hidden to the rest of the code base behind AMQFrame and MethodBody
classes so if/when we decide to settle on just one "variant" type
solution we can do so.
This commit touches nearly 100 files, mostly converting method
signatures with shared_ptr<FooBody> to FooBody* or FooBody&, and
converting stored shared_ptr<AMQBody> to AMQFrame and
share_ptr<AMQMethodBody> to MethodHolder.
There is one outstanding client memory leak, which I will fix in my next commit.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@566822 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing/AMQMethodBody.h')
| -rw-r--r-- | cpp/src/qpid/framing/AMQMethodBody.h | 67 |
1 files changed, 25 insertions, 42 deletions
diff --git a/cpp/src/qpid/framing/AMQMethodBody.h b/cpp/src/qpid/framing/AMQMethodBody.h index 73c5eb78a6..9c776e143b 100644 --- a/cpp/src/qpid/framing/AMQMethodBody.h +++ b/cpp/src/qpid/framing/AMQMethodBody.h @@ -21,65 +21,48 @@ * under the License. * */ -#include <iostream> #include "amqp_types.h" #include "AMQBody.h" -#include "Buffer.h" -#include "qpid/framing/AMQP_ServerOperations.h" +#include "qpid/framing/ProtocolVersion.h" +#include "qpid/shared_ptr.h" + +#include <ostream> + +#include <assert.h> namespace qpid { namespace framing { -class AMQP_MethodVersionMap; +class Buffer; +class AMQP_ServerOperations; +class Invocable; +class MethodBodyConstVisitor; -class AMQMethodBody : public AMQBody -{ +class AMQMethodBody : public AMQBody { public: - typedef boost::shared_ptr<AMQMethodBody> shared_ptr; - - static shared_ptr create( - AMQP_MethodVersionMap& map, ProtocolVersion version, Buffer& buf); - - ProtocolVersion version; - uint8_t type() const { return METHOD_BODY; } - AMQMethodBody(uint8_t major, uint8_t minor) : version(major, minor) {} - AMQMethodBody(ProtocolVersion ver) : version(ver) {} - virtual ~AMQMethodBody() {} - void decode(Buffer&, uint32_t); - virtual void encode(Buffer& buffer) const; + AMQMethodBody() {} + AMQMethodBody(uint8_t, uint8_t) {} + + virtual ~AMQMethodBody(); + virtual void accept(MethodBodyConstVisitor&) const = 0; + virtual MethodId amqpMethodId() const = 0; virtual ClassId amqpClassId() const = 0; - virtual void invoke(AMQP_ServerOperations&); - virtual bool invoke(Invocable* target); + virtual void invoke(AMQP_ServerOperations&) { assert(0); } + virtual bool invoke(Invocable*) { return false; } - template <class T> bool isA() { + template <class T> bool isA() const { return amqpClassId()==T::CLASS_ID && amqpMethodId()==T::METHOD_ID; } - /** Return request ID or response correlationID */ - virtual RequestId getRequestId() const { return 0; } - - virtual bool isRequest() const { return false; } - virtual bool isResponse() const { return false; } - - static uint32_t baseSize() { return 4; } - protected: - - struct ClassMethodId { - uint16_t classId; - uint16_t methodId; - void decode(Buffer& b); - }; - - void encodeId(Buffer& buffer) const; - virtual void encodeContent(Buffer& buffer) const = 0; - virtual void decodeContent(Buffer& buffer) = 0; - - virtual void printPrefix(std::ostream&) const {} + virtual uint32_t size() const = 0; + virtual uint8_t type() const { return METHOD_BODY; } - friend class MethodHolder; + AMQMethodBody* getMethod() { return this; } + const AMQMethodBody* getMethod() const { return this; } + void accept(AMQBodyConstVisitor& v) const { v.visit(*this); } }; |
