/opt/workspace/qpid/tags/M2/Final/cpp/lib/common/framing/AMQFrame.h

00001 /*
00002  *
00003  * Licensed to the Apache Software Foundation (ASF) under one
00004  * or more contributor license agreements.  See the NOTICE file
00005  * distributed with this work for additional information
00006  * regarding copyright ownership.  The ASF licenses this file
00007  * to you under the Apache License, Version 2.0 (the
00008  * "License"); you may not use this file except in compliance
00009  * with the License.  You may obtain a copy of the License at
00010  * 
00011  *   http://www.apache.org/licenses/LICENSE-2.0
00012  * 
00013  * Unless required by applicable law or agreed to in writing,
00014  * software distributed under the License is distributed on an
00015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00016  * KIND, either express or implied.  See the License for the
00017  * specific language governing permissions and limitations
00018  * under the License.
00019  *
00020  */
00021 /*#include <qpid/framing/amqp_methods.h>*/
00022 #include <amqp_types.h>
00023 #include <AMQBody.h>
00024 #include <AMQDataBlock.h>
00025 #include <AMQMethodBody.h>
00026 #include <AMQHeaderBody.h>
00027 #include <AMQContentBody.h>
00028 #include <AMQHeartbeatBody.h>
00029 #include <AMQP_MethodVersionMap.h>
00030 #include <AMQP_HighestVersion.h>
00031 #include <Buffer.h>
00032 
00033 #ifndef _AMQFrame_
00034 #define _AMQFrame_
00035 
00036 namespace qpid {
00037     namespace framing {
00038 
00039         
00040         class AMQFrame : virtual public AMQDataBlock
00041         {
00042             static AMQP_MethodVersionMap versionMap;
00043             qpid::framing::ProtocolVersion version;
00044             
00045             u_int16_t channel;
00046             u_int8_t type;//used if the body is decoded separately from the 'head'
00047             AMQBody::shared_ptr body;
00048                         AMQBody::shared_ptr createMethodBody(Buffer& buffer);
00049             
00050         public:
00051             AMQFrame(qpid::framing::ProtocolVersion& _version = highestProtocolVersion);
00052             AMQFrame(qpid::framing::ProtocolVersion& _version, u_int16_t channel, AMQBody* body);
00053             AMQFrame(qpid::framing::ProtocolVersion& _version, u_int16_t channel, AMQBody::shared_ptr& body);
00054             virtual ~AMQFrame();
00055             virtual void encode(Buffer& buffer); 
00056             virtual bool decode(Buffer& buffer); 
00057             virtual u_int32_t size() const;
00058             u_int16_t getChannel();
00059             AMQBody::shared_ptr& getBody();
00060 
00061             u_int32_t decodeHead(Buffer& buffer); 
00062             void decodeBody(Buffer& buffer, uint32_t size); 
00063 
00064             friend std::ostream& operator<<(std::ostream& out, const AMQFrame& body);
00065         };
00066 
00067     }
00068 }
00069 
00070 
00071 #endif

Generated on Mon Nov 26 19:13:17 2007 for Qpid by  doxygen 1.5.1