/home/aconway/svn/qpid/cpp/src/qpid/framing/AMQResponseBody.h

00001 #ifndef _framing_AMQResponseBody_h
00002 #define _framing_AMQResponseBody_h
00003 
00004 /*
00005  *
00006  * Copyright (c) 2006 The Apache Software Foundation
00007  *
00008  * Licensed under the Apache License, Version 2.0 (the "License");
00009  * you may not use this file except in compliance with the License.
00010  * You may obtain a copy of the License at
00011  *
00012  *    http://www.apache.org/licenses/LICENSE-2.0
00013  *
00014  * Unless required by applicable law or agreed to in writing, software
00015  * distributed under the License is distributed on an "AS IS" BASIS,
00016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017  * See the License for the specific language governing permissions and
00018  * limitations under the License.
00019  *
00020  */
00021 
00022 #include "AMQMethodBody.h"
00023 
00024 namespace qpid {
00025 namespace framing {
00026 
00027 class AMQP_MethodVersionMap;
00028 
00032 class AMQResponseBody : public AMQMethodBody
00033 {
00034 
00035   public:
00036     typedef boost::shared_ptr<AMQResponseBody> shared_ptr;
00037     
00038     struct Data {
00039         Data(ResponseId id=0, RequestId req=0, BatchOffset off=0)
00040             : responseId(id), requestId(req), batchOffset(off) {}
00041         void encode(Buffer&) const;
00042         void decode(Buffer&);
00043 
00044         uint64_t responseId;
00045         uint64_t requestId;
00046         uint32_t batchOffset;
00047     };
00048 
00049     static Data& getData(const AMQBody::shared_ptr& body) {
00050         return boost::dynamic_pointer_cast<AMQResponseBody>(body)->getData();
00051     }
00052 
00053     static shared_ptr create(
00054         AMQP_MethodVersionMap& versionMap, ProtocolVersion version,
00055         Buffer& buffer);
00056 
00057     AMQResponseBody(
00058         ProtocolVersion v, ResponseId id=0, RequestId req=0, BatchOffset off=0)
00059         : AMQMethodBody(v), data(id, req, off) {}
00060 
00061     uint8_t type() const { return RESPONSE_BODY; }
00062     void encode(Buffer& buffer) const;
00063 
00064     Data& getData() { return data; }
00065     ResponseId getResponseId() const { return data.responseId; }
00066     RequestId getRequestId() const { return data.requestId; }
00067     BatchOffset getBatchOffset() const { return data.batchOffset; }
00068     void setResponseId(ResponseId id) { data.responseId = id; }
00069     void setRequestId(RequestId id) { data.requestId = id; }
00070     void setBatchOffset(BatchOffset id) { data.batchOffset = id; }
00071 
00072     bool isResponse() const { return true; }
00073   protected:
00074     static const uint32_t baseSize() { return AMQMethodBody::baseSize()+20; }
00075     void printPrefix(std::ostream& out) const;
00076 
00077   private:
00078     Data data;
00079 };
00080 
00081 }} // namespace qpid::framing
00082 
00083 
00084 
00085 #endif  

Generated on Tue Apr 17 14:22:03 2007 for Qpid by  doxygen 1.4.7