summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-09-25 15:40:21 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-09-25 15:40:21 +0000
commit6744eb871b2dbb6203f64781c510c392662015ce (patch)
tree960b6470e6894c98b3dc5dec68bd42d3f330a544 /cpp/src
parentAdded tests for proxy comparison (diff)
downloadice-6744eb871b2dbb6203f64781c510c392662015ce.tar.bz2
ice-6744eb871b2dbb6203f64781c510c392662015ce.tar.xz
ice-6744eb871b2dbb6203f64781c510c392662015ce.zip
Fixed a bug in proxy comparison
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Reference.cpp223
-rw-r--r--cpp/src/Ice/Reference.h11
2 files changed, 134 insertions, 100 deletions
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 7abdd03bc66..829af4c4dbe 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -287,6 +287,11 @@ IceInternal::Reference::operator==(const Reference& r) const
// Note: if(this == &r) test is performed by each non-abstract derived class.
//
+ if(getType() != r.getType())
+ {
+ return false;
+ }
+
if(_mode != r._mode)
{
return false;
@@ -358,6 +363,15 @@ IceInternal::Reference::operator<(const Reference& r) const
{
return false;
}
+
+ if(getType() < r.getType())
+ {
+ return true;
+ }
+ else if(r.getType() < getType())
+ {
+ return false;
+ }
return false;
}
@@ -424,6 +438,12 @@ IceInternal::FixedReference::getFixedConnections() const
return _fixedConnections;
}
+Reference::Type
+IceInternal::FixedReference::getType() const
+{
+ return Fixed;
+}
+
bool
IceInternal::FixedReference::getSecure() const
{
@@ -610,10 +630,8 @@ IceInternal::FixedReference::operator<(const Reference& r) const
if(Reference::operator==(r))
{
const FixedReference* rhs = dynamic_cast<const FixedReference*>(&r);
- if(rhs)
- {
- return _fixedConnections < rhs->_fixedConnections;
- }
+ assert(rhs);
+ return _fixedConnections < rhs->_fixedConnections;
}
return false;
}
@@ -903,89 +921,86 @@ IceInternal::RoutableReference::operator<(const Reference& r) const
if(Reference::operator==(r))
{
const RoutableReference* rhs = dynamic_cast<const RoutableReference*>(&r);
- if(rhs)
- {
- if(!_secure && rhs->_secure)
- {
- return true;
- }
- else if(rhs->_secure < _secure)
- {
- return false;
- }
- if(!_collocationOptimization && rhs->_collocationOptimization)
- {
- return true;
- }
- else if(rhs->_collocationOptimization < _collocationOptimization)
- {
- return false;
- }
- if(!_cacheConnection && rhs->_cacheConnection)
- {
- return true;
- }
- else if(rhs->_cacheConnection < _cacheConnection)
- {
- return false;
- }
- if(_endpointSelection < rhs->_endpointSelection)
- {
- return true;
- }
- else if(rhs->_endpointSelection < _endpointSelection)
- {
- return false;
- }
- if(_connectionId < rhs->_connectionId)
- {
- return true;
- }
- else if(rhs->_connectionId < _connectionId)
- {
- return false;
- }
- if(!_overrideCompress && rhs->_overrideCompress)
+ assert(rhs);
+ if(!_secure && rhs->_secure)
+ {
+ return true;
+ }
+ else if(rhs->_secure < _secure)
+ {
+ return false;
+ }
+ if(!_collocationOptimization && rhs->_collocationOptimization)
+ {
+ return true;
+ }
+ else if(rhs->_collocationOptimization < _collocationOptimization)
+ {
+ return false;
+ }
+ if(!_cacheConnection && rhs->_cacheConnection)
+ {
+ return true;
+ }
+ else if(rhs->_cacheConnection < _cacheConnection)
+ {
+ return false;
+ }
+ if(_endpointSelection < rhs->_endpointSelection)
+ {
+ return true;
+ }
+ else if(rhs->_endpointSelection < _endpointSelection)
+ {
+ return false;
+ }
+ if(_connectionId < rhs->_connectionId)
+ {
+ return true;
+ }
+ else if(rhs->_connectionId < _connectionId)
+ {
+ return false;
+ }
+ if(!_overrideCompress && rhs->_overrideCompress)
+ {
+ return true;
+ }
+ else if(rhs->_overrideCompress < _overrideCompress)
+ {
+ return false;
+ }
+ else if(_overrideCompress)
+ {
+ if(!_compress && rhs->_compress)
{
return true;
}
- else if(rhs->_overrideCompress < _overrideCompress)
+ else if(rhs->_compress < _compress)
{
return false;
}
- else if(_overrideCompress)
- {
- if(!_compress && rhs->_compress)
- {
- return true;
- }
- else if(rhs->_compress < _compress)
- {
- return false;
- }
- }
-
- if(!_overrideTimeout && rhs->_overrideTimeout)
+ }
+ if(!_overrideTimeout && rhs->_overrideTimeout)
+ {
+ return true;
+ }
+ else if(rhs->_overrideTimeout < _overrideTimeout)
+ {
+ return false;
+ }
+ else if(_overrideTimeout)
+ {
+ if(_timeout < rhs->_timeout)
{
return true;
}
- else if(rhs->_overrideTimeout < _overrideTimeout)
+ else if(rhs->_timeout < _timeout)
{
return false;
}
- else if(_overrideTimeout)
- {
- if(_timeout < rhs->_timeout)
- {
- return true;
- }
- else if(rhs->_timeout < _timeout)
- {
- return false;
- }
- }
- return _routerInfo < rhs->_routerInfo;
- }
+ }
+ return _routerInfo < rhs->_routerInfo;
}
return false;
}
@@ -1201,6 +1216,12 @@ IceInternal::DirectReference::getEndpoints() const
return _endpoints;
}
+Reference::Type
+IceInternal::DirectReference::getType() const
+{
+ return Direct;
+}
+
int
IceInternal::DirectReference::getLocatorCacheTimeout() const
{
@@ -1405,10 +1426,8 @@ IceInternal::DirectReference::operator<(const Reference& r) const
if(RoutableReference::operator==(r))
{
const DirectReference* rhs = dynamic_cast<const DirectReference*>(&r);
- if(rhs)
- {
- return _endpoints < rhs->_endpoints;
- }
+ assert(rhs);
+ return _endpoints < rhs->_endpoints;
}
return false;
}
@@ -1452,6 +1471,12 @@ IceInternal::IndirectReference::getEndpoints() const
return vector<EndpointIPtr>();
}
+Reference::Type
+IceInternal::IndirectReference::getType() const
+{
+ return Indirect;
+}
+
int
IceInternal::IndirectReference::getLocatorCacheTimeout() const
{
@@ -1695,28 +1720,26 @@ IceInternal::IndirectReference::operator<(const Reference& r) const
if(RoutableReference::operator==(r))
{
const IndirectReference* rhs = dynamic_cast<const IndirectReference*>(&r);
- if(rhs)
- {
- if(_adapterId < rhs->_adapterId)
- {
- return true;
- }
- else if(rhs->_adapterId < _adapterId)
- {
- return false;
- }
-
- if(_locatorInfo < rhs->_locatorInfo)
- {
- return true;
- }
- else if(rhs->_locatorInfo < _locatorInfo)
- {
- return false;
- }
+ assert(rhs);
+ if(_adapterId < rhs->_adapterId)
+ {
+ return true;
+ }
+ else if(rhs->_adapterId < _adapterId)
+ {
+ return false;
+ }
+
+ if(_locatorInfo < rhs->_locatorInfo)
+ {
+ return true;
+ }
+ else if(rhs->_locatorInfo < _locatorInfo)
+ {
+ return false;
+ }
- return _locatorCacheTimeout < rhs->_locatorCacheTimeout;
- }
+ return _locatorCacheTimeout < rhs->_locatorCacheTimeout;
}
return false;
}
diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h
index d5b564393f5..caa3a9fb169 100644
--- a/cpp/src/Ice/Reference.h
+++ b/cpp/src/Ice/Reference.h
@@ -43,6 +43,13 @@ public:
ModeLast = ModeBatchDatagram
};
+ enum Type
+ {
+ Fixed,
+ Direct,
+ Indirect
+ };
+
Mode getMode() const { return _mode; }
const Ice::Identity& getIdentity() const { return _identity; }
const std::string& getFacet() const { return _facet; }
@@ -56,6 +63,7 @@ public:
virtual RouterInfoPtr getRouterInfo() const { return 0; }
virtual LocatorInfoPtr getLocatorInfo() const { return 0; }
+ virtual Type getType() const = 0;
virtual bool getSecure() const = 0;
virtual std::string getAdapterId() const = 0;
virtual std::vector<EndpointIPtr> getEndpoints() const = 0;
@@ -140,6 +148,7 @@ public:
const std::vector<Ice::ConnectionIPtr>& getFixedConnections() const;
+ virtual Type getType() const;
virtual bool getSecure() const;
virtual std::string getAdapterId() const;
virtual std::vector<EndpointIPtr> getEndpoints() const;
@@ -245,6 +254,7 @@ public:
DirectReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
const std::string&, Mode, bool, const std::vector<EndpointIPtr>&, const RouterInfoPtr&, bool);
+ virtual Type getType() const;
virtual int getLocatorCacheTimeout() const;
virtual std::string getAdapterId() const;
virtual std::vector<EndpointIPtr> getEndpoints() const;
@@ -286,6 +296,7 @@ public:
virtual LocatorInfoPtr getLocatorInfo() const { return _locatorInfo; }
+ virtual Type getType() const;
virtual int getLocatorCacheTimeout() const;
virtual std::string getAdapterId() const;
virtual std::vector<EndpointIPtr> getEndpoints() const;