/home/aconway/svn/qpid/cpp/src/qpid/broker/Connection.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 #ifndef _Connection_
00022 #define _Connection_
00023 
00024 #include <sstream>
00025 #include <vector>
00026 
00027 #include <boost/ptr_container/ptr_map.hpp>
00028 
00029 #include "qpid/framing/AMQFrame.h"
00030 #include "qpid/framing/AMQP_ServerOperations.h"
00031 #include "qpid/framing/AMQP_ClientProxy.h"
00032 #include "qpid/sys/ConnectionOutputHandler.h"
00033 #include "qpid/sys/ConnectionInputHandler.h"
00034 #include "qpid/sys/TimeoutHandler.h"
00035 #include "qpid/framing/ProtocolVersion.h"
00036 #include "Broker.h"
00037 #include "qpid/Exception.h"
00038 #include "BrokerChannel.h"
00039 
00040 namespace qpid {
00041 namespace broker {
00042 
00043 class Channel;
00044 
00045 class Connection : public sys::ConnectionInputHandler, 
00046                    public ConnectionToken
00047 {
00048   public:
00049     Connection(sys::ConnectionOutputHandler* out, Broker& broker);
00050 
00052     Channel& getChannel(framing::ChannelId channel);
00053 
00055     void closeChannel(framing::ChannelId channel);
00056 
00058     void close(framing::ReplyCode code, const string& text, framing::ClassId classId, framing::MethodId methodId);
00059 
00060     sys::ConnectionOutputHandler& getOutput() const { return *out; }
00061     framing::ProtocolVersion getVersion() const { return version; }
00062 
00063     uint32_t getFrameMax() const { return framemax; }
00064     uint16_t getHeartbeat() const { return heartbeat; }
00065     uint32_t getTimeout() const { return timeout; }
00066     uint64_t getStagingThreshold() const { return stagingThreshold; }
00067 
00068     void setFrameMax(uint32_t fm) { framemax = fm; }
00069     void setHeartbeat(uint16_t hb) { heartbeat = hb; }
00070     
00077     Queue::shared_ptr getQueue(const string& name, uint16_t channel);
00078 
00079     Broker& broker;
00080     std::vector<Queue::shared_ptr> exclusiveQueues;
00081 
00082     // ConnectionInputHandler methods
00083     void received(framing::AMQFrame* frame);
00084     void initiated(const framing::ProtocolInitiation& header);
00085     void idleOut();
00086     void idleIn();
00087     void closed();
00088 
00089   private:
00090     typedef boost::ptr_map<framing::ChannelId, Channel> ChannelMap;
00091 
00092     typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
00093     Exchange::shared_ptr findExchange(const string& name);
00094 
00095     framing::ProtocolVersion version;
00096     ChannelMap channels;
00097     sys::ConnectionOutputHandler* out;
00098     uint32_t framemax;
00099     uint16_t heartbeat;
00100     framing::AMQP_ClientProxy::Connection* client;
00101     const uint32_t timeout; //timeout for auto-deleted queues (in ms)
00102     const uint64_t stagingThreshold;
00103 
00104 };
00105 
00106 }}
00107 
00108 #endif

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