summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2009-01-16 20:07:47 +0000
committerTed Ross <tross@apache.org>2009-01-16 20:07:47 +0000
commit46e82569f85137c8cd8cee3fe86fe4efc662e7f3 (patch)
tree743b37bff10949ac83b1d13774c217acf3667efd
parent480ed248512cedd1ca5197f2a4fb7f805943e992 (diff)
downloadqpid-python-46e82569f85137c8cd8cee3fe86fe4efc662e7f3.tar.gz
QPID-1589 - Added equality/inequality operators to qpid::console::ObjectId.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@735114 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/console/ObjectId.cpp38
-rw-r--r--qpid/cpp/src/qpid/console/ObjectId.h7
2 files changed, 45 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/console/ObjectId.cpp b/qpid/cpp/src/qpid/console/ObjectId.cpp
index 25de9411f6..f8993e7e05 100644
--- a/qpid/cpp/src/qpid/console/ObjectId.cpp
+++ b/qpid/cpp/src/qpid/console/ObjectId.cpp
@@ -43,6 +43,44 @@ void ObjectId::encode(framing::Buffer& buffer)
buffer.putLongLong(second);
}
+bool ObjectId::operator==(const ObjectId& other) const
+{
+ return second == other.second && first == other.first;
+}
+
+bool ObjectId::operator!=(const ObjectId& other) const
+{
+ return !(*this == other);
+}
+
+bool ObjectId::operator<(const ObjectId& other) const
+{
+ if (first < other.first)
+ return true;
+ if (first > other.first)
+ return false;
+ return second < other.second;
+}
+
+bool ObjectId::operator>(const ObjectId& other) const
+{
+ if (first > other.first)
+ return true;
+ if (first < other.first)
+ return false;
+ return second > other.second;
+}
+
+bool ObjectId::operator<=(const ObjectId& other) const
+{
+ return !(*this > other);
+}
+
+bool ObjectId::operator>=(const ObjectId& other) const
+{
+ return !(*this < other);
+}
+
ostream& qpid::console::operator<<(ostream& o, const ObjectId& id)
{
o << (int) id.getFlags() << "-" << id.getSequence() << "-" << id.getBrokerBank() << "-" <<
diff --git a/qpid/cpp/src/qpid/console/ObjectId.h b/qpid/cpp/src/qpid/console/ObjectId.h
index 7d0399e51c..73304ca306 100644
--- a/qpid/cpp/src/qpid/console/ObjectId.h
+++ b/qpid/cpp/src/qpid/console/ObjectId.h
@@ -49,6 +49,13 @@ namespace console {
void encode(framing::Buffer& buffer);
void setValue(uint64_t f, uint64_t s) { first = f; second = s; }
+ bool operator==(const ObjectId& other) const;
+ bool operator!=(const ObjectId& other) const;
+ bool operator<(const ObjectId& other) const;
+ bool operator>(const ObjectId& other) const;
+ bool operator<=(const ObjectId& other) const;
+ bool operator>=(const ObjectId& other) const;
+
private:
uint64_t first;
uint64_t second;