summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing/SequenceSet.h
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/framing/SequenceSet.h')
-rw-r--r--cpp/src/qpid/framing/SequenceSet.h44
1 files changed, 7 insertions, 37 deletions
diff --git a/cpp/src/qpid/framing/SequenceSet.h b/cpp/src/qpid/framing/SequenceSet.h
index 8b3d6b3f28..f934bb40bb 100644
--- a/cpp/src/qpid/framing/SequenceSet.h
+++ b/cpp/src/qpid/framing/SequenceSet.h
@@ -21,38 +21,18 @@
#ifndef _framing_SequenceSet_h
#define _framing_SequenceSet_h
-#include "amqp_types.h"
-#include "Buffer.h"
#include "SequenceNumber.h"
-#include "qpid/framing/reply_exceptions.h"
-#include <ostream>
-#include <list>
+#include "qpid/RangeSet.h"
namespace qpid {
namespace framing {
+class Buffer;
-class SequenceSet {
- struct Range {
- SequenceNumber start;
- SequenceNumber end;
-
- Range(SequenceNumber s=0, SequenceNumber e=0);
- bool contains(SequenceNumber i) const;
- bool intersects(const Range& r) const;
- bool merge(const Range& r);
- bool mergeable(const SequenceNumber& r) const;
- void encode(Buffer& buffer) const;
-
- template <class S> void serialize(S& s) { s(start)(end); }
- };
-
- typedef std::list<Range> Ranges;
- Ranges ranges;
-
+class SequenceSet : public RangeSet<SequenceNumber> {
public:
SequenceSet() {}
explicit SequenceSet(const SequenceNumber& s) { add(s); }
-
+
void encode(Buffer& buffer) const;
void decode(Buffer& buffer);
uint32_t size() const;
@@ -65,26 +45,16 @@ class SequenceSet {
void remove(const SequenceNumber& start, const SequenceNumber& end);
void remove(const SequenceSet& set);
- void clear();
- bool empty() const;
-
- template <class T>
- T for_each(T& t) const
- {
- for (Ranges::const_iterator i = ranges.begin(); i != ranges.end(); i++) {
- t(i->start, i->end);
+ template <class T> T for_each(T& t) const {
+ for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++) {
+ t(i->first(), i->last());
}
return t;
}
- template <class S> void serialize(S& s) { s.split(*this); s(ranges.begin(), ranges.end()); }
- template <class S> void encode(S& s) const { s(uint16_t(ranges.size()*sizeof(Range))); }
- template <class S> void decode(S& s) { uint16_t sz; s(sz); ranges.resize(sz/sizeof(Range)); }
-
friend std::ostream& operator<<(std::ostream&, const SequenceSet&);
};
-
}} // namespace qpid::framing