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

00001 #ifndef QPID_BROKER_SESSIONMANAGER_H
00002 #define QPID_BROKER_SESSIONMANAGER_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/sys/Time.h>
00027 #include <qpid/sys/Mutex.h>
00028 #include <qpid/RefCounted.h>
00029 
00030 #include <set>
00031 #include <vector>
00032 #include <memory>
00033 
00034 #include <boost/noncopyable.hpp>
00035 #include <boost/ptr_container/ptr_vector.hpp>
00036 #include <boost/intrusive_ptr.hpp>
00037 
00038 namespace qpid {
00039 namespace broker {
00040 
00041 class SessionState;
00042 class SessionHandler;
00043 
00047 class SessionManager : private boost::noncopyable {
00048   public:
00052     struct Observer : public RefCounted {
00053         virtual void opened(SessionState&) {}
00054     };
00055     
00056     SessionManager(uint32_t ack);
00057     
00058     ~SessionManager();
00059     
00061     std::auto_ptr<SessionState> open(SessionHandler& c, uint32_t timeout_);
00062     
00066     void suspend(std::auto_ptr<SessionState> session);
00067         
00071     std::auto_ptr<SessionState> resume(const framing::Uuid&);
00072 
00074     void add(const boost::intrusive_ptr<Observer>&);
00075     
00076   private:
00077     typedef boost::ptr_vector<SessionState> Suspended;
00078     typedef std::set<framing::Uuid> Active;
00079     typedef std::vector<boost::intrusive_ptr<Observer> > Observers;
00080 
00081     void erase(const framing::Uuid&);             
00082     void eraseExpired();             
00083 
00084     sys::Mutex lock;
00085     Suspended suspended;
00086     Active active;
00087     uint32_t ack;
00088     Observers observers;
00089     
00090   friend class SessionState; // removes deleted sessions from active set.
00091 };
00092 
00093 
00094 
00095 }} // namespace qpid::broker
00096 
00097 
00098 
00099 
00100 
00101 #endif  

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