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

00001 #ifndef _AMQMethodBody_
00002 #define _AMQMethodBody_
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 <iostream>
00025 #include "amqp_types.h"
00026 #include "AMQBody.h"
00027 #include "Buffer.h"
00028 #include "qpid/framing/AMQP_ServerOperations.h"
00029 #include "MethodContext.h"
00030 
00031 namespace qpid {
00032 namespace framing {
00033 
00034 class AMQP_MethodVersionMap;
00035 
00036 class AMQMethodBody : public AMQBody
00037 {
00038   public:
00039     typedef boost::shared_ptr<AMQMethodBody> shared_ptr;
00040 
00041     static shared_ptr create(
00042         AMQP_MethodVersionMap& map, ProtocolVersion version, Buffer& buf);
00043 
00044     ProtocolVersion version;    
00045     uint8_t type() const { return METHOD_BODY; }
00046     AMQMethodBody(uint8_t major, uint8_t minor) : version(major, minor) {}
00047     AMQMethodBody(ProtocolVersion ver) : version(ver) {}
00048     virtual ~AMQMethodBody() {}
00049     void decode(Buffer&, uint32_t);
00050 
00051     virtual MethodId amqpMethodId() const = 0;
00052     virtual ClassId  amqpClassId() const = 0;
00053     
00054     virtual void invoke(AMQP_ServerOperations&, const MethodContext&);
00055 
00056     template <class T> bool isA() {
00057         return amqpClassId()==T::CLASS_ID && amqpMethodId()==T::METHOD_ID;
00058     }
00059 
00061     virtual RequestId getRequestId() const { return 0; }
00062 
00063     virtual bool isRequest() const { return false; }
00064     virtual bool isResponse() const { return false; }
00065 
00066   protected:
00067     static uint32_t baseSize() { return 4; }
00068 
00069     struct ClassMethodId {
00070         uint16_t classId;
00071         uint16_t methodId;
00072         void decode(Buffer& b);
00073     };
00074     
00075     void encodeId(Buffer& buffer) const;
00076     virtual void encodeContent(Buffer& buffer) const = 0;
00077     virtual void decodeContent(Buffer& buffer) = 0;
00078 };
00079 
00080 
00081 }} // namespace qpid::framing
00082 
00083 
00084 #endif

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