/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/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 <memory>
00025 #include <sstream>
00026 #include <vector>
00027 
00028 #include <boost/ptr_container/ptr_map.hpp>
00029 
00030 #include "qpid/framing/AMQFrame.h"
00031 #include "qpid/framing/AMQP_ServerOperations.h"
00032 #include "qpid/framing/AMQP_ClientProxy.h"
00033 #include "qpid/sys/AggregateOutput.h"
00034 #include "qpid/sys/ConnectionOutputHandler.h"
00035 #include "qpid/sys/ConnectionInputHandler.h"
00036 #include "qpid/sys/TimeoutHandler.h"
00037 #include "qpid/framing/ProtocolVersion.h"
00038 #include "Broker.h"
00039 #include "qpid/sys/Socket.h"
00040 #include "qpid/Exception.h"
00041 #include "ConnectionHandler.h"
00042 #include "ConnectionState.h"
00043 #include "SessionHandler.h"
00044 #include "qpid/management/Manageable.h"
00045 #include "qpid/management/Client.h"
00046 #include "qpid/management/Link.h"
00047 
00048 #include <boost/ptr_container/ptr_map.hpp>
00049 
00050 namespace qpid {
00051 namespace broker {
00052 
00053 class Connection : public sys::ConnectionInputHandler, 
00054                    public ConnectionState
00055 {
00056   public:
00057     Connection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId);
00058     ~Connection ();
00059 
00061     SessionHandler& getChannel(framing::ChannelId channel);
00062 
00064     void close(framing::ReplyCode code, const string& text, framing::ClassId classId, framing::MethodId methodId);
00065 
00066     // ConnectionInputHandler methods
00067     void received(framing::AMQFrame& frame);
00068     void idleOut();
00069     void idleIn();
00070     void closed();
00071     bool doOutput();
00072 
00073     void closeChannel(framing::ChannelId channel);
00074 
00075     // Manageable entry points
00076     management::ManagementObject::shared_ptr GetManagementObject (void) const;
00077     management::Manageable::status_t
00078         ManagementMethod (uint32_t methodId, management::Args& args);
00079 
00080     void initMgmt(bool asLink = false);
00081 
00082   private:
00083     typedef boost::ptr_map<framing::ChannelId, SessionHandler> ChannelMap;
00084     typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
00085 
00092     class MgmtWrapper
00093     {
00094     public:
00095         virtual ~MgmtWrapper(){}
00096         virtual void received(framing::AMQFrame& frame) = 0;
00097         virtual management::ManagementObject::shared_ptr getManagementObject() const = 0;
00098         virtual void closing() = 0;
00099         virtual void processPending(){}
00100         virtual void process(Connection&, const management::Args&){}
00101     };
00102     class MgmtClient;
00103     class MgmtLink;
00104 
00105     ChannelMap channels;
00106     framing::AMQP_ClientProxy::Connection* client;
00107     ConnectionHandler adapter;
00108     std::auto_ptr<MgmtWrapper> mgmtWrapper;
00109     bool mgmtClosing;
00110     const std::string mgmtId;
00111 };
00112 
00113 }}
00114 
00115 #endif

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