diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/CollocatedRequestHandler.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/CollocatedRequestHandler.h | 6 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.cpp | 73 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionFactory.h | 9 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.cpp | 185 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionI.h | 4 | ||||
-rw-r--r-- | cpp/src/Ice/ConnectionRequestHandler.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/EndpointI.h | 8 | ||||
-rw-r--r-- | cpp/src/Ice/EventHandler.h | 7 | ||||
-rw-r--r-- | cpp/src/Ice/IPEndpointI.cpp | 31 | ||||
-rw-r--r-- | cpp/src/Ice/IPEndpointI.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/OpaqueEndpointI.cpp | 24 | ||||
-rw-r--r-- | cpp/src/Ice/OpaqueEndpointI.h | 2 | ||||
-rw-r--r-- | cpp/src/Ice/ResponseHandler.h | 7 | ||||
-rw-r--r-- | cpp/src/Ice/RetryQueue.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/TcpEndpointI.cpp | 33 | ||||
-rw-r--r-- | cpp/src/Ice/UdpEndpointI.cpp | 27 | ||||
-rw-r--r-- | cpp/src/Ice/VirtualShared.h | 31 | ||||
-rw-r--r-- | cpp/src/Ice/WSEndpoint.cpp | 33 | ||||
-rw-r--r-- | cpp/src/Ice/WSEndpoint.h | 2 | ||||
-rw-r--r-- | cpp/src/IceSSL/EndpointI.cpp | 36 |
21 files changed, 92 insertions, 442 deletions
diff --git a/cpp/src/Ice/CollocatedRequestHandler.cpp b/cpp/src/Ice/CollocatedRequestHandler.cpp index 20349210b21..87a3d09c0f2 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.cpp +++ b/cpp/src/Ice/CollocatedRequestHandler.cpp @@ -126,11 +126,7 @@ CollocatedRequestHandler::~CollocatedRequestHandler() RequestHandlerPtr CollocatedRequestHandler::update(const RequestHandlerPtr& previousHandler, const RequestHandlerPtr& newHandler) { -#ifdef ICE_CPP11_MAPPING - return previousHandler.get() == this ? newHandler : dynamic_pointer_cast<RequestHandler>(shared_from_this()); -#else - return previousHandler.get() == this ? newHandler : this; -#endif + return previousHandler.get() == this ? newHandler : shared_from_this(); } bool @@ -277,11 +273,7 @@ CollocatedRequestHandler::invokeAsyncRequest(OutgoingAsyncBase* outAsync, int ba // // This will throw if the request is canceled // -#ifdef ICE_CPP11_MAPPING - outAsync->cancelable(dynamic_pointer_cast<CollocatedRequestHandler>(shared_from_this())); -#else - outAsync->cancelable(this); -#endif + outAsync->cancelable(shared_from_this()); if(_response) { diff --git a/cpp/src/Ice/CollocatedRequestHandler.h b/cpp/src/Ice/CollocatedRequestHandler.h index f98407c0ef3..87b5cb37966 100644 --- a/cpp/src/Ice/CollocatedRequestHandler.h +++ b/cpp/src/Ice/CollocatedRequestHandler.h @@ -39,10 +39,8 @@ class OutgoingAsync; class CollocatedRequestHandler : public RequestHandler, public ResponseHandler, - private IceUtil::Monitor<IceUtil::Mutex> -#ifndef ICE_CPP11_MAPPING - , public virtual ::IceUtil::Shared -#endif + private IceUtil::Monitor<IceUtil::Mutex>, + public ICE_ENABLE_SHARED_FROM_THIS(CollocatedRequestHandler) { public: diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 6ce8b78d45e..43652e08478 100644 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -867,12 +867,7 @@ IceInternal::OutgoingConnectionFactory::ConnectCallback::connectionStartComplete } connection->activate(); -#ifdef ICE_CPP11_MAPPING - _factory->finishGetConnection(_connectors, *_iter, connection, - dynamic_pointer_cast<ConnectCallback>(shared_from_this())); -#else - _factory->finishGetConnection(_connectors, *_iter, connection, this); -#endif + _factory->finishGetConnection(_connectors, *_iter, connection, shared_from_this()); } void @@ -890,11 +885,7 @@ IceInternal::OutgoingConnectionFactory::ConnectCallback::connectionStartFailed(c _factory->handleConnectionException(ex, _hasMore || _iter != _connectors.end() - 1); if(dynamic_cast<const Ice::CommunicatorDestroyedException*>(&ex)) // No need to continue. { -#ifdef ICE_CPP11_MAPPING - _factory->finishGetConnection(_connectors, ex, dynamic_pointer_cast<ConnectCallback>(shared_from_this())); -#else - _factory->finishGetConnection(_connectors, ex, this); -#endif + _factory->finishGetConnection(_connectors, ex, shared_from_this()); } else if(++_iter != _connectors.end()) // Try the next connector. { @@ -902,11 +893,7 @@ IceInternal::OutgoingConnectionFactory::ConnectCallback::connectionStartFailed(c } else { -#ifdef ICE_CPP11_MAPPING - _factory->finishGetConnection(_connectors, ex, dynamic_pointer_cast<ConnectCallback>(shared_from_this())); -#else - _factory->finishGetConnection(_connectors, ex, this); -#endif + _factory->finishGetConnection(_connectors, ex, shared_from_this()); } } @@ -1008,14 +995,7 @@ IceInternal::OutgoingConnectionFactory::ConnectCallback::getConnection() // connection. // bool compress; -#ifdef ICE_CPP11_MAPPING - Ice::ConnectionIPtr connection = _factory->getConnection( - _connectors, - dynamic_pointer_cast<ConnectCallback>(shared_from_this()), - compress); -#else - Ice::ConnectionIPtr connection = _factory->getConnection(_connectors, this, compress); -#endif + Ice::ConnectionIPtr connection = _factory->getConnection(_connectors, shared_from_this(), compress); if(!connection) { // @@ -1122,11 +1102,7 @@ IceInternal::OutgoingConnectionFactory::ConnectCallback::removeConnectors(const void IceInternal::OutgoingConnectionFactory::ConnectCallback::removeFromPending() { -#ifdef ICE_CPP11_MAPPING - _factory->removeFromPending(dynamic_pointer_cast<ConnectCallback>(shared_from_this()), _connectors); -#else - _factory->removeFromPending(this, _connectors); -#endif + _factory->removeFromPending(shared_from_this(), _connectors); } bool @@ -1435,11 +1411,7 @@ IceInternal::IncomingConnectionFactory::message(ThreadPoolCurrent& current) } assert(connection); -#ifdef ICE_CPP11_MAPPING - connection->start(dynamic_pointer_cast<IncomingConnectionFactory>(shared_from_this())); -#else - connection->start(this); -#endif + connection->start(shared_from_this()); } void @@ -1693,12 +1665,7 @@ IceInternal::IncomingConnectionFactory::setState(State state) Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat); out << "accepting " << _endpoint->protocol() << " connections at " << _acceptor->toString(); } -#ifdef ICE_CPP11_MAPPING - _adapter->getThreadPool()->_register(dynamic_pointer_cast<EventHandler>(shared_from_this()), - SocketOperationRead); -#else - _adapter->getThreadPool()->_register(this, SocketOperationRead); -#endif + _adapter->getThreadPool()->_register(shared_from_this(), SocketOperationRead); } for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate)); break; @@ -1717,12 +1684,7 @@ IceInternal::IncomingConnectionFactory::setState(State state) Trace out(_instance->initializationData().logger, _instance->traceLevels()->networkCat); out << "holding " << _endpoint->protocol() << " connections at " << _acceptor->toString(); } -#ifdef ICE_CPP11_MAPPING - _adapter->getThreadPool()->unregister(dynamic_pointer_cast<EventHandler>(shared_from_this()), - SocketOperationRead); -#else - _adapter->getThreadPool()->unregister(this, SocketOperationRead); -#endif + _adapter->getThreadPool()->unregister(shared_from_this(), SocketOperationRead); } for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold)); break; @@ -1739,11 +1701,7 @@ IceInternal::IncomingConnectionFactory::setState(State state) // the finish() call. Not all selector implementations do support this // however. // -#ifdef ICE_CPP11_MAPPING - if(_adapter->getThreadPool()->finish(dynamic_pointer_cast<EventHandler>(shared_from_this()), true)) -#else - if(_adapter->getThreadPool()->finish(this, true)) -#endif + if(_adapter->getThreadPool()->finish(shared_from_this(), true)) { closeAcceptor(); } @@ -1789,19 +1747,10 @@ IceInternal::IncomingConnectionFactory::createAcceptor() out << "listening for " << _endpoint->protocol() << " connections\n" << _acceptor->toDetailedString(); } -#ifdef ICE_CPP11_MAPPING - _adapter->getThreadPool()->initialize(dynamic_pointer_cast<EventHandler>(shared_from_this())); -#else - _adapter->getThreadPool()->initialize(this); -#endif + _adapter->getThreadPool()->initialize(shared_from_this()); if(_state == StateActive) { -#ifdef ICE_CPP11_MAPPING - _adapter->getThreadPool()->_register(dynamic_pointer_cast<EventHandler>(shared_from_this()), - SocketOperationRead); -#else - _adapter->getThreadPool()->_register(this, SocketOperationRead); -#endif + _adapter->getThreadPool()->_register(shared_from_this(), SocketOperationRead); } } catch(const Ice::Exception&) diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h index 433d5dbafe2..2259a872d9d 100644 --- a/cpp/src/Ice/ConnectionFactory.h +++ b/cpp/src/Ice/ConnectionFactory.h @@ -88,10 +88,8 @@ private: }; class ConnectCallback : public Ice::ConnectionI::StartCallback, - public IceInternal::EndpointI_connectors -#ifdef ICE_CPP11_MAPPING - , public ::std::enable_shared_from_this<::IceInternal::OutgoingConnectionFactory::ConnectCallback> -#endif + public IceInternal::EndpointI_connectors, + public ICE_ENABLE_SHARED_FROM_THIS(IceInternal::OutgoingConnectionFactory::ConnectCallback) { public: @@ -171,7 +169,8 @@ private: class IncomingConnectionFactory : public EventHandler, public Ice::ConnectionI::StartCallback, - public IceUtil::Monitor<IceUtil::Mutex> + public IceUtil::Monitor<IceUtil::Mutex>, + public ICE_ENABLE_SHARED_FROM_THIS(IncomingConnectionFactory) { public: diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index f8b9475fd1b..d9c0050477c 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -355,12 +355,7 @@ Ice::ConnectionI::start(const StartCallbackPtr& callback) exception(ex); if(callback) { -#ifdef ICE_CPP11_MAPPING - callback->connectionStartFailed(dynamic_pointer_cast<ConnectionI>(shared_from_this()), - *_exception.get()); -#else - callback->connectionStartFailed(this, *_exception.get()); -#endif + callback->connectionStartFailed(shared_from_this(), *_exception.get()); return; } else @@ -372,11 +367,7 @@ Ice::ConnectionI::start(const StartCallbackPtr& callback) if(callback) { -#ifdef ICE_CPP11_MAPPING - callback->connectionStartCompleted(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - callback->connectionStartCompleted(this); -#endif + callback->connectionStartCompleted(shared_from_this()); } } @@ -736,11 +727,7 @@ Ice::ConnectionI::sendAsyncRequest(const OutgoingAsyncBasePtr& out, bool compres // Notify the request that it's cancelable with this connection. // This will throw if the request is canceled. // -#ifdef ICE_CPP11_MAPPING - out->cancelable(dynamic_pointer_cast<CancellationHandler>(shared_from_this())); -#else - out->cancelable(this); -#endif + out->cancelable(shared_from_this()); Int requestId = 0; if(response) { @@ -951,11 +938,7 @@ AsyncResultPtr Ice::ConnectionI::__begin_flushBatchRequests(const CallbackBasePtr& cb, const LocalObjectPtr& cookie) { ConnectionFlushBatchAsyncPtr result = new ConnectionFlushBatchAsync( -#ifdef ICE_CPP11_MAPPING - dynamic_pointer_cast<EventHandler>(shared_from_this()), -#else - this, -#endif + shared_from_this(), _communicator, _instance, __flushBatchRequests_name, @@ -1002,11 +985,7 @@ Ice::ConnectionI::setCallback(const ConnectionCallbackPtr& callback) const ConnectionIPtr _connection; const ConnectionCallbackPtr _callback; }; -#ifdef ICE_CPP11_MAPPING - _threadPool->dispatch(new CallbackWorkItem(dynamic_pointer_cast<ConnectionI>(shared_from_this()), callback)); -#else - _threadPool->dispatch(new CallbackWorkItem(this, callback)); -#endif + _threadPool->dispatch(new CallbackWorkItem(shared_from_this(), callback)); } } else @@ -1021,11 +1000,7 @@ Ice::ConnectionI::closeCallback(const ConnectionCallbackPtr& callback) { try { -#ifdef ICE_CPP11_MAPPING - callback->closed(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - callback->closed(this); -#endif + callback->closed(shared_from_this()); } catch(const std::exception& ex) { @@ -1052,11 +1027,7 @@ Ice::ConnectionI::setACM(const IceUtil::Optional<int>& timeout, if(_state == StateActive) { -#ifdef ICE_CPP11_MAPPING - _monitor->remove(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - _monitor->remove(this); -#endif + _monitor->remove(shared_from_this()); } _monitor = _monitor->acm(timeout, close, heartbeat); @@ -1071,11 +1042,7 @@ Ice::ConnectionI::setACM(const IceUtil::Optional<int>& timeout, if(_state == StateActive) { -#ifdef ICE_CPP11_MAPPING - _monitor->add(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - _monitor->add(this); -#endif + _monitor->add(shared_from_this()); } } @@ -1453,13 +1420,8 @@ Ice::ConnectionI::createProxy(const Identity& ident) const // Create a reference and return a reverse proxy for this // reference. // - ConnectionIPtr self = -#ifdef ICE_CPP11_MAPPING - dynamic_pointer_cast<ConnectionI>(const_pointer_cast<VirtualShared>(shared_from_this())); -#else - const_cast<ConnectionI*>(this); -#endif - return _instance->proxyFactory()->referenceToProxy(_instance->referenceFactory()->create(ident, self)); + return _instance->proxyFactory()->referenceToProxy( + _instance->referenceFactory()->create(ident, shared_from_this())); } #if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT) @@ -1708,12 +1670,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current) // satisfied before continuing. // scheduleTimeout(newOp); -#ifdef ICE_CPP11_MAPPING - _threadPool->update(dynamic_pointer_cast<EventHandler>(shared_from_this()), - current.operation, newOp); -#else - _threadPool->update(this, current.operation, newOp); -#endif + _threadPool->update(shared_from_this(), current.operation, newOp); return; } @@ -1727,12 +1684,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current) return; } -#ifdef ICE_CPP11_MAPPING - _threadPool->unregister(dynamic_pointer_cast<EventHandler>(shared_from_this()), - current.operation); -#else - _threadPool->unregister(this, current.operation); -#endif + _threadPool->unregister(shared_from_this(), current.operation); // // We start out in holding state. @@ -1780,12 +1732,7 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current) if(_state < StateClosed) { scheduleTimeout(newOp); -#ifdef ICE_CPP11_MAPPING - _threadPool->update(dynamic_pointer_cast<EventHandler>(shared_from_this()), current.operation, - newOp); -#else - _threadPool->update(this, current.operation, newOp); -#endif + _threadPool->update(shared_from_this(), current.operation, newOp); } } @@ -1847,14 +1794,9 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current) } else { -#ifdef ICE_CPP11_MAPPING - _threadPool->dispatchFromThisThread(new DispatchCall(dynamic_pointer_cast<ConnectionI>(shared_from_this()), - startCB, sentCBs, compress, requestId, invokeNum, servantManager, adapter, outAsync, heartbeatCallback, - current.stream)); -#else - _threadPool->dispatchFromThisThread(new DispatchCall(this, startCB, sentCBs, compress, requestId, - invokeNum, servantManager, adapter, outAsync, heartbeatCallback, current.stream)); -#endif + _threadPool->dispatchFromThisThread(new DispatchCall(shared_from_this(), startCB, sentCBs, compress, requestId, + invokeNum, servantManager, adapter, outAsync, + heartbeatCallback, current.stream)); } } @@ -1873,12 +1815,7 @@ ConnectionI::dispatch(const StartCallbackPtr& startCB, const vector<OutgoingMess // if(startCB) { - -#ifdef ICE_CPP11_MAPPING - startCB->connectionStartCompleted(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - startCB->connectionStartCompleted(this); -#endif + startCB->connectionStartCompleted(shared_from_this()); ++dispatchedCount; } @@ -1923,11 +1860,7 @@ ConnectionI::dispatch(const StartCallbackPtr& startCB, const vector<OutgoingMess { try { -#ifdef ICE_CPP11_MAPPING - heartbeatCallback->heartbeat(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - heartbeatCallback->heartbeat(this); -#endif + heartbeatCallback->heartbeat(shared_from_this()); } catch(const std::exception& ex) { @@ -2019,12 +1952,7 @@ Ice::ConnectionI::finished(ThreadPoolCurrent& current, bool close) } else { -#ifdef ICE_CPP11_MAPPING - _threadPool->dispatchFromThisThread(new FinishCall( - dynamic_pointer_cast<ConnectionI>(shared_from_this()), close)); -#else - _threadPool->dispatchFromThisThread(new FinishCall(this, close)); -#endif + _threadPool->dispatchFromThisThread(new FinishCall(shared_from_this(), close)); } } @@ -2069,12 +1997,7 @@ Ice::ConnectionI::finish(bool close) if(_startCallback) { -#ifdef ICE_CPP11_MAPPING - _startCallback->connectionStartFailed( - dynamic_pointer_cast<ConnectionI>(shared_from_this()), *_exception.get()); -#else - _startCallback->connectionStartFailed(this, *_exception.get()); -#endif + _startCallback->connectionStartFailed(shared_from_this(), *_exception.get()); _startCallback = 0; } @@ -2454,12 +2377,7 @@ Ice::ConnectionI::setState(State state) { return; } -#ifdef ICE_CPP11_MAPPING - _threadPool->_register(dynamic_pointer_cast<EventHandler>(shared_from_this()), - SocketOperationRead); -#else - _threadPool->_register(this, SocketOperationRead); -#endif + _threadPool->_register(shared_from_this(), SocketOperationRead); break; } @@ -2475,12 +2393,7 @@ Ice::ConnectionI::setState(State state) } if(_state == StateActive) { -#ifdef ICE_CPP11_MAPPING - _threadPool->unregister(dynamic_pointer_cast<EventHandler>(shared_from_this()), - SocketOperationRead); -#else - _threadPool->unregister(this, SocketOperationRead); -#endif + _threadPool->unregister(shared_from_this(), SocketOperationRead); } break; } @@ -2511,11 +2424,7 @@ Ice::ConnectionI::setState(State state) // Don't need to close now for connections so only close the transceiver // if the selector request it. // -#ifdef ICE_CPP11_MAPPING - if(_threadPool->finish(dynamic_pointer_cast<EventHandler>(shared_from_this()), false)) -#else - if(_threadPool->finish(this, false)) -#endif + if(_threadPool->finish(shared_from_this(), false)) { _transceiver->close(); } @@ -2550,19 +2459,11 @@ Ice::ConnectionI::setState(State state) { _acmLastActivity = IceUtil::Time::now(IceUtil::Time::Monotonic); } -#ifdef ICE_CPP11_MAPPING - _monitor->add(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - _monitor->add(this); -#endif + _monitor->add(shared_from_this()); } else if(_state == StateActive) { -#ifdef ICE_CPP11_MAPPING - _monitor->remove(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - _monitor->remove(this); -#endif + _monitor->remove(shared_from_this()); } } @@ -2647,11 +2548,7 @@ Ice::ConnectionI::initiateShutdown() if(op) { scheduleTimeout(op); -#ifdef ICE_CPP11_MAPPING - _threadPool->_register(dynamic_pointer_cast<EventHandler>(shared_from_this()), op); -#else - _threadPool->_register(this, op); -#endif + _threadPool->_register(shared_from_this(), op); } } } @@ -2695,11 +2592,7 @@ Ice::ConnectionI::initialize(SocketOperation operation) if(s != SocketOperationNone) { scheduleTimeout(s); -#ifdef ICE_CPP11_MAPPING - _threadPool->update(dynamic_pointer_cast<EventHandler>(shared_from_this()), operation, s); -#else - _threadPool->update(this, operation, s); -#endif + _threadPool->update(shared_from_this(), operation, s); return false; } @@ -2745,11 +2638,7 @@ Ice::ConnectionI::validate(SocketOperation operation) if(op) { scheduleTimeout(op); -#ifdef ICE_CPP11_MAPPING - _threadPool->update(dynamic_pointer_cast<EventHandler>(shared_from_this()), operation, op); -#else - _threadPool->update(this, operation, op); -#endif + _threadPool->update(shared_from_this(), operation, op); return false; } } @@ -2778,11 +2667,7 @@ Ice::ConnectionI::validate(SocketOperation operation) if(op) { scheduleTimeout(op); -#ifdef ICE_CPP11_MAPPING - _threadPool->update(dynamic_pointer_cast<EventHandler>(shared_from_this()), operation, op); -#else - _threadPool->update(this, operation, op); -#endif + _threadPool->update(shared_from_this(), operation, op); return false; } } @@ -3160,11 +3045,7 @@ Ice::ConnectionI::sendMessage(OutgoingMessage& message) _writeStream.swap(*_sendStreams.back().stream); scheduleTimeout(op); -#ifdef ICE_CPP11_MAPPING - _threadPool->_register(dynamic_pointer_cast<EventHandler>(shared_from_this()), op); -#else - _threadPool->_register(this, op); -#endif + _threadPool->_register(shared_from_this(), op); return AsyncStatusQueued; } @@ -3779,11 +3660,7 @@ ConnectionI::reap() { if(_monitor) { -#ifdef ICE_CPP11_MAPPING - _monitor->reap(dynamic_pointer_cast<ConnectionI>(shared_from_this())); -#else - _monitor->reap(this); -#endif + _monitor->reap(shared_from_this()); } if(_observer) { diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 6e7227f6bdf..75ec43765a7 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -38,6 +38,7 @@ #include <Ice/ConnectionAsync.h> #include <Ice/BatchRequestQueueF.h> #include <Ice/ACM.h> +#include <Ice/VirtualShared.h> #include <deque> @@ -66,7 +67,8 @@ class ConnectionI : public Connection, public IceInternal::EventHandler, public IceInternal::ResponseHandler, public IceInternal::CancellationHandler, - public IceUtil::Monitor<IceUtil::Mutex> + public IceUtil::Monitor<IceUtil::Mutex>, + public ICE_ENABLE_SHARED_FROM_THIS(ConnectionI) { class Observer : public IceInternal::ObserverHelperT<Ice::Instrumentation::ConnectionObserver> { diff --git a/cpp/src/Ice/ConnectionRequestHandler.h b/cpp/src/Ice/ConnectionRequestHandler.h index 29f70063768..3cfd5954d11 100644 --- a/cpp/src/Ice/ConnectionRequestHandler.h +++ b/cpp/src/Ice/ConnectionRequestHandler.h @@ -13,6 +13,7 @@ #include <Ice/RequestHandler.h> #include <Ice/ReferenceF.h> #include <Ice/ProxyF.h> +#include <Ice/VirtualShared.h> namespace IceInternal { diff --git a/cpp/src/Ice/EndpointI.h b/cpp/src/Ice/EndpointI.h index 6000f706bdb..ced48f600e5 100644 --- a/cpp/src/Ice/EndpointI.h +++ b/cpp/src/Ice/EndpointI.h @@ -16,16 +16,14 @@ #include <Ice/TransceiverF.h> #include <Ice/ConnectorF.h> #include <Ice/AcceptorF.h> +#include <Ice/VirtualShared.h> namespace IceInternal { class BasicStream; -class ICE_API EndpointI_connectors -#ifndef ICE_CPP11_MAPPING - : public virtual IceUtil::Shared -#endif +class ICE_API EndpointI_connectors : public virtual ICE_SHARED { public: @@ -36,7 +34,7 @@ public: }; class ICE_API EndpointI : public Ice::Endpoint, - public ICE_ENABLE_SHARED_FROM_THIS(EndpointI) + public virtual ICE_SHARED { public: diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h index 47e4473ca1b..cb3f1f3299d 100644 --- a/cpp/src/Ice/EventHandler.h +++ b/cpp/src/Ice/EventHandler.h @@ -21,12 +21,7 @@ namespace IceInternal { -class ICE_API EventHandler : -#ifdef ICE_CPP11_MAPPING - virtual public VirtualShared -#else - virtual public ::Ice::LocalObject -#endif +class ICE_API EventHandler : virtual public ICE_LOCAL_OBJECT { public: diff --git a/cpp/src/Ice/IPEndpointI.cpp b/cpp/src/Ice/IPEndpointI.cpp index 74d274d8d77..cfbcb3bb111 100644 --- a/cpp/src/Ice/IPEndpointI.cpp +++ b/cpp/src/Ice/IPEndpointI.cpp @@ -80,13 +80,7 @@ IceInternal::IPEndpointInfoI::secure() const Ice::EndpointInfoPtr IceInternal::IPEndpointI::getInfo() const { - Ice::IPEndpointInfoPtr info -#ifdef ICE_CPP11_MAPPING - = make_shared<IPEndpointInfoI>( - dynamic_pointer_cast<IPEndpointI>(const_pointer_cast<EndpointI>(shared_from_this()))); -#else - = new IPEndpointInfoI(const_cast<IPEndpointI*>(this)); -#endif + Ice::IPEndpointInfoPtr info = ICE_MAKE_SHARED(IPEndpointInfoI, shared_from_this()); fillEndpointInfo(info.get()); return info; } @@ -129,12 +123,7 @@ IceInternal::IPEndpointI::connectionId(const string& connectionId) const { if(connectionId == _connectionId) { -#ifdef ICE_CPP11_MAPPING - return dynamic_pointer_cast<IPEndpointI>( - const_pointer_cast<EndpointI>(shared_from_this())); -#else - return const_cast<IPEndpointI*>(this); -#endif + return shared_from_this(); } else { @@ -157,13 +146,7 @@ IceInternal::IPEndpointI::port() const void IceInternal::IPEndpointI::connectors_async(Ice::EndpointSelectionType selType, const EndpointI_connectorsPtr& cb) const { - _instance->resolve(_host, _port, selType, -#ifdef ICE_CPP11_MAPPING - dynamic_pointer_cast<IPEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())), -#else - const_cast<IPEndpointI*>(this), -#endif - cb); + _instance->resolve(_host, _port, selType, shared_from_this(), cb); } vector<EndpointIPtr> @@ -173,13 +156,7 @@ IceInternal::IPEndpointI::expand() const vector<string> hosts = getHostsForEndpointExpand(_host, _instance->protocolSupport(), false); if(hosts.empty()) { - endps.push_back( -#ifdef ICE_CPP11_MAPPING - dynamic_pointer_cast<IPEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())) -#else - const_cast<IPEndpointI*>(this) -#endif - ); + endps.push_back(shared_from_this()); } else { diff --git a/cpp/src/Ice/IPEndpointI.h b/cpp/src/Ice/IPEndpointI.h index 396d25fdad8..422fb9803e2 100644 --- a/cpp/src/Ice/IPEndpointI.h +++ b/cpp/src/Ice/IPEndpointI.h @@ -43,7 +43,7 @@ private: const EndpointIPtr _endpoint; }; -class ICE_API IPEndpointI : public EndpointI +class ICE_API IPEndpointI : public EndpointI, public ICE_ENABLE_SHARED_FROM_THIS(IPEndpointI) { public: diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp index 6a15b5e920c..16296d0a093 100644 --- a/cpp/src/Ice/OpaqueEndpointI.cpp +++ b/cpp/src/Ice/OpaqueEndpointI.cpp @@ -131,11 +131,7 @@ IceInternal::OpaqueEndpointI::timeout() const EndpointIPtr IceInternal::OpaqueEndpointI::timeout(Int) const { -#ifdef ICE_CPP11_MAPPING - return dynamic_pointer_cast<OpaqueEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())); -#else - return const_cast<OpaqueEndpointI*>(this); -#endif + return shared_from_this(); } const string& @@ -147,11 +143,7 @@ IceInternal::OpaqueEndpointI::connectionId() const EndpointIPtr IceInternal::OpaqueEndpointI::connectionId(const string&) const { -#ifdef ICE_CPP11_MAPPING - return dynamic_pointer_cast<OpaqueEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())); -#else - return const_cast<OpaqueEndpointI*>(this); -#endif + return shared_from_this(); } bool @@ -163,11 +155,7 @@ IceInternal::OpaqueEndpointI::compress() const EndpointIPtr IceInternal::OpaqueEndpointI::compress(bool) const { -#ifdef ICE_CPP11_MAPPING - return dynamic_pointer_cast<OpaqueEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())); -#else - return const_cast<OpaqueEndpointI*>(this); -#endif + return shared_from_this(); } bool @@ -204,11 +192,7 @@ vector<EndpointIPtr> IceInternal::OpaqueEndpointI::expand() const { vector<EndpointIPtr> endps; -#ifdef ICE_CPP11_MAPPING - endps.push_back(dynamic_pointer_cast<OpaqueEndpointI>(const_pointer_cast<EndpointI>(shared_from_this()))); -#else - endps.push_back(const_cast<OpaqueEndpointI*>(this)); -#endif + endps.push_back(shared_from_this()); return endps; } diff --git a/cpp/src/Ice/OpaqueEndpointI.h b/cpp/src/Ice/OpaqueEndpointI.h index 4ea862d4c30..8ae35cf7ff7 100644 --- a/cpp/src/Ice/OpaqueEndpointI.h +++ b/cpp/src/Ice/OpaqueEndpointI.h @@ -16,7 +16,7 @@ namespace IceInternal { -class OpaqueEndpointI : public EndpointI +class OpaqueEndpointI : public EndpointI, public ICE_ENABLE_SHARED_FROM_THIS(OpaqueEndpointI) { public: diff --git a/cpp/src/Ice/ResponseHandler.h b/cpp/src/Ice/ResponseHandler.h index 0838953bc41..36b12b1d1fe 100644 --- a/cpp/src/Ice/ResponseHandler.h +++ b/cpp/src/Ice/ResponseHandler.h @@ -23,12 +23,7 @@ namespace IceInternal class BasicStream; -class ResponseHandler : -#ifdef ICE_CPP11_MAPPING - public virtual VirtualShared -#else - public virtual ::IceUtil::Shared -#endif +class ResponseHandler : public virtual ICE_SHARED { public: diff --git a/cpp/src/Ice/RetryQueue.h b/cpp/src/Ice/RetryQueue.h index 07e5e5ac39e..a7355c4f1b1 100644 --- a/cpp/src/Ice/RetryQueue.h +++ b/cpp/src/Ice/RetryQueue.h @@ -17,6 +17,7 @@ #include <Ice/OutgoingAsyncF.h> #include <Ice/InstanceF.h> #include <Ice/RequestHandler.h> // For CancellationHandler +#include <Ice/VirtualShared.h> namespace IceInternal { diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index b30edcb0be7..601092a024f 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -64,12 +64,8 @@ IceInternal::TcpEndpointI::TcpEndpointI(const ProtocolInstancePtr& instance, Bas EndpointInfoPtr IceInternal::TcpEndpointI::getInfo() const { -#ifdef ICE_CPP11_MAPPING - TCPEndpointInfoPtr info = make_shared<InfoI<Ice::TCPEndpointInfo>>( - dynamic_pointer_cast<TcpEndpointI>(const_pointer_cast<EndpointI>(shared_from_this()))); -#else - TCPEndpointInfoPtr info = new InfoI<Ice::TCPEndpointInfo>(const_cast<TcpEndpointI*>(this)); -#endif + TCPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::TCPEndpointInfo>, + ICE_DYNAMIC_CAST(TcpEndpointI, shared_from_this())); fillEndpointInfo(info.get()); return info; } @@ -77,12 +73,7 @@ IceInternal::TcpEndpointI::getInfo() const EndpointInfoPtr IceInternal::TcpEndpointI::getWSInfo(const string& resource) const { -#ifdef ICE_CPP11_MAPPING - WSEndpointInfoPtr info = make_shared<InfoI<Ice::WSEndpointInfo>>( - dynamic_pointer_cast<TcpEndpointI>(const_pointer_cast<EndpointI>(shared_from_this()))); -#else - WSEndpointInfoPtr info = new InfoI<Ice::WSEndpointInfo>(const_cast<TcpEndpointI*>(this)); -#endif + WSEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::WSEndpointInfo>, shared_from_this()); fillEndpointInfo(info.get()); info->resource = resource; return info; @@ -99,11 +90,7 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const { if(timeout == _timeout) { -#ifdef ICE_CPP11_MAPPING - return dynamic_pointer_cast<TcpEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())); -#else - return const_cast<TcpEndpointI*>(this); -#endif + return shared_from_this(); } else { @@ -122,11 +109,7 @@ IceInternal::TcpEndpointI::compress(bool compress) const { if(compress == _compress) { -#ifdef ICE_CPP11_MAPPING - return dynamic_pointer_cast<TcpEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())); -#else - return const_cast<TcpEndpointI*>(this); -#endif + return shared_from_this(); } else { @@ -149,11 +132,7 @@ IceInternal::TcpEndpointI::transceiver() const AcceptorPtr IceInternal::TcpEndpointI::acceptor(const string&) const { -#ifdef ICE_CPP11_MAPPING - return new TcpAcceptor(dynamic_pointer_cast<TcpEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())), _instance, _host, _port); -#else - return new TcpAcceptor(const_cast<TcpEndpointI*>(this), _instance, _host, _port); -#endif + return new TcpAcceptor(ICE_DYNAMIC_CAST(TcpEndpointI, shared_from_this()), _instance, _host, _port); } TcpEndpointIPtr diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index cffe27fb7ec..ef98a76deda 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -78,12 +78,8 @@ IceInternal::UdpEndpointI::UdpEndpointI(const ProtocolInstancePtr& instance, Bas EndpointInfoPtr IceInternal::UdpEndpointI::getInfo() const { -#ifdef ICE_CPP11_MAPPING - Ice::UDPEndpointInfoPtr info = make_shared<InfoI<Ice::UDPEndpointInfo>>( - dynamic_pointer_cast<UdpEndpointI>(const_pointer_cast<EndpointI>(shared_from_this()))); -#else - Ice::UDPEndpointInfoPtr info = new InfoI<Ice::UDPEndpointInfo>(const_cast<UdpEndpointI*>(this)); -#endif + Ice::UDPEndpointInfoPtr info = ICE_MAKE_SHARED(InfoI<Ice::UDPEndpointInfo>, + ICE_DYNAMIC_CAST(UdpEndpointI, shared_from_this())); fillEndpointInfo(info.get()); return info; } @@ -97,11 +93,7 @@ IceInternal::UdpEndpointI::timeout() const EndpointIPtr IceInternal::UdpEndpointI::timeout(Int) const { -#ifdef ICE_CPP11_MAPPING - return const_pointer_cast<EndpointI>(shared_from_this()); -#else - return const_cast<UdpEndpointI*>(this); -#endif + return shared_from_this(); } bool @@ -115,11 +107,7 @@ IceInternal::UdpEndpointI::compress(bool compress) const { if(compress == _compress) { -#ifdef ICE_CPP11_MAPPING - return const_pointer_cast<EndpointI>(shared_from_this()); -#else - return const_cast<UdpEndpointI*>(this); -#endif + return shared_from_this(); } else { @@ -137,12 +125,7 @@ IceInternal::UdpEndpointI::datagram() const TransceiverPtr IceInternal::UdpEndpointI::transceiver() const { -#ifdef ICE_CPP11_MAPPING - return new UdpTransceiver(dynamic_pointer_cast<UdpEndpointI>(const_pointer_cast<EndpointI>(shared_from_this())), - _instance, _host, _port, _mcastInterface, _connect); -#else - return new UdpTransceiver(const_cast<UdpEndpointI*>(this), _instance, _host, _port, _mcastInterface, _connect); -#endif + return new UdpTransceiver(ICE_DYNAMIC_CAST(UdpEndpointI, shared_from_this()), _instance, _host, _port, _mcastInterface, _connect); } AcceptorPtr diff --git a/cpp/src/Ice/VirtualShared.h b/cpp/src/Ice/VirtualShared.h deleted file mode 100644 index 4de4d0b17bc..00000000000 --- a/cpp/src/Ice/VirtualShared.h +++ /dev/null @@ -1,31 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#ifndef ICE_VIRTUAL_SHARED_H -#define ICE_VIRTUAL_SHARED_H - -#include <IceUtil/Config.h> - -#ifdef ICE_CPP11_MAPPING - -namespace IceInternal -{ - -class VirtualShared : public ::std::enable_shared_from_this<VirtualShared> -{ -public: - - virtual ~VirtualShared() = default; -}; - -} - -#endif - -#endif diff --git a/cpp/src/Ice/WSEndpoint.cpp b/cpp/src/Ice/WSEndpoint.cpp index c1f9c520b18..7c6bde550d8 100644 --- a/cpp/src/Ice/WSEndpoint.cpp +++ b/cpp/src/Ice/WSEndpoint.cpp @@ -94,11 +94,7 @@ IceInternal::WSEndpoint::timeout(Int timeout) const { if(timeout == _delegate->timeout()) { -#ifdef ICE_CPP11_MAPPING - return const_pointer_cast<EndpointI>(shared_from_this()); -#else - return const_cast<WSEndpoint*>(this); -#endif + return shared_from_this(); } else { @@ -117,11 +113,7 @@ IceInternal::WSEndpoint::connectionId(const string& connectionId) const { if(connectionId == _delegate->connectionId()) { -#ifdef ICE_CPP11_MAPPING - return const_pointer_cast<EndpointI>(shared_from_this()); -#else - return const_cast<WSEndpoint*>(this); -#endif + return shared_from_this(); } else { @@ -140,11 +132,7 @@ IceInternal::WSEndpoint::compress(bool compress) const { if(compress == _delegate->compress()) { -#ifdef ICE_CPP11_MAPPING - return const_pointer_cast<EndpointI>(shared_from_this()); -#else - return const_cast<WSEndpoint*>(this); -#endif + return shared_from_this(); } else { @@ -215,12 +203,7 @@ AcceptorPtr IceInternal::WSEndpoint::acceptor(const string& adapterName) const { AcceptorPtr delAcc = _delegate->acceptor(adapterName); -#ifdef ICE_CPP11_MAPPING - return new WSAcceptor(dynamic_pointer_cast<WSEndpoint>(const_pointer_cast<EndpointI>(shared_from_this())), - _instance, delAcc); -#else - return new WSAcceptor(const_cast<WSEndpoint*>(this), _instance, delAcc); -#endif + return new WSAcceptor(shared_from_this(), _instance, delAcc); } WSEndpointPtr @@ -235,13 +218,7 @@ IceInternal::WSEndpoint::expand() const vector<EndpointIPtr> endps = _delegate->expand(); for(vector<EndpointIPtr>::iterator p = endps.begin(); p != endps.end(); ++p) { -#ifdef ICE_CPP11_MAPPING - *p = p->get() == _delegate.get() ? - dynamic_pointer_cast<WSEndpoint>(const_pointer_cast<EndpointI>(shared_from_this())) : - make_shared<WSEndpoint>(_instance, *p, _resource); -#else - *p = p->get() == _delegate.get() ? const_cast<WSEndpoint*>(this) : new WSEndpoint(_instance, *p, _resource); -#endif + *p = p->get() == _delegate.get() ? shared_from_this() : ICE_MAKE_SHARED(WSEndpoint, _instance, *p, _resource); } return endps; } diff --git a/cpp/src/Ice/WSEndpoint.h b/cpp/src/Ice/WSEndpoint.h index a5f4a89d09a..99d97a7a5b5 100644 --- a/cpp/src/Ice/WSEndpoint.h +++ b/cpp/src/Ice/WSEndpoint.h @@ -31,7 +31,7 @@ public: virtual Ice::EndpointInfoPtr getWSInfo(const std::string&) const = 0; }; -class WSEndpoint : public EndpointI +class WSEndpoint : public EndpointI, public ICE_ENABLE_SHARED_FROM_THIS(WSEndpoint) { public: diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index 88e258f868b..183dd1ec3b3 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -55,13 +55,7 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, IceInternal::BasicStre Ice::EndpointInfoPtr IceSSL::EndpointI::getInfo() const { -#ifdef ICE_CPP11_MAPPING - EndpointInfoPtr info = make_shared<IceInternal::InfoI<EndpointInfo>>( - dynamic_pointer_cast<IceInternal::EndpointI>( - const_pointer_cast<IceInternal::EndpointI>(shared_from_this()))); -#else - EndpointInfoPtr info = new IceInternal::InfoI<EndpointInfo>(const_cast<EndpointI*>(this)); -#endif + EndpointInfoPtr info = ICE_MAKE_SHARED(IceInternal::InfoI<EndpointInfo>, shared_from_this()); fillEndpointInfo(info.get()); return info; } @@ -69,13 +63,7 @@ IceSSL::EndpointI::getInfo() const Ice::EndpointInfoPtr IceSSL::EndpointI::getWSInfo(const string& resource) const { -#ifdef ICE_CPP11_MAPPING - WSEndpointInfoPtr info = make_shared<IceInternal::InfoI<Ice::WSEndpointInfo>>( - dynamic_pointer_cast<IceInternal::EndpointI>( - const_pointer_cast<IceInternal::EndpointI>(shared_from_this()))); -#else - WSSEndpointInfoPtr info = new IceInternal::InfoI<WSSEndpointInfo>(const_cast<EndpointI*>(this)); -#endif + WSSEndpointInfoPtr info = ICE_MAKE_SHARED(IceInternal::InfoI<WSSEndpointInfo>, shared_from_this()); fillEndpointInfo(info.get()); info->resource = resource; return info; @@ -92,11 +80,7 @@ IceSSL::EndpointI::timeout(Int timeout) const { if(timeout == _timeout) { -#ifdef ICE_CPP11_MAPPING - return dynamic_pointer_cast<IceInternal::EndpointI>(const_pointer_cast<IceInternal::EndpointI>(shared_from_this())); -#else - return const_cast<EndpointI*>(this); -#endif + return shared_from_this(); } else { @@ -115,11 +99,7 @@ IceSSL::EndpointI::compress(bool compress) const { if(compress == _compress) { -#ifdef ICE_CPP11_MAPPING - return dynamic_pointer_cast<IceInternal::EndpointI>(const_pointer_cast<IceInternal::EndpointI>(shared_from_this())); -#else - return const_cast<EndpointI*>(this); -#endif + return shared_from_this(); } else { @@ -142,13 +122,7 @@ IceSSL::EndpointI::transceiver() const IceInternal::AcceptorPtr IceSSL::EndpointI::acceptor(const string& adapterName) const { -#ifdef ICE_CPP11_MAPPING - return new AcceptorI( - dynamic_pointer_cast<EndpointI>(const_pointer_cast<IceInternal::EndpointI>(shared_from_this())), - _instance, adapterName, _host, _port); -#else - return new AcceptorI(const_cast<EndpointI*>(this), _instance, adapterName, _host, _port); -#endif + return new AcceptorI(ICE_DYNAMIC_CAST(IceSSL::EndpointI, shared_from_this()), _instance, adapterName, _host, _port); } EndpointIPtr |