Apache Qpid C++ API
Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation

qpid/framing/SequenceSet.h

Go to the documentation of this file.
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 _framing_SequenceSet_h
00022 #define _framing_SequenceSet_h
00023 
00024 #include "SequenceNumber.h"
00025 #include "qpid/RangeSet.h"
00026 
00027 namespace qpid {
00028 namespace framing {
00029 class Buffer;
00030 
00031 class SequenceSet : public RangeSet<SequenceNumber> {
00032   public:
00033     SequenceSet() {}
00034     SequenceSet(const RangeSet<SequenceNumber>& r)
00035         : RangeSet<SequenceNumber>(r) {}
00036     SequenceSet(const SequenceNumber& s) { add(s); }
00037     SequenceSet(const SequenceNumber& start, const SequenceNumber finish) { add(start,finish); }
00038     
00039     
00040     void encode(Buffer& buffer) const;
00041     void decode(Buffer& buffer);
00042     uint32_t encodedSize() const;   
00043 
00044     bool contains(const SequenceNumber& s) const;
00045     void add(const SequenceNumber& s);
00046     void add(const SequenceNumber& start, const SequenceNumber& finish); // Closed range
00047     void add(const SequenceSet& set);
00048     void remove(const SequenceNumber& s);
00049     void remove(const SequenceNumber& start, const SequenceNumber& finish); // Closed range
00050     void remove(const SequenceSet& set);
00051 
00052     template <class T> void for_each(T& t) const {
00053         for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++) 
00054             t(i->first(), i->last());
00055         }
00056 
00057     template <class T> void for_each(const T& t) const {
00058         for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++) 
00059             t(i->first(), i->last());
00060     }
00061 
00062   friend std::ostream& operator<<(std::ostream&, const SequenceSet&);
00063 };    
00064 
00065 }} // namespace qpid::framing
00066 
00067 
00068 #endif

Qpid C++ API Reference
Generated on Tue Dec 8 15:39:36 2009 for Qpid C++ Client API by doxygen 1.4.7