00001 #ifndef QPID_BROKER_SESSIONMANAGER_H
00002 #define QPID_BROKER_SESSIONMANAGER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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_, std::string name);
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;
00091 };
00092
00093
00094
00095 }}
00096
00097
00098
00099
00100
00101 #endif