summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/framing')
-rw-r--r--cpp/src/qpid/framing/Handler.h6
-rw-r--r--cpp/src/qpid/framing/Proxy.cpp9
-rw-r--r--cpp/src/qpid/framing/Proxy.h10
-rw-r--r--cpp/src/qpid/framing/SequenceSet.cpp2
-rw-r--r--cpp/src/qpid/framing/SequenceSet.h15
-rw-r--r--cpp/src/qpid/framing/SessionState.h2
6 files changed, 28 insertions, 16 deletions
diff --git a/cpp/src/qpid/framing/Handler.h b/cpp/src/qpid/framing/Handler.h
index fbf3c0b7ca..b93869be85 100644
--- a/cpp/src/qpid/framing/Handler.h
+++ b/cpp/src/qpid/framing/Handler.h
@@ -82,14 +82,14 @@ struct Handler {
template <class X, void (X::*F)(T)>
class MemFunRef : public Handler<T> {
public:
- MemFunRef(X& x, Handler<T>* next=0) : Handler(next), target(x) {}
- void handle(T t) { (target.*F)(t); }
+ MemFunRef(X& x, Handler<T>* next=0) : Handler(next), target(&x) {}
+ void handle(T t) { (target->*F)(t); }
/** Allow calling with -> syntax, compatible with Chains */
MemFunRef* operator->() { return this; }
private:
- X& target;
+ X* target;
};
/** Interface for a handler that implements a
diff --git a/cpp/src/qpid/framing/Proxy.cpp b/cpp/src/qpid/framing/Proxy.cpp
index b47060028f..6b37fb368d 100644
--- a/cpp/src/qpid/framing/Proxy.cpp
+++ b/cpp/src/qpid/framing/Proxy.cpp
@@ -22,16 +22,21 @@
namespace qpid {
namespace framing {
+Proxy::Proxy(FrameHandler& h) : out(&h) {}
+
Proxy::~Proxy() {}
void Proxy::send(const AMQBody& b) {
AMQFrame f(b);
- out.handle(f);
+ out->handle(f);
}
-
ProtocolVersion Proxy::getVersion() const {
return ProtocolVersion();
}
+FrameHandler& Proxy::getHandler() { return *out; }
+
+void Proxy::setHandler(FrameHandler& f) { out=&f; }
+
}} // namespace qpid::framing
diff --git a/cpp/src/qpid/framing/Proxy.h b/cpp/src/qpid/framing/Proxy.h
index 86b99a83b0..3dc082097a 100644
--- a/cpp/src/qpid/framing/Proxy.h
+++ b/cpp/src/qpid/framing/Proxy.h
@@ -33,16 +33,18 @@ class AMQBody;
class Proxy
{
public:
- Proxy(FrameHandler& h) : out(h) {}
+ Proxy(FrameHandler& h);
virtual ~Proxy();
void send(const AMQBody&);
ProtocolVersion getVersion() const;
- FrameHandler& getHandler() { return out; }
- protected:
- FrameHandler& out;
+ FrameHandler& getHandler();
+ void setHandler(FrameHandler&);
+
+ private:
+ FrameHandler* out;
};
}} // namespace qpid::framing
diff --git a/cpp/src/qpid/framing/SequenceSet.cpp b/cpp/src/qpid/framing/SequenceSet.cpp
index cdf890b7f8..9ba55b2fa8 100644
--- a/cpp/src/qpid/framing/SequenceSet.cpp
+++ b/cpp/src/qpid/framing/SequenceSet.cpp
@@ -84,7 +84,7 @@ void SequenceSet::remove(const SequenceNumber& s) { *this -= s; }
struct RangePrinter {
std::ostream& out;
RangePrinter(std::ostream& o) : out(o) {}
- void operator()(SequenceNumber i, SequenceNumber j) {
+ void operator()(SequenceNumber i, SequenceNumber j) const {
out << "[" << i.getValue() << "," << j.getValue() << "] ";
}
};
diff --git a/cpp/src/qpid/framing/SequenceSet.h b/cpp/src/qpid/framing/SequenceSet.h
index 029a26818e..99e7cb4b21 100644
--- a/cpp/src/qpid/framing/SequenceSet.h
+++ b/cpp/src/qpid/framing/SequenceSet.h
@@ -34,6 +34,8 @@ class SequenceSet : public RangeSet<SequenceNumber> {
explicit SequenceSet(const RangeSet<SequenceNumber>& r)
: RangeSet<SequenceNumber>(r) {}
explicit SequenceSet(const SequenceNumber& s) { add(s); }
+ SequenceSet(const SequenceNumber& start, const SequenceNumber finish) { add(start,finish); }
+
void encode(Buffer& buffer) const;
void decode(Buffer& buffer);
@@ -41,17 +43,20 @@ class SequenceSet : public RangeSet<SequenceNumber> {
bool contains(const SequenceNumber& s) const;
void add(const SequenceNumber& s);
- void add(const SequenceNumber& start, const SequenceNumber& end);
+ void add(const SequenceNumber& start, const SequenceNumber& finish); // Closed range
void add(const SequenceSet& set);
void remove(const SequenceNumber& s);
- void remove(const SequenceNumber& start, const SequenceNumber& end);
+ void remove(const SequenceNumber& start, const SequenceNumber& finish); // Closed range
void remove(const SequenceSet& set);
- template <class T> T for_each(T& t) const {
- for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++) {
+ template <class T> void for_each(T& t) const {
+ for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++)
t(i->first(), i->last());
}
- return t;
+
+ template <class T> void for_each(const T& t) const {
+ for (RangeIterator i = rangesBegin(); i != rangesEnd(); i++)
+ t(i->first(), i->last());
}
friend std::ostream& operator<<(std::ostream&, const SequenceSet&);
diff --git a/cpp/src/qpid/framing/SessionState.h b/cpp/src/qpid/framing/SessionState.h
index 4b3f704dda..1df62b3138 100644
--- a/cpp/src/qpid/framing/SessionState.h
+++ b/cpp/src/qpid/framing/SessionState.h
@@ -70,7 +70,7 @@ class SessionState
SessionState(const framing::Uuid& id=framing::Uuid(true));
const framing::Uuid& getId() const { return id; }
- State getState() const { return state; }
+ State getState() { return state; }
/** Received incoming L3 frame.
* @return SequenceNumber if an ack should be sent, empty otherwise.