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

00001 #ifndef QPID_BROKER_PREVIEWSESSION_H
00002 #define QPID_BROKER_PREVIEWSESSION_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 "qpid/framing/Uuid.h"
00026 #include "qpid/framing/FrameHandler.h"
00027 #include "qpid/framing/SessionState.h"
00028 #include "qpid/framing/ProtocolVersion.h"
00029 #include "qpid/sys/Mutex.h"
00030 #include "qpid/sys/Time.h"
00031 #include "qpid/management/Manageable.h"
00032 #include "qpid/management/Session.h"
00033 #include "SessionContext.h"
00034 
00035 #include <boost/noncopyable.hpp>
00036 #include <boost/scoped_ptr.hpp>
00037 
00038 #include <set>
00039 #include <vector>
00040 #include <ostream>
00041 
00042 namespace qpid {
00043 
00044 namespace framing {
00045 class AMQP_ClientProxy;
00046 }
00047 
00048 namespace broker {
00049 
00050 class SemanticHandler;
00051 class PreviewSessionHandler;
00052 class PreviewSessionManager;
00053 class Broker;
00054 class ConnectionState;
00055 
00060 class PreviewSessionState : public framing::SessionState,
00061     public SessionContext,
00062     public framing::FrameHandler::Chains,
00063     public management::Manageable
00064 {
00065   public:
00066     ~PreviewSessionState();
00067     bool isAttached() const { return handler; }
00068 
00069     void detach();
00070     void attach(PreviewSessionHandler& handler);
00071 
00072     
00073     PreviewSessionHandler* getHandler();
00074 
00076     framing::AMQP_ClientProxy& getProxy();
00077     
00079     ConnectionState& getConnection();
00080     bool isLocal(const ConnectionToken* t) const;
00081 
00082     uint32_t getTimeout() const { return timeout; }
00083     Broker& getBroker() { return broker; }
00084     framing::ProtocolVersion getVersion() const { return version; }
00085 
00087     void activateOutput();
00088 
00089     // Manageable entry points
00090     management::ManagementObject::shared_ptr GetManagementObject (void) const;
00091     management::Manageable::status_t
00092         ManagementMethod (uint32_t methodId, management::Args& args);
00093 
00094     // Normally SessionManager creates sessions.
00095     PreviewSessionState(PreviewSessionManager*,
00096                  PreviewSessionHandler* out,
00097                  uint32_t timeout,
00098                  uint32_t ackInterval);
00099     
00100 
00101   private:
00102     PreviewSessionManager* factory;
00103     PreviewSessionHandler* handler;    
00104     framing::Uuid id;
00105     uint32_t timeout;
00106     sys::AbsTime expiry;        // Used by SessionManager.
00107     Broker& broker;
00108     framing::ProtocolVersion version;
00109     sys::Mutex lock;
00110     boost::scoped_ptr<SemanticHandler> semanticHandler;
00111     management::Session::shared_ptr mgmtObject;
00112 
00113   friend class PreviewSessionManager;
00114 };
00115 
00116 
00117 inline std::ostream& operator<<(std::ostream& out, const PreviewSessionState& session) {
00118     return out << session.getId();
00119 }
00120 
00121 }} // namespace qpid::broker
00122 
00123 
00124 
00125 #endif  

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