Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation |
00001 #ifndef QPID_FRAMING_AMQBODY_H 00002 #define QPID_FRAMING_AMQBODY_H 00003 00004 /* 00005 * 00006 * Licensed to the Apache Software Foundation (ASF) under one 00007 * or more contributor license agreements. See the NOTICE file 00008 * distributed with this work for additional information 00009 * regarding copyright ownership. The ASF licenses this file 00010 * to you under the Apache License, Version 2.0 (the 00011 * "License"); you may not use this file except in compliance 00012 * with the License. You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, 00017 * software distributed under the License is distributed on an 00018 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00019 * KIND, either express or implied. See the License for the 00020 * specific language governing permissions and limitations 00021 * under the License. 00022 * 00023 */ 00024 #include "qpid/framing/amqp_types.h" 00025 #include "qpid/RefCounted.h" 00026 #include "qpid/framing/BodyFactory.h" 00027 #include <boost/intrusive_ptr.hpp> 00028 #include <ostream> 00029 #include "qpid/CommonImportExport.h" 00030 00031 namespace qpid { 00032 namespace framing { 00033 00034 class Buffer; 00035 00036 class AMQMethodBody; 00037 class AMQHeaderBody; 00038 class AMQContentBody; 00039 class AMQHeartbeatBody; 00040 00041 struct AMQBodyConstVisitor { 00042 virtual ~AMQBodyConstVisitor() {} 00043 virtual void visit(const AMQHeaderBody&) = 0; 00044 virtual void visit(const AMQContentBody&) = 0; 00045 virtual void visit(const AMQHeartbeatBody&) = 0; 00046 virtual void visit(const AMQMethodBody&) = 0; 00047 }; 00048 00049 class AMQBody : public RefCounted { 00050 public: 00051 AMQBody() {} 00052 QPID_COMMON_EXTERN virtual ~AMQBody(); 00053 00054 // Make AMQBody copyable even though RefCounted. 00055 AMQBody(const AMQBody&) : RefCounted() {} 00056 AMQBody& operator=(const AMQBody&) { return *this; } 00057 00058 virtual uint8_t type() const = 0; 00059 00060 virtual void encode(Buffer& buffer) const = 0; 00061 virtual void decode(Buffer& buffer, uint32_t=0) = 0; 00062 virtual uint32_t encodedSize() const = 0; 00063 00064 virtual void print(std::ostream& out) const = 0; 00065 virtual void accept(AMQBodyConstVisitor&) const = 0; 00066 00067 virtual AMQMethodBody* getMethod() { return 0; } 00068 virtual const AMQMethodBody* getMethod() const { return 0; } 00069 00071 static bool match(const AMQBody& , const AMQBody& ); 00072 virtual boost::intrusive_ptr<AMQBody> clone() const = 0; 00073 }; 00074 00075 QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& out, const AMQBody& body) ; 00076 00077 enum BodyTypes { 00078 METHOD_BODY = 1, 00079 HEADER_BODY = 2, 00080 CONTENT_BODY = 3, 00081 HEARTBEAT_BODY = 8 00082 }; 00083 00084 }} // namespace qpid::framing 00085 00086 #endif