From 44c50b719e5685bd7a25cdeb9c5c9202ed8dc29a Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Thu, 4 Oct 2007 12:01:28 +0000 Subject: Fix (and refactor) processing of ranges in message handler. Alter release() to push released messages onto head in reverse order (todo: make this atomic instead) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@581869 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/framing/SequenceNumberSet.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cpp/src/qpid/framing') diff --git a/cpp/src/qpid/framing/SequenceNumberSet.h b/cpp/src/qpid/framing/SequenceNumberSet.h index 7643d68071..f9d0cc1fd4 100644 --- a/cpp/src/qpid/framing/SequenceNumberSet.h +++ b/cpp/src/qpid/framing/SequenceNumberSet.h @@ -26,6 +26,7 @@ #include "amqp_types.h" #include "Buffer.h" #include "SequenceNumber.h" +#include "qpid/framing/reply_exceptions.h" namespace qpid { namespace framing { @@ -41,9 +42,24 @@ public: uint32_t encodedSize() const; SequenceNumberSet condense() const; + template + void processRanges(T t) const + { + if (size() % 2) { //must be even number + throw InvalidArgumentException("SequenceNumberSet contains odd number of elements"); + } + + for (SequenceNumberSet::const_iterator i = begin(); i != end(); i++) { + SequenceNumber first = i->getValue(); + SequenceNumber last = (++i)->getValue(); + t(first, last); + } + } + friend std::ostream& operator<<(std::ostream&, const SequenceNumberSet&); }; + }} // namespace qpid::framing -- cgit v1.2.1