From 07da96698f552090621960295ce15666b4af557e Mon Sep 17 00:00:00 2001 From: Marc Laukien Date: Sun, 9 Sep 2001 02:36:43 +0000 Subject: more tests, fixes to operator< and operator== --- cpp/src/Ice/Endpoint.cpp | 94 ++++++++++++++++------------------------------- cpp/src/Ice/Endpoint.h | 5 --- cpp/src/Ice/Proxy.cpp | 6 --- cpp/src/Ice/Reference.cpp | 20 ++++------ cpp/src/Ice/Reference.h | 1 - 5 files changed, 39 insertions(+), 87 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Ice/Endpoint.cpp b/cpp/src/Ice/Endpoint.cpp index 833af74472b..d8753565839 100644 --- a/cpp/src/Ice/Endpoint.cpp +++ b/cpp/src/Ice/Endpoint.cpp @@ -198,30 +198,24 @@ IceInternal::UnknownEndpoint::equivalent(const AcceptorPtr&) const bool IceInternal::UnknownEndpoint::operator==(const Endpoint& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::UnknownEndpoint::operator!=(const Endpoint& r) const { const UnknownEndpoint* p = dynamic_cast(&r); if (!p) { - return true; + return false; } if (this == p) { - return false; + return true; } if (_rawBytes != p->_rawBytes) { - return true; + return false; } - return false; + return true; } bool @@ -465,45 +459,38 @@ IceInternal::TcpEndpoint::equivalent(const AcceptorPtr& acceptor) const bool IceInternal::TcpEndpoint::operator==(const Endpoint& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::TcpEndpoint::operator!=(const Endpoint& r) const { const TcpEndpoint* p = dynamic_cast(&r); if (!p) { - return true; + return false; } if (this == p) { - return false; + return true; } if (_port != p->_port) { - return true; + return false; } - + + if(_timeout != p->_timeout) + { + return false; + } + struct sockaddr_in laddr; struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (memcmp(&laddr, &raddr, sizeof(struct sockaddr_in)) != 0) { - return true; - } - - if (_timeout != p->_timeout) - { - return true; + return false; } - return false; + return true; } bool @@ -539,7 +526,6 @@ IceInternal::TcpEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; @@ -785,45 +771,38 @@ IceInternal::SslEndpoint::equivalent(const AcceptorPtr& acceptor) const bool IceInternal::SslEndpoint::operator==(const Endpoint& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::SslEndpoint::operator!=(const Endpoint& r) const { const SslEndpoint* p = dynamic_cast(&r); if (!p) { - return true; + return false; } if (this == p) { - return false; + return true; } if (_port != p->_port) { - return true; + return false; } - + + if(_timeout != p->_timeout) + { + return false; + } + struct sockaddr_in laddr; struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (memcmp(&laddr, &raddr, sizeof(struct sockaddr_in)) != 0) { - return true; - } - - if (_timeout != p->_timeout) - { - return true; + return false; } - return false; + return true; } bool @@ -859,7 +838,6 @@ IceInternal::SslEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; @@ -1083,40 +1061,33 @@ IceInternal::UdpEndpoint::equivalent(const AcceptorPtr&) const bool IceInternal::UdpEndpoint::operator==(const Endpoint& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::UdpEndpoint::operator!=(const Endpoint& r) const { const UdpEndpoint* p = dynamic_cast(&r); if (!p) { - return true; + return false; } if (this == p) { - return false; + return true; } if (_port != p->_port) { - return true; + return false; } - + struct sockaddr_in laddr; struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (memcmp(&laddr, &raddr, sizeof(struct sockaddr_in)) != 0) { - return true; + return false; } - return false; + return true; } bool @@ -1152,7 +1123,6 @@ IceInternal::UdpEndpoint::operator<(const Endpoint& r) const struct sockaddr_in raddr; getAddress(_host.c_str(), _port, laddr); getAddress(p->_host.c_str(), p->_port, raddr); - if (laddr.sin_addr.s_addr < raddr.sin_addr.s_addr) { return true; diff --git a/cpp/src/Ice/Endpoint.h b/cpp/src/Ice/Endpoint.h index c2952c9434e..879157dfc41 100644 --- a/cpp/src/Ice/Endpoint.h +++ b/cpp/src/Ice/Endpoint.h @@ -118,7 +118,6 @@ public: // Compare endpoints for sorting purposes // virtual bool operator==(const Endpoint&) const = 0; - virtual bool operator!=(const Endpoint&) const = 0; virtual bool operator<(const Endpoint&) const = 0; }; @@ -144,7 +143,6 @@ public: virtual bool equivalent(const AcceptorPtr&) const; virtual bool operator==(const Endpoint&) const; - virtual bool operator!=(const Endpoint&) const; virtual bool operator<(const Endpoint&) const; private: @@ -179,7 +177,6 @@ public: virtual bool equivalent(const AcceptorPtr&) const; virtual bool operator==(const Endpoint&) const; - virtual bool operator!=(const Endpoint&) const; virtual bool operator<(const Endpoint&) const; private: @@ -216,7 +213,6 @@ public: virtual bool equivalent(const AcceptorPtr&) const; virtual bool operator==(const Endpoint&) const; - virtual bool operator!=(const Endpoint&) const; virtual bool operator<(const Endpoint&) const; private: @@ -253,7 +249,6 @@ public: virtual bool equivalent(const AcceptorPtr&) const; virtual bool operator==(const Endpoint&) const; - virtual bool operator!=(const Endpoint&) const; virtual bool operator<(const Endpoint&) const; private: diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index 0ad0ce7a209..3f257907966 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -146,12 +146,6 @@ IceProxy::Ice::Object::operator==(const Object& r) const return _reference->identity == r._reference->identity; } -bool -IceProxy::Ice::Object::operator!=(const Object& r) const -{ - return _reference->identity != r._reference->identity; -} - bool IceProxy::Ice::Object::operator<(const Object& r) const { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index c7885f1e94e..349a5794bb1 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -347,44 +347,38 @@ IceInternal::Reference::changeEndpoints(const std::vector& newEndpo bool IceInternal::Reference::operator==(const Reference& r) const -{ - return !operator!=(r); -} - -bool -IceInternal::Reference::operator!=(const Reference& r) const { if (this == &r) { - return false; + return true; } if (identity != r.identity) { - return true; + return false; } if (mode != r.mode) { - return true; + return false; } if (secure != r.secure) { - return true; + return false; } if (origEndpoints != r.origEndpoints) { - return true; + return false; } if (endpoints != r.endpoints) { - return true; + return false; } - return false; + return true; } bool diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h index 4433810c596..76c9a375546 100644 --- a/cpp/src/Ice/Reference.h +++ b/cpp/src/Ice/Reference.h @@ -70,7 +70,6 @@ public: ReferencePtr changeEndpoints(const std::vector&) const; bool operator==(const Reference&) const; - bool operator!=(const Reference&) const; bool operator<(const Reference&) const; }; -- cgit v1.2.3