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

00001 #ifndef _framing_AMQRequestBody_h
00002 #define _framing_AMQRequestBody_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 "qpid/framing/AMQMethodBody.h"
00023 
00024 namespace qpid {
00025 namespace framing {
00026 
00030 class AMQRequestBody : public AMQMethodBody
00031 {
00032  public:
00033     typedef boost::shared_ptr<AMQRequestBody> shared_ptr;
00034 
00035     struct Data {
00036         Data(RequestId id=0, ResponseId mark=0)
00037             : requestId(id), responseMark(mark) {}
00038         void encode(Buffer&) const;
00039         void decode(Buffer&);
00040 
00041         RequestId requestId;
00042         ResponseId responseMark;
00043     };
00044 
00045     static Data& getData(const AMQBody::shared_ptr& body) {
00046         return boost::dynamic_pointer_cast<AMQRequestBody>(body)->getData();
00047     }
00048 
00049     static shared_ptr create(
00050         AMQP_MethodVersionMap& versionMap, ProtocolVersion version,
00051         Buffer& buffer);
00052 
00053     AMQRequestBody(ProtocolVersion v, RequestId id=0, ResponseId mark=0)
00054         : AMQMethodBody(v), data(id, mark) {}
00055 
00056     uint8_t type() const { return REQUEST_BODY; }
00057     void encode(Buffer& buffer) const;
00058 
00059     Data& getData() { return data; }
00060     RequestId  getRequestId() const { return data.requestId; }
00061     ResponseId getResponseMark() const { return data.responseMark; }
00062     void setRequestId(RequestId id) { data.requestId=id; }
00063     void setResponseMark(ResponseId mark) { data.responseMark=mark; }
00064 
00065     bool isRequest()const { return true; }
00066     static const uint32_t baseSize() { return AMQMethodBody::baseSize()+20; }
00067   protected:
00068     void printPrefix(std::ostream& out) const;
00069     
00070   private:
00071     Data data;
00072 };
00073 
00074 }} // namespace qpid::framing
00075 
00076 
00077 
00078 #endif  

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