/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/broker/Message.h

00001 #ifndef _broker_Message_h
00002 #define _broker_Message_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 
00025 #include <string>
00026 #include <boost/shared_ptr.hpp>
00027 #include <boost/variant.hpp>
00028 #include "PersistableMessage.h"
00029 #include "MessageAdapter.h"
00030 #include "qpid/framing/amqp_types.h"
00031 
00032 namespace qpid {
00033         
00034 namespace framing {
00035 class FieldTable;
00036 class SequenceNumber;
00037 }
00038         
00039 namespace broker {
00040 class ConnectionToken;
00041 class Exchange;
00042 class ExchangeRegistry;
00043 class MessageStore;
00044 class Queue;
00045 
00046 class Message : public PersistableMessage {
00047 public:
00048     typedef boost::intrusive_ptr<Message> shared_ptr;
00049 
00050     Message(const framing::SequenceNumber& id = framing::SequenceNumber());
00051     ~Message();
00052         
00053     uint64_t getPersistenceId() const { return persistenceId; }
00054     void setPersistenceId(uint64_t _persistenceId) const { persistenceId = _persistenceId; }
00055 
00056     bool getRedelivered() const { return redelivered; }
00057     void redeliver() { redelivered = true; }
00058 
00059     const ConnectionToken* getPublisher() const {  return publisher; }
00060     void setPublisher(ConnectionToken* p) {  publisher = p; }
00061 
00062     const framing::SequenceNumber& getCommandId() { return frames.getId(); }
00063 
00064     uint64_t contentSize() const;
00065 
00066     std::string getRoutingKey() const;
00067     const boost::shared_ptr<Exchange> getExchange(ExchangeRegistry&) const;
00068     std::string getExchangeName() const;
00069     bool isImmediate() const;
00070     const framing::FieldTable* getApplicationHeaders() const;
00071     bool isPersistent();
00072     bool requiresAccept();
00073 
00074     framing::FrameSet& getFrames() { return frames; } 
00075     const framing::FrameSet& getFrames() const { return frames; } 
00076 
00077     template <class T> T* getProperties() {
00078         return frames.getHeaders()->get<T>(true);
00079     }
00080 
00081     template <class T> const T* getProperties() const {
00082         return frames.getHeaders()->get<T>();
00083     }
00084 
00085     template <class T> const T* getMethod() const {
00086         return frames.as<T>();
00087     }
00088 
00089     template <class T> bool isA() const {
00090         return frames.isA<T>();
00091     }
00092 
00093     uint32_t getRequiredCredit() const;
00094 
00095     void encode(framing::Buffer& buffer) const;
00096     void encodeContent(framing::Buffer& buffer) const;
00097 
00102     uint32_t encodedSize() const;
00108     uint32_t encodedHeaderSize() const;
00109     uint32_t encodedContentSize() const;
00110 
00111     void decodeHeader(framing::Buffer& buffer);
00112     void decodeContent(framing::Buffer& buffer);
00113             
00119     void releaseContent(MessageStore* store);
00120 
00121     void sendContent(Queue& queue, framing::FrameHandler& out, uint16_t maxFrameSize) const;
00122     void sendHeader(framing::FrameHandler& out, uint16_t maxFrameSize) const;
00123 
00124     bool isContentLoaded() const;
00125 
00126   private:
00127     framing::FrameSet frames;
00128     mutable boost::shared_ptr<Exchange> exchange;
00129     mutable uint64_t persistenceId;
00130     bool redelivered;
00131     bool loaded;
00132     bool staged;
00133     ConnectionToken* publisher;
00134     mutable MessageAdapter* adapter;
00135 
00136     static TransferAdapter TRANSFER;
00137     static PreviewAdapter TRANSFER_99_0;
00138 
00139     MessageAdapter& getAdapter() const;
00140 };
00141 
00142 }}
00143 
00144 
00145 #endif

Generated on Thu Apr 10 11:08:17 2008 for Qpid by  doxygen 1.4.7