/home/aconway/svn/qpid/cpp/src/qpid/broker/BrokerMessageMessage.h

00001 #ifndef _broker_BrokerMessageMessage_h
00002 #define _broker_BrokerMessageMessage_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 "BrokerMessageBase.h"
00025 #include "qpid/framing/MessageTransferBody.h"
00026 #include "qpid/framing/amqp_types.h"
00027 #include <boost/weak_ptr.hpp>
00028 #include <vector>
00029 
00030 namespace qpid {
00031 
00032 namespace framing {
00033 class MessageTransferBody;
00034 }
00035         
00036 namespace broker {
00037 class ConnectionToken;
00038 class Reference;
00039 
00040 class MessageMessage: public Message{
00041   public:
00042     typedef boost::shared_ptr<MessageMessage> shared_ptr;
00043     typedef boost::shared_ptr<framing::MessageTransferBody> TransferPtr;
00044     typedef boost::shared_ptr<Reference> ReferencePtr;
00045     
00046     MessageMessage(ConnectionToken* publisher, framing::RequestId, TransferPtr transfer);
00047     MessageMessage(ConnectionToken* publisher, framing::RequestId, TransferPtr transfer, ReferencePtr reference);
00048     MessageMessage();
00049             
00050     // Default destructor okay
00051 
00052     framing::RequestId getRequestId() const {return requestId; }
00053     TransferPtr getTransfer() const { return transfer; }
00054     ReferencePtr getReference() const ;
00055     
00056     void deliver(framing::ChannelAdapter& channel, 
00057                  const std::string& consumerTag, 
00058                  uint64_t deliveryTag, 
00059                  uint32_t framesize);
00060     
00061     void sendGetOk(const framing::MethodContext& context, 
00062                                    const std::string& destination,
00063                    uint32_t messageCount,
00064                    uint64_t deliveryTag, 
00065                    uint32_t framesize);
00066 
00067     bool isComplete();
00068 
00069     uint64_t contentSize() const;
00070     framing::BasicHeaderProperties* getHeaderProperties();
00071     const framing::FieldTable& getApplicationHeaders();
00072     bool isPersistent();
00073             
00074     void encode(framing::Buffer& buffer) const;
00075     void encodeHeader(framing::Buffer& buffer) const;
00076     uint32_t encodedSize() const;
00077     uint32_t encodedHeaderSize() const;
00078     uint32_t encodedContentSize() const;
00079     uint64_t expectedContentSize();
00080     void decodeHeader(framing::Buffer& buffer);
00081     void decodeContent(framing::Buffer& buffer, uint32_t contentChunkSize = 0);
00082 
00083   private:
00084     void transferMessage(
00085         framing::ChannelAdapter& channel, 
00086         const std::string& consumerTag, 
00087         uint32_t framesize);
00088     
00089     framing::MessageTransferBody* copyTransfer(
00090         const framing::ProtocolVersion& version,
00091         const std::string& destination, 
00092         const framing::Content& body) const;
00093   
00094     framing::RequestId requestId;
00095     const TransferPtr transfer;
00096     const boost::shared_ptr<Reference> reference;
00097 };
00098 
00099 }}
00100 
00101 
00102 #endif  

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