diff --git a/cpp/include/Ice/Connection.h b/cpp/include/Ice/Connection.h index 4e5a089eaab..3586397a3da 100644 --- a/cpp/include/Ice/Connection.h +++ b/cpp/include/Ice/Connection.h @@ -270,7 +270,7 @@ class ICE_CLASS(ICE_API) Connection * @return A proxy that matches the given identity and uses this connection. * @see #setAdapter */ - virtual std::optional createProxy(const Identity& id) const = 0; + virtual ObjectPrx createProxy(const Identity& id) const = 0; /** * Explicitly set an object adapter that dispatches requests that are received over this connection. A client can diff --git a/cpp/include/Ice/ObjectAdapter.h b/cpp/include/Ice/ObjectAdapter.h index 0088e7ab026..da7aa56a063 100644 --- a/cpp/include/Ice/ObjectAdapter.h +++ b/cpp/include/Ice/ObjectAdapter.h @@ -359,7 +359,7 @@ class ICE_CLASS(ICE_API) ObjectAdapter * @return A proxy for the object with the given identity. * @see Identity */ - virtual std::optional createProxy(const Identity& id) const = 0; + virtual ObjectPrx createProxy(const Identity& id) const = 0; /** * Create a direct proxy for the object with the given identity. The returned proxy contains this object adapter's @@ -368,7 +368,7 @@ class ICE_CLASS(ICE_API) ObjectAdapter * @return A proxy for the object with the given identity. * @see Identity */ - virtual std::optional createDirectProxy(const Identity& id) const = 0; + virtual ObjectPrx createDirectProxy(const Identity& id) const = 0; /** * Create an indirect proxy for the object with the given identity. If this object adapter is configured with an @@ -378,7 +378,7 @@ class ICE_CLASS(ICE_API) ObjectAdapter * @return A proxy for the object with the given identity. * @see Identity */ - virtual std::optional createIndirectProxy(const Identity& id) const = 0; + virtual ObjectPrx createIndirectProxy(const Identity& id) const = 0; /** * Set an Ice locator for this object adapter. By doing so, the object adapter will register itself with the diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp index 03891fe672a..59f29f66291 100644 --- a/cpp/src/Glacier2/Blobject.cpp +++ b/cpp/src/Glacier2/Blobject.cpp @@ -66,7 +66,7 @@ Glacier2::Blobject::updateObserver(const shared_ptr& inParams, function&)> response, function exception, diff --git a/cpp/src/Glacier2/Blobject.h b/cpp/src/Glacier2/Blobject.h index bd2bc1ae2f1..2c0133f2695 100644 --- a/cpp/src/Glacier2/Blobject.h +++ b/cpp/src/Glacier2/Blobject.h @@ -26,7 +26,7 @@ class Blobject : public Ice::BlobjectArrayAsync, public std::enable_shared_from_ protected: - void invoke(Ice::ObjectPrxPtr&, + void invoke(Ice::ObjectPrx&, const std::pair&, std::function&)>, std::function, diff --git a/cpp/src/Glacier2/ClientBlobject.cpp b/cpp/src/Glacier2/ClientBlobject.cpp index f47c4641134..f08f01cfed0 100644 --- a/cpp/src/Glacier2/ClientBlobject.cpp +++ b/cpp/src/Glacier2/ClientBlobject.cpp @@ -113,7 +113,7 @@ Glacier2::ClientBlobject::ice_invokeAsync(pair inParam throw ObjectNotExistException(__FILE__, __LINE__, current.id, "", ""); } - invoke(proxy, inParams, std::move(response), std::move(error), current); + invoke(proxy.value(), inParams, std::move(response), std::move(error), current); } shared_ptr diff --git a/cpp/src/Glacier2/ServerBlobject.cpp b/cpp/src/Glacier2/ServerBlobject.cpp index 30195dfcaa3..26cd1609c92 100644 --- a/cpp/src/Glacier2/ServerBlobject.cpp +++ b/cpp/src/Glacier2/ServerBlobject.cpp @@ -20,7 +20,5 @@ Glacier2::ServerBlobject::ice_invokeAsync(pair inParam const Current& current) { auto proxy = _reverseConnection->createProxy(current.id); - assert(proxy); - invoke(proxy, inParams, std::move(response), std::move(error), current); } diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index e62e1e8d409..db067d73300 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -1280,7 +1280,7 @@ Ice::ConnectionI::getEndpoint() const noexcept return _endpoint; // No mutex protection necessary, _endpoint is immutable. } -optional +ObjectPrx Ice::ConnectionI::createProxy(const Identity& ident) const { checkIdentity(ident, __FILE__, __LINE__); diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 20418e71a7c..d78080ee2c9 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -181,7 +181,7 @@ class ConnectionI : public Connection, virtual void setAdapter(const ObjectAdapterPtr&); // From Connection. virtual ObjectAdapterPtr getAdapter() const noexcept; // From Connection. virtual EndpointPtr getEndpoint() const noexcept; // From Connection. - virtual std::optional createProxy(const Identity& ident) const; // From Connection. + virtual ObjectPrx createProxy(const Identity& ident) const; // From Connection. void setAdapterAndServantManager(const ObjectAdapterPtr&, const IceInternal::ServantManagerPtr&); diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 6421c135f99..99a9946a25e 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -608,7 +608,7 @@ IceInternal::Instance::createAdmin(const ObjectAdapterPtr& adminAdapter, const I } } setServerProcessProxy(adapter, adminIdentity); - return adapter->createProxy(adminIdentity).value(); + return adapter->createProxy(adminIdentity); } std::optional @@ -702,7 +702,7 @@ IceInternal::Instance::addAllAdminFacets() void IceInternal::Instance::setServerProcessProxy(const ObjectAdapterPtr& adminAdapter, const Identity& adminIdentity) { - ObjectPrx admin = adminAdapter->createProxy(adminIdentity).value(); + ObjectPrx admin = adminAdapter->createProxy(adminIdentity); optional locator = adminAdapter->getLocator(); const string serverId = _initData.properties->getProperty("Ice.Admin.ServerId"); if(locator && serverId != "") diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index fba7c835032..3238c610138 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -379,7 +379,7 @@ Ice::ObjectAdapterI::addFacet(const shared_ptr& object, const Identity& _servantManager->addServant(object, ident, facet); - return newProxy(ident, facet).value(); + return newProxy(ident, facet); } ObjectPrx @@ -524,7 +524,7 @@ Ice::ObjectAdapterI::findServantLocator(const string& prefix) const return _servantManager->findServantLocator(prefix); } -optional +ObjectPrx Ice::ObjectAdapterI::createProxy(const Identity& ident) const { lock_guard lock(_mutex); @@ -535,7 +535,7 @@ Ice::ObjectAdapterI::createProxy(const Identity& ident) const return newProxy(ident, ""); } -optional +ObjectPrx Ice::ObjectAdapterI::createDirectProxy(const Identity& ident) const { lock_guard lock(_mutex); @@ -546,7 +546,7 @@ Ice::ObjectAdapterI::createDirectProxy(const Identity& ident) const return newDirectProxy(ident, ""); } -optional +ObjectPrx Ice::ObjectAdapterI::createIndirectProxy(const Identity& ident) const { lock_guard lock(_mutex); @@ -1069,7 +1069,7 @@ Ice::ObjectAdapterI::~ObjectAdapterI() } } -std::optional +ObjectPrx Ice::ObjectAdapterI::newProxy(const Identity& ident, const string& facet) const { if(_id.empty()) @@ -1086,43 +1086,20 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident, const string& facet) const } } -std::optional +ObjectPrx Ice::ObjectAdapterI::newDirectProxy(const Identity& ident, const string& facet) const { - // - // Create a reference and return a proxy for this reference. - // - ReferencePtr ref = _instance->referenceFactory()->create(ident, facet, _reference, _publishedEndpoints); - - if (ref) - { - return ObjectPrx::_fromReference(std::move(ref)); - } - else - { - return std::nullopt; - } + return ObjectPrx::_fromReference( + _instance->referenceFactory()->create(ident, facet, _reference, _publishedEndpoints)); } -std::optional +ObjectPrx Ice::ObjectAdapterI::newIndirectProxy(const Identity& ident, const string& facet, const string& id) const { // // Create an indirect reference with the given adapter id. // - ReferencePtr ref = _instance->referenceFactory()->create(ident, facet, _reference, id); - - // - // Return a proxy for the reference. - // - if (ref) - { - return ObjectPrx::_fromReference(std::move(ref)); - } - else - { - return std::nullopt; - } + return ObjectPrx::_fromReference(_instance->referenceFactory()->create(ident, facet, _reference, id)); } void diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index b6a700b1b80..8b9600935d8 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -64,9 +64,9 @@ class ObjectAdapterI final : public ObjectAdapter, public std::enable_shared_fro std::shared_ptr removeServantLocator(const std::string&) final; std::shared_ptr findServantLocator(const std::string&) const final; - std::optional createProxy(const Identity&) const final; - std::optional createDirectProxy(const Identity&) const final; - std::optional createIndirectProxy(const Identity&) const final; + ObjectPrx createProxy(const Identity&) const final; + ObjectPrx createDirectProxy(const Identity&) const final; + ObjectPrx createIndirectProxy(const Identity&) const final; void setLocator(const std::optional&) final; std::optional getLocator() const noexcept; @@ -105,9 +105,9 @@ class ObjectAdapterI final : public ObjectAdapter, public std::enable_shared_fro void initialize(std::optional); friend class IceInternal::ObjectAdapterFactory; - std::optional newProxy(const Identity&, const std::string&) const; - std::optional newDirectProxy(const Identity&, const std::string&) const; - std::optional newIndirectProxy(const Identity&, const std::string&, const std::string&) const; + ObjectPrx newProxy(const Identity&, const std::string&) const; + ObjectPrx newDirectProxy(const Identity&, const std::string&) const; + ObjectPrx newIndirectProxy(const Identity&, const std::string&, const std::string&) const; void checkForDeactivation() const; std::vector parseEndpoints(const std::string&, bool) const; std::vector computePublishedEndpoints(); diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp index 4a13c8eeff8..6e109cb23b2 100644 --- a/cpp/src/Ice/ReferenceFactory.cpp +++ b/cpp/src/Ice/ReferenceFactory.cpp @@ -32,10 +32,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const ReferencePtr& tmpl, const vector& endpoints) { - if(ident.name.empty() && ident.category.empty()) - { - return 0; - } + assert(!ident.name.empty()); return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(), endpoints, "", ""); @@ -47,10 +44,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, const ReferencePtr& tmpl, const string& adapterId) { - if(ident.name.empty() && ident.category.empty()) - { - return 0; - } + assert(!ident.name.empty()); return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(), vector(), adapterId, ""); @@ -59,10 +53,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, ReferencePtr IceInternal::ReferenceFactory::create(const Identity& ident, const Ice::ConnectionIPtr& connection) { - if(ident.name.empty() && ident.category.empty()) - { - return 0; - } + assert(!ident.name.empty()); // // Create new reference diff --git a/cpp/src/IceGrid/WellKnownObjectsManager.cpp b/cpp/src/IceGrid/WellKnownObjectsManager.cpp index 5c7565c71ab..1cff77fb5ee 100644 --- a/cpp/src/IceGrid/WellKnownObjectsManager.cpp +++ b/cpp/src/IceGrid/WellKnownObjectsManager.cpp @@ -16,7 +16,7 @@ WellKnownObjectsManager::WellKnownObjectsManager(const shared_ptr& dat } void -WellKnownObjectsManager::add(const Ice::ObjectPrxPtr& proxy, const string& type) +WellKnownObjectsManager::add(const Ice::ObjectPrx& proxy, const string& type) { assert(!_initialized); ObjectInfo info = { proxy, type }; @@ -24,7 +24,7 @@ WellKnownObjectsManager::add(const Ice::ObjectPrxPtr& proxy, const string& type) } void -WellKnownObjectsManager::addEndpoint(const string& name, const Ice::ObjectPrxPtr& proxy) +WellKnownObjectsManager::addEndpoint(const string& name, const Ice::ObjectPrx& proxy) { _endpoints.insert(make_pair(name, proxy)); } diff --git a/cpp/src/IceGrid/WellKnownObjectsManager.h b/cpp/src/IceGrid/WellKnownObjectsManager.h index f1c12259012..8ee97b0f16f 100644 --- a/cpp/src/IceGrid/WellKnownObjectsManager.h +++ b/cpp/src/IceGrid/WellKnownObjectsManager.h @@ -19,8 +19,8 @@ class WellKnownObjectsManager WellKnownObjectsManager(const std::shared_ptr&); - void add(const Ice::ObjectPrxPtr&, const std::string&); - void addEndpoint(const std::string&, const Ice::ObjectPrxPtr&); + void add(const Ice::ObjectPrx&, const std::string&); + void addEndpoint(const std::string&, const Ice::ObjectPrx&); void finish(); void registerAll(); diff --git a/cpp/test/Ice/echo/BlobjectI.cpp b/cpp/test/Ice/echo/BlobjectI.cpp index 68d32d06768..eb6848b743f 100644 --- a/cpp/test/Ice/echo/BlobjectI.cpp +++ b/cpp/test/Ice/echo/BlobjectI.cpp @@ -53,7 +53,7 @@ BlobjectI::ice_invokeAsync(std::vector inEncaps, } if(_batchProxy) { - obj = _batchProxy; + obj = _batchProxy.value(); } if(!current.facet.empty()) diff --git a/swift/src/IceImpl/Connection.mm b/swift/src/IceImpl/Connection.mm index e558f52cd31..64cc661a0f5 100644 --- a/swift/src/IceImpl/Connection.mm +++ b/swift/src/IceImpl/Connection.mm @@ -25,15 +25,8 @@ -(nullable ICEObjectPrx*) createProxy:(NSString*)name category:(NSString*)catego { try { - auto cppPrx = self.connection->createProxy(Ice::Identity{fromNSString(name), fromNSString(category)}); - if (cppPrx) - { - return [[ICEObjectPrx alloc] initWithCppObjectPrx:cppPrx.value()]; - } - else - { - return nil; - } + auto prx = self.connection->createProxy(Ice::Identity{fromNSString(name), fromNSString(category)}); + return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx]; } catch(const std::exception& ex) { diff --git a/swift/src/IceImpl/ObjectAdapter.mm b/swift/src/IceImpl/ObjectAdapter.mm index bff999c2c0d..b2bd5427a05 100644 --- a/swift/src/IceImpl/ObjectAdapter.mm +++ b/swift/src/IceImpl/ObjectAdapter.mm @@ -99,14 +99,7 @@ -(nullable ICEObjectPrx*) createProxy:(NSString*)name category:(NSString*)catego try { auto prx = self.objectAdapter->createProxy(Ice::Identity{fromNSString(name), fromNSString(category)}); - if (prx) - { - return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx.value()]; - } - else - { - return nil; - } + return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx]; } catch(const std::exception& ex) { @@ -120,14 +113,7 @@ -(nullable ICEObjectPrx*) createDirectProxy:(NSString*)name category:(NSString*) try { auto prx = self.objectAdapter->createDirectProxy(Ice::Identity{fromNSString(name), fromNSString(category)}); - if (prx) - { - return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx.value()]; - } - else - { - return nil; - } + return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx]; } catch(const std::exception& ex) { @@ -141,14 +127,7 @@ -(nullable ICEObjectPrx*) createIndirectProxy:(NSString*)name category:(NSString try { auto prx = self.objectAdapter->createIndirectProxy(Ice::Identity{fromNSString(name), fromNSString(category)}); - if (prx) - { - return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx.value()]; - } - else - { - return nil; - } + return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx]; } catch(const std::exception& ex) {