summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/framing
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-07-19 08:27:36 +0000
committerGordon Sim <gsim@apache.org>2007-07-19 08:27:36 +0000
commitb87a1e9d27755e2f98792567c29a0625b92c8654 (patch)
treecb1232987efbfa1cc0ef8ec5e62b07b6b6c918b6 /cpp/src/qpid/framing
parentdfe8a370b6580446cf970e27562ad0385178922f (diff)
downloadqpid-python-b87a1e9d27755e2f98792567c29a0625b92c8654.tar.gz
removed the need to pass MethodContext/RequestId through proxy and handler/adapter interfaces
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@557522 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/framing')
-rw-r--r--cpp/src/qpid/framing/FramingContent.h20
-rw-r--r--cpp/src/qpid/framing/MethodContext.cpp7
-rw-r--r--cpp/src/qpid/framing/Proxy.h1
-rw-r--r--cpp/src/qpid/framing/SequenceNumber.cpp62
-rw-r--r--cpp/src/qpid/framing/SequenceNumber.h51
5 files changed, 139 insertions, 2 deletions
diff --git a/cpp/src/qpid/framing/FramingContent.h b/cpp/src/qpid/framing/FramingContent.h
index 876e90c905..c813408cf3 100644
--- a/cpp/src/qpid/framing/FramingContent.h
+++ b/cpp/src/qpid/framing/FramingContent.h
@@ -1,3 +1,23 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
#ifndef _framing_FramingContent_h
#define _framing_FramingContent_h
diff --git a/cpp/src/qpid/framing/MethodContext.cpp b/cpp/src/qpid/framing/MethodContext.cpp
index 73af73f8e5..9dc42dcfd7 100644
--- a/cpp/src/qpid/framing/MethodContext.cpp
+++ b/cpp/src/qpid/framing/MethodContext.cpp
@@ -24,8 +24,11 @@ namespace qpid {
namespace framing {
RequestId MethodContext::getRequestId() const {
- return boost::shared_polymorphic_downcast<AMQRequestBody>(methodBody)
- ->getRequestId();
+ if (methodBody->type() == REQUEST_BODY) {
+ return boost::shared_polymorphic_cast<AMQRequestBody>(methodBody)->getRequestId();
+ } else {
+ return 0;
+ }
}
}} // namespace qpid::framing
diff --git a/cpp/src/qpid/framing/Proxy.h b/cpp/src/qpid/framing/Proxy.h
index 8ed46ed748..4af496387b 100644
--- a/cpp/src/qpid/framing/Proxy.h
+++ b/cpp/src/qpid/framing/Proxy.h
@@ -20,6 +20,7 @@
*/
#include "ProtocolVersion.h"
+#include "amqp_types.h"
namespace qpid {
namespace framing {
diff --git a/cpp/src/qpid/framing/SequenceNumber.cpp b/cpp/src/qpid/framing/SequenceNumber.cpp
new file mode 100644
index 0000000000..9bba67d4ae
--- /dev/null
+++ b/cpp/src/qpid/framing/SequenceNumber.cpp
@@ -0,0 +1,62 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "SequenceNumber.h"
+
+using qpid::framing::SequenceNumber;
+
+SequenceNumber::SequenceNumber() : value(0) {}
+
+SequenceNumber::SequenceNumber(uint32_t v) : value((int32_t) v) {}
+
+bool SequenceNumber::operator==(const SequenceNumber& other) const
+{
+ return value == other.value;
+}
+
+bool SequenceNumber::operator!=(const SequenceNumber& other) const
+{
+ return !(value == other.value);
+}
+
+
+SequenceNumber& SequenceNumber::operator++()
+{
+ value = value + 1;
+ return *this;
+}
+
+const SequenceNumber SequenceNumber::operator++(int)
+{
+ SequenceNumber old(value);
+ value = value + 1;
+ return old;
+}
+
+bool SequenceNumber::operator<(const SequenceNumber& other) const
+{
+ return (value - other.value) < 0;
+}
+
+bool SequenceNumber::operator>(const SequenceNumber& other) const
+{
+ return other < *this;
+}
diff --git a/cpp/src/qpid/framing/SequenceNumber.h b/cpp/src/qpid/framing/SequenceNumber.h
new file mode 100644
index 0000000000..6d38084a25
--- /dev/null
+++ b/cpp/src/qpid/framing/SequenceNumber.h
@@ -0,0 +1,51 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+#ifndef _framing_SequenceNumber_h
+#define _framing_SequenceNumber_h
+
+#include "amqp_types.h"
+
+namespace qpid {
+namespace framing {
+
+/**
+ * 4-byte sequence number that 'wraps around'.
+ */
+class SequenceNumber
+{
+ int32_t value;
+ public:
+ SequenceNumber();
+ SequenceNumber(uint32_t v);
+
+ SequenceNumber& operator++();//prefix ++
+ const SequenceNumber operator++(int);//postfix ++
+ bool operator==(const SequenceNumber& other) const;
+ bool operator!=(const SequenceNumber& other) const;
+ bool operator<(const SequenceNumber& other) const;
+ bool operator>(const SequenceNumber& other) const;
+ uint32_t getValue() const { return (uint32_t) value; }
+};
+
+}} // namespace qpid::framing
+
+
+#endif