/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/broker/PreviewConnection.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 _PreviewConnection_
00022 #define _PreviewConnection_
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 "PreviewConnectionHandler.h"
00042 #include "ConnectionState.h"
00043 #include "PreviewSessionHandler.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 PreviewConnection : public sys::ConnectionInputHandler, public ConnectionState
00054 {
00055   public:
00056     PreviewConnection(sys::ConnectionOutputHandler* out, Broker& broker, const std::string& mgmtId, bool isLink = false);
00057     ~PreviewConnection ();
00058 
00060     PreviewSessionHandler& getChannel(framing::ChannelId channel);
00061 
00063     void close(framing::ReplyCode code, const string& text, framing::ClassId classId, framing::MethodId methodId);
00064 
00065     // ConnectionInputHandler methods
00066     void received(framing::AMQFrame& frame);
00067     void idleOut();
00068     void idleIn();
00069     void closed();
00070     bool doOutput();
00071 
00072     void closeChannel(framing::ChannelId channel);
00073 
00074     // Manageable entry points
00075     management::ManagementObject::shared_ptr GetManagementObject (void) const;
00076     management::Manageable::status_t
00077         ManagementMethod (uint32_t methodId, management::Args& args);
00078 
00079 
00080   private:
00081     typedef boost::ptr_map<framing::ChannelId, PreviewSessionHandler> ChannelMap;
00082     typedef std::vector<Queue::shared_ptr>::iterator queue_iterator;
00083 
00090     class MgmtWrapper
00091     {
00092     public:
00093         virtual ~MgmtWrapper(){}
00094         virtual void received(framing::AMQFrame& frame) = 0;
00095         virtual management::ManagementObject::shared_ptr getManagementObject() const = 0;
00096         virtual void closing() = 0;
00097         virtual void processPending(){}
00098         virtual void process(PreviewConnection&, const management::Args&){}
00099     };
00100     class MgmtClient;
00101     class MgmtLink;
00102 
00103     ChannelMap channels;
00104     framing::AMQP_ClientProxy::Connection* client;
00105     uint64_t stagingThreshold;
00106     PreviewConnectionHandler adapter;
00107     std::auto_ptr<MgmtWrapper> mgmtWrapper;
00108     bool mgmtClosing;
00109     const std::string mgmtId;
00110 };
00111 
00112 }}
00113 
00114 #endif

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