/usr/share/cruisecontrol-bin-2.6.1/projects/qpid-trunk/cpp/src/qpid/framing/SessionState.h

00001 #ifndef QPID_FRAMING_SESSIONSTATE_H
00002 #define QPID_FRAMING_SESSIONSTATE_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/SequenceNumber.h"
00026 #include "qpid/framing/Uuid.h"
00027 #include "qpid/framing/AMQFrame.h"
00028 #include "qpid/sys/Mutex.h"
00029 
00030 #include <boost/optional.hpp>
00031 
00032 #include <deque>
00033 
00034 namespace qpid {
00035 namespace framing {
00036 
00045 class SessionState
00046 {
00047   public:
00048     typedef std::vector<AMQFrame> Replay;
00049 
00051     enum State {
00052         SUSPENDED, 
00053         RESUMING, 
00054         ATTACHED 
00055     };
00056 
00064     SessionState(uint32_t ackInterval, bool enableReplay = true, const framing::Uuid& id=framing::Uuid(true));
00065 
00070     SessionState(const framing::Uuid& id=framing::Uuid(true));
00071 
00072     const framing::Uuid& getId() const { return id; }
00073     State getState() const { return state; }
00074     
00080     boost::optional<SequenceNumber> received(const AMQFrame&);
00081 
00086     bool sent(const AMQFrame&);
00087 
00089     void receivedAck(SequenceNumber);
00090 
00094     Replay replay();
00095 
00097     void suspend();
00098 
00101     SequenceNumber resuming();
00102 
00109     SequenceNumber sendingAck();
00110 
00111     SequenceNumber getLastSent() const { return lastSent; }
00112     SequenceNumber getLastReceived() const { return lastReceived; }
00113 
00114   private:
00115     typedef std::deque<AMQFrame> Unacked;
00116 
00117     bool sendingSolicit();
00118 
00119     State state;
00120     framing::Uuid id;
00121 
00122     Unacked unackedOut;
00123     SequenceNumber lastReceived;
00124     SequenceNumber lastSent;
00125     uint32_t ackInterval;
00126     SequenceNumber sendAckAt;
00127     SequenceNumber solicitAckAt;
00128     bool ackSolicited;
00129     bool suspending;
00130     bool resumable;
00131     sys::Mutex unackedLock;
00132 };
00133 
00134 
00135 }} // namespace qpid::common
00136 
00137 
00138 #endif  

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