Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation |
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 _AccumulatedAck_ 00022 #define _AccumulatedAck_ 00023 00024 #include <algorithm> 00025 #include <functional> 00026 #include <list> 00027 #include <ostream> 00028 #include "SequenceNumber.h" 00029 #include "SequenceNumberSet.h" 00030 #include "qpid/CommonImportExport.h" 00031 00032 namespace qpid { 00033 namespace framing { 00034 00035 struct Range 00036 { 00037 SequenceNumber start; 00038 SequenceNumber end; 00039 00040 Range(SequenceNumber s, SequenceNumber e); 00041 bool contains(SequenceNumber i) const; 00042 bool intersect(const Range& r) const; 00043 bool merge(const Range& r); 00044 bool mergeable(const SequenceNumber& r) const; 00045 }; 00050 class AccumulatedAck { 00051 public: 00055 SequenceNumber mark; 00060 std::list<Range> ranges; 00061 00062 QPID_COMMON_EXTERN explicit AccumulatedAck(SequenceNumber r = SequenceNumber()); 00063 QPID_COMMON_EXTERN void update(SequenceNumber firstTag, SequenceNumber lastTag); 00064 QPID_COMMON_EXTERN void consolidate(); 00065 QPID_COMMON_EXTERN void clear(); 00066 QPID_COMMON_EXTERN bool covers(SequenceNumber tag) const; 00067 void collectRanges(SequenceNumberSet& set) const; 00068 QPID_COMMON_EXTERN void update(const SequenceNumber cumulative, const SequenceNumberSet& range); 00069 void operator()(SequenceNumber first, SequenceNumber last) { update(first, last); } 00070 }; 00071 QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const Range&); 00072 QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream&, const AccumulatedAck&); 00073 } 00074 } 00075 00076 00077 #endif