diff options
Diffstat (limited to 'cpp/include')
54 files changed, 1657 insertions, 399 deletions
diff --git a/cpp/include/Ice/ACMF.h b/cpp/include/Ice/ACMF.h index f4d9d581a36..9f2bebfd358 100644 --- a/cpp/include/Ice/ACMF.h +++ b/cpp/include/Ice/ACMF.h @@ -18,12 +18,18 @@ namespace IceInternal { class ACMMonitor; +class FactoryACMMonitor; + +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<ACMMonitor> ACMMonitorPtr; +typedef ::std::shared_ptr<FactoryACMMonitor> FactoryACMMonitorPtr; +#else ICE_API IceUtil::Shared* upCast(ACMMonitor*); typedef IceInternal::Handle<ACMMonitor> ACMMonitorPtr; -class FactoryACMMonitor; ICE_API IceUtil::Shared* upCast(FactoryACMMonitor*); typedef IceInternal::Handle<FactoryACMMonitor> FactoryACMMonitorPtr; +#endif } diff --git a/cpp/include/Ice/AsyncResult.h b/cpp/include/Ice/AsyncResult.h index 71272445250..a777be04c7b 100644 --- a/cpp/include/Ice/AsyncResult.h +++ b/cpp/include/Ice/AsyncResult.h @@ -23,7 +23,7 @@ #include <Ice/ObserverHelper.h> #include <Ice/BasicStream.h> -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER # include <functional> // for std::function #endif @@ -31,16 +31,30 @@ namespace IceInternal { class CallbackBase; -typedef IceUtil::Handle<CallbackBase> CallbackBasePtr; +ICE_DEFINE_PTR(CallbackBasePtr, CallbackBase); } namespace Ice { -class ICE_API AsyncResult : public Ice::LocalObject, private IceUtil::noncopyable +class ICE_API AsyncResult : private IceUtil::noncopyable, +#ifdef ICE_CPP11_MAPPING + public ::std::enable_shared_from_this<::Ice::AsyncResult> +#else + public Ice::LocalObject +#endif { public: + +#ifdef ICE_CPP11_MAPPING + AsyncResult(const CommunicatorPtr&, const IceInternal::InstancePtr&, const std::string&, + const IceInternal::CallbackBasePtr&); +#else + AsyncResult(const CommunicatorPtr&, const IceInternal::InstancePtr&, const std::string&, + const IceInternal::CallbackBasePtr&, const LocalObjectPtr&); +#endif + virtual ~AsyncResult(); // Must be heap-allocated void cancel(); @@ -48,7 +62,7 @@ public: CommunicatorPtr getCommunicator() const; virtual ConnectionPtr getConnection() const; - virtual ObjectPrx getProxy() const; + virtual ObjectPrxPtr getProxy() const; bool isCompleted() const; void waitForCompleted(); @@ -59,7 +73,11 @@ public: void throwLocalException() const; bool sentSynchronously() const; + +#ifndef ICE_CPP11_MAPPING LocalObjectPtr getCookie() const; +#endif + const std::string& getOperation() const; ::IceInternal::BasicStream* __startReadParams() @@ -91,10 +109,6 @@ protected: static void __check(const AsyncResultPtr&, const ::std::string&); - AsyncResult(const CommunicatorPtr&, const IceInternal::InstancePtr&, const std::string&, - const IceInternal::CallbackBasePtr&, const LocalObjectPtr&); - virtual ~AsyncResult(); // Must be heap-allocated - bool sent(bool); bool finished(bool); bool finished(const Exception&); @@ -157,14 +171,16 @@ namespace IceInternal // // Base class for all callbacks. // -class ICE_API CallbackBase : public IceUtil::Shared +class ICE_API CallbackBase : public ICE_ENABLE_SHARED_FROM_THIS(CallbackBase) { public: void checkCallback(bool, bool); virtual void completed(const ::Ice::AsyncResultPtr&) const = 0; +#ifndef ICE_CPP11_MAPPING virtual CallbackBasePtr verify(const ::Ice::LocalObjectPtr&) = 0; +#endif virtual void sent(const ::Ice::AsyncResultPtr&) const = 0; virtual bool hasSentCallback() const = 0; }; @@ -231,7 +247,7 @@ private: Callback _sent; }; -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER template<typename T> struct callback_type { @@ -334,6 +350,7 @@ public: namespace Ice { +#ifndef ICE_CPP11_MAPPING typedef IceUtil::Handle< ::IceInternal::GenericCallbackBase> CallbackPtr; template<class T> CallbackPtr @@ -352,17 +369,18 @@ newCallback(T* instance, return new ::IceInternal::AsyncCallback<T>(instance, cb, sentcb); } -#ifdef ICE_CPP11 +# ifdef ICE_CPP11_COMPILER ICE_API CallbackPtr newCallback(const ::IceInternal::Function<void (const AsyncResultPtr&)>&, const ::IceInternal::Function<void (const AsyncResultPtr&)>& = ::IceInternal::Function<void (const AsyncResultPtr&)>()); +# endif #endif +} // // Operation callbacks are specified in Proxy.h // -} #endif diff --git a/cpp/include/Ice/AsyncResultF.h b/cpp/include/Ice/AsyncResultF.h index 1ca4d3d7469..023954fff9a 100644 --- a/cpp/include/Ice/AsyncResultF.h +++ b/cpp/include/Ice/AsyncResultF.h @@ -18,8 +18,13 @@ namespace Ice { class AsyncResult; + +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<AsyncResult> AsyncResultPtr; +#else ICE_API IceUtil::Shared* upCast(::Ice::AsyncResult*); typedef IceInternal::Handle<AsyncResult> AsyncResultPtr; +#endif } diff --git a/cpp/include/Ice/BasicStream.h b/cpp/include/Ice/BasicStream.h index 33406d3ac49..6fc8e06d90b 100644 --- a/cpp/include/Ice/BasicStream.h +++ b/cpp/include/Ice/BasicStream.h @@ -13,8 +13,9 @@ #include <IceUtil/StringConverter.h> #include <Ice/InstanceF.h> #include <Ice/Object.h> +#include <Ice/ValueF.h> #include <Ice/ProxyF.h> -#include <Ice/ObjectFactoryF.h> +#include <Ice/ObjectFactory.h> #include <Ice/ObjectFactoryManagerF.h> #include <Ice/Buffer.h> #include <Ice/Protocol.h> @@ -22,6 +23,7 @@ #include <Ice/UserExceptionFactory.h> #include <Ice/StreamHelpers.h> #include <Ice/FactoryTable.h> +#include <Ice/Traits.h> namespace Ice { @@ -34,10 +36,19 @@ namespace IceInternal { template<typename T> inline void -patchHandle(void* addr, const Ice::ObjectPtr& v) +patchHandle(void* addr, const Ice::ValuePtr& v) { +#ifdef ICE_CPP11_MAPPING + ::std::shared_ptr<T>* handle = static_cast<::std::shared_ptr<T>*>(addr); + *handle = ::std::dynamic_pointer_cast<T>(v); + if(v && !handle) + { + IceInternal::Ex::throwUOE(T::ice_staticId(), v); + } +#else IceInternal::Handle<T>* p = static_cast<IceInternal::Handle<T>*>(addr); __patch(*p, v); // Generated __patch method, necessary for forward declarations. +#endif } class ICE_API BasicStream : public Buffer @@ -45,7 +56,7 @@ class ICE_API BasicStream : public Buffer public: typedef size_t size_type; - typedef void (*PatchFunc)(void*, const Ice::ObjectPtr&); + typedef void (*PatchFunc)(void*, const Ice::ValuePtr&); BasicStream(Instance*, const Ice::EncodingVersion&); BasicStream(Instance*, const Ice::EncodingVersion&, const Ice::Byte*, const Ice::Byte*); @@ -626,7 +637,13 @@ public: void read(std::pair<const Ice::Int*, const Ice::Int*>&, ::IceUtil::ScopedArray<Ice::Int>&); // Long + +#ifdef ICE_CPP11_MAPPING + void write(long long int); +#else void write(Ice::Long); +#endif + void write(const Ice::Long*, const Ice::Long*); void read(Ice::Long&); void read(std::vector<Ice::Long>&); @@ -780,6 +797,32 @@ public: void read(std::vector<std::wstring>&); // Proxy +#ifdef ICE_CPP11_MAPPING + void writeProxy(const Ice::ObjectPrxPtr&); + + template<typename T, typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, T>::value>::type* = nullptr> + void write(const ::std::shared_ptr<T>& v) + { + writeProxy(::std::static_pointer_cast<::Ice::ObjectPrx>(v)); + } + + ::Ice::ObjectPrxPtr readProxy(); + + template<typename T, typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, T>::value>::type* = nullptr> + void read(::std::shared_ptr<T>& v) + { + ::std::shared_ptr<::Ice::ObjectPrx> proxy(readProxy()); + if(!proxy) + { + v = 0; + } + else + { + v = ::std::make_shared<T>(); + v->__copyFrom(proxy); + } + } +#else void write(const Ice::ObjectPrx&); template<typename T> void write(const IceInternal::ProxyHandle<T>& v) { @@ -790,8 +833,23 @@ public: { __read(this, v); // Generated __read method, necessary for forward declarations. } +#endif // Class +#ifdef ICE_CPP11_MAPPING // C++11 mapping + template<typename T, typename ::std::enable_if<::std::is_base_of<::Ice::Value, T>::value>::type* = nullptr> + void write(const ::std::shared_ptr<T>& v) + { + initWriteEncaps(); + _currentWriteEncaps->encoder->write(v); + } + + template<typename T, typename ::std::enable_if<::std::is_base_of<::Ice::Value, T>::value>::type* = nullptr> + void read(::std::shared_ptr<T>& v) + { + read(&patchHandle<T>, &v); + } +#else // C++98 mapping void write(const Ice::ObjectPtr& v) { initWriteEncaps(); @@ -801,15 +859,18 @@ public: { write(Ice::ObjectPtr(upCast(v.get()))); } + + template<typename T> void read(IceInternal::Handle<T>& v) + { + read(&patchHandle<T>, &v); + } +#endif + void read(PatchFunc patchFunc, void* patchAddr) { initReadEncaps(); _currentReadEncaps->decoder->read(patchFunc, patchAddr); } - template<typename T> void read(IceInternal::Handle<T>& v) - { - read(&patchHandle<T>, &v); - } // Enum Ice::Int readEnum(Ice::Int); @@ -888,7 +949,7 @@ private: class WriteEncaps; enum SliceType { NoSlice, ObjectSlice, ExceptionSlice }; - typedef std::vector<Ice::ObjectPtr> ObjectList; + typedef std::vector<Ice::ValuePtr> ObjectList; class ICE_API EncapsDecoder : private ::IceUtil::noncopyable { @@ -922,12 +983,12 @@ private: } std::string readTypeId(bool); - Ice::ObjectPtr newInstance(const std::string&); + Ice::ValuePtr newInstance(const std::string&); void addPatchEntry(Ice::Int, PatchFunc, void*); - void unmarshal(Ice::Int, const Ice::ObjectPtr&); + void unmarshal(Ice::Int, const Ice::ValuePtr&); - typedef std::map<Ice::Int, Ice::ObjectPtr> IndexToPtrMap; + typedef std::map<Ice::Int, Ice::ValuePtr> IndexToPtrMap; typedef std::map<Ice::Int, std::string> TypeIdReadMap; struct PatchEntry @@ -1084,7 +1145,7 @@ private: virtual ~EncapsEncoder() { } - virtual void write(const Ice::ObjectPtr&) = 0; + virtual void write(const Ice::ValuePtr&) = 0; virtual void write(const Ice::UserException&) = 0; virtual void startInstance(SliceType, const Ice::SlicedDataPtr&) = 0; @@ -1112,7 +1173,7 @@ private: BasicStream* _stream; WriteEncaps* _encaps; - typedef std::map<Ice::ObjectPtr, Ice::Int> PtrToIndexMap; + typedef std::map<Ice::ValuePtr, Ice::Int> PtrToIndexMap; typedef std::map<std::string, Ice::Int> TypeIdWriteMap; // Encapsulation attributes for object marshalling. @@ -1134,7 +1195,7 @@ private: { } - virtual void write(const Ice::ObjectPtr&); + virtual void write(const Ice::ValuePtr&); virtual void write(const Ice::UserException&); virtual void startInstance(SliceType, const Ice::SlicedDataPtr&); @@ -1146,7 +1207,7 @@ private: private: - Ice::Int registerObject(const Ice::ObjectPtr&); + Ice::Int registerObject(const Ice::ValuePtr&); // Instance attributes SliceType _sliceType; @@ -1168,7 +1229,7 @@ private: { } - virtual void write(const Ice::ObjectPtr&); + virtual void write(const Ice::ValuePtr&); virtual void write(const Ice::UserException&); virtual void startInstance(SliceType, const Ice::SlicedDataPtr&); @@ -1181,7 +1242,7 @@ private: private: void writeSlicedData(const Ice::SlicedDataPtr&); - void writeInstance(const Ice::ObjectPtr&); + void writeInstance(const Ice::ValuePtr&); struct InstanceData { diff --git a/cpp/include/Ice/BatchRequestInterceptor.h b/cpp/include/Ice/BatchRequestInterceptor.h index b8d1c417a63..2c7c4877974 100644 --- a/cpp/include/Ice/BatchRequestInterceptor.h +++ b/cpp/include/Ice/BatchRequestInterceptor.h @@ -13,7 +13,7 @@ #include <IceUtil/Shared.h> #include <Ice/ProxyF.h> -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER # include <functional> #endif @@ -31,18 +31,18 @@ public: virtual void enqueue() const = 0; virtual int getSize() const = 0; virtual const std::string& getOperation() const = 0; - virtual const Ice::ObjectPrx& getProxy() const = 0; + virtual const Ice::ObjectPrxPtr& getProxy() const = 0; }; -class BatchRequestInterceptor : public IceUtil::Shared +class BatchRequestInterceptor : public ICE_ENABLE_SHARED_FROM_THIS(BatchRequestInterceptor) { public: virtual void enqueue(const BatchRequest&, int, int) = 0; }; -typedef IceUtil::Handle<BatchRequestInterceptor> BatchRequestInterceptorPtr; +ICE_DEFINE_PTR(BatchRequestInterceptorPtr, BatchRequestInterceptor); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ICE_API BatchRequestInterceptorPtr newBatchRequestInterceptor(const ::std::function<void (const BatchRequest&, int, int)>&); #endif diff --git a/cpp/include/Ice/CommunicatorAsync.h b/cpp/include/Ice/CommunicatorAsync.h index 68ebc4919d9..3644fdbc121 100644 --- a/cpp/include/Ice/CommunicatorAsync.h +++ b/cpp/include/Ice/CommunicatorAsync.h @@ -12,6 +12,7 @@ #include <Ice/Communicator.h> +#ifndef ICE_CPP11_MAPPING namespace Ice { @@ -111,5 +112,6 @@ newCallback_Communicator_flushBatchRequests(T* instance, void (T::*excb)(const : } } +#endif #endif diff --git a/cpp/include/Ice/Comparable.h b/cpp/include/Ice/Comparable.h new file mode 100644 index 00000000000..7becd593401 --- /dev/null +++ b/cpp/include/Ice/Comparable.h @@ -0,0 +1,63 @@ +// ********************************************************************** +// +// 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_COMPARABLE_H +#define ICE_COMPARABLE_H + +namespace Ice +{ + +template<typename T, typename U> +inline bool targetEquals(const T& lhs, const U& rhs) +{ + if(lhs && rhs) + { + return *lhs == *rhs; + } + else + { + return !lhs && !rhs; + } +} + +template<typename T> +struct TargetEquals +{ + bool operator()(const T& lhs, const T& rhs) const + { + return targetEquals(lhs, rhs); + } +}; + + +template<typename T, typename U> +inline bool targetLess(const T& lhs, const U& rhs) +{ + if(lhs && rhs) + { + return *lhs < *rhs; + } + else + { + return !lhs && rhs; + } +} + +template<typename T> +struct TargetLess +{ + bool operator()(const T& lhs, const T& rhs) const + { + return targetLess(lhs, rhs); + } +}; + +} + +#endif diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h index 8dbfb467c06..df86c77b149 100644 --- a/cpp/include/Ice/Config.h +++ b/cpp/include/Ice/Config.h @@ -81,7 +81,11 @@ namespace Ice typedef unsigned char Byte; typedef short Short; typedef int Int; +#ifdef ICE_CPP11_MAPPING +typedef long long int Long; +#else typedef IceUtil::Int64 Long; +#endif typedef float Float; typedef double Double; diff --git a/cpp/include/Ice/ConnectionAsync.h b/cpp/include/Ice/ConnectionAsync.h index 8f5ff18003b..6845bc5a6a2 100644 --- a/cpp/include/Ice/ConnectionAsync.h +++ b/cpp/include/Ice/ConnectionAsync.h @@ -16,6 +16,7 @@ namespace Ice { +#ifndef ICE_CPP11_MAPPING template<class T> class CallbackNC_Connection_flushBatchRequests : public Callback_Connection_flushBatchRequests_Base, public ::IceInternal::OnewayCallbackNC<T> @@ -109,6 +110,7 @@ newCallback_Connection_flushBatchRequests(T* instance, void (T::*excb)(const ::I { return new Callback_Connection_flushBatchRequests<T, CT>(instance, excb, sentcb); } +#endif } diff --git a/cpp/include/Ice/ConnectionFactoryF.h b/cpp/include/Ice/ConnectionFactoryF.h index 453ed0d9304..5e6cce64592 100644 --- a/cpp/include/Ice/ConnectionFactoryF.h +++ b/cpp/include/Ice/ConnectionFactoryF.h @@ -22,8 +22,13 @@ ICE_API IceUtil::Shared* upCast(OutgoingConnectionFactory*); typedef IceInternal::Handle<OutgoingConnectionFactory> OutgoingConnectionFactoryPtr; class IncomingConnectionFactory; + +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<IncomingConnectionFactory> IncomingConnectionFactoryPtr; +#else ICE_API IceUtil::Shared* upCast(IncomingConnectionFactory*); typedef IceInternal::Handle<IncomingConnectionFactory> IncomingConnectionFactoryPtr; +#endif } diff --git a/cpp/include/Ice/ConnectionIF.h b/cpp/include/Ice/ConnectionIF.h index 967fb0c7f5a..bd5dbfc154f 100644 --- a/cpp/include/Ice/ConnectionIF.h +++ b/cpp/include/Ice/ConnectionIF.h @@ -17,8 +17,12 @@ namespace Ice { class ConnectionI; +#ifdef ICE_CPP11_MAPPING // C++11 mapping +typedef ::std::shared_ptr<ConnectionI> ConnectionIPtr; +#else // C++98 mapping ICE_API Ice::LocalObject* upCast(Ice::ConnectionI*); typedef IceInternal::Handle<ConnectionI> ConnectionIPtr; +#endif } diff --git a/cpp/include/Ice/DefaultObjectFactory.h b/cpp/include/Ice/DefaultObjectFactory.h index 2eb1879898a..1ec2a01a7af 100644 --- a/cpp/include/Ice/DefaultObjectFactory.h +++ b/cpp/include/Ice/DefaultObjectFactory.h @@ -13,6 +13,7 @@ #include <Ice/Config.h> #include <Ice/ObjectFactory.h> +#ifndef ICE_CPP11_MAPPING namespace IceInternal { template<class O> @@ -44,5 +45,6 @@ private: }; } +#endif #endif diff --git a/cpp/include/Ice/Dispatcher.h b/cpp/include/Ice/Dispatcher.h index eeb76610e38..841df0147b8 100644 --- a/cpp/include/Ice/Dispatcher.h +++ b/cpp/include/Ice/Dispatcher.h @@ -14,7 +14,7 @@ #include <IceUtil/Shared.h> #include <IceUtil/Handle.h> #include <Ice/ConnectionF.h> -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER # include <functional> #endif @@ -41,7 +41,7 @@ public: typedef IceUtil::Handle<Dispatcher> DispatcherPtr; -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ICE_API DispatcherPtr newDispatcher(const ::std::function<void (const DispatcherCallPtr&, const ConnectionPtr)>&); #endif diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h index 09cf13ccfd5..31a967075ae 100644 --- a/cpp/include/Ice/Exception.h +++ b/cpp/include/Ice/Exception.h @@ -15,6 +15,7 @@ #include <Ice/Format.h> #include <Ice/Handle.h> #include <Ice/ObjectF.h> +#include <Ice/ValueF.h> #include <Ice/StreamF.h> namespace IceInternal @@ -25,7 +26,7 @@ class BasicStream; namespace Ex { -ICE_API void throwUOE(const ::std::string&, const ::Ice::ObjectPtr&); +ICE_API void throwUOE(const ::std::string&, const ::Ice::ValuePtr&); ICE_API void throwMemoryLimitException(const char*, int, size_t, size_t); ICE_API void throwMarshalException(const char*, int, const std::string&); diff --git a/cpp/include/Ice/FactoryTable.h b/cpp/include/Ice/FactoryTable.h index e1f8d1641f0..24b5243733f 100644 --- a/cpp/include/Ice/FactoryTable.h +++ b/cpp/include/Ice/FactoryTable.h @@ -12,7 +12,7 @@ #include <IceUtil/Mutex.h> #include <Ice/UserExceptionFactory.h> -#include <Ice/ObjectFactoryF.h> +#include <Ice/ObjectFactory.h> namespace Ice @@ -39,8 +39,12 @@ public: IceInternal::UserExceptionFactoryPtr getExceptionFactory(const ::std::string&) const; void removeExceptionFactory(const ::std::string&); - void addObjectFactory(const ::std::string&, const Ice::ObjectFactoryPtr&); - Ice::ObjectFactoryPtr getObjectFactory(const ::std::string&) const; +#ifdef ICE_CPP11_MAPPING + void addObjectFactory(const ::std::string&, ::std::function<::Ice::ValuePtr (const ::std::string&)>); +#else + void addObjectFactory(const ::std::string&, const ::Ice::ObjectFactoryPtr&); +#endif + ICE_OBJECT_FACTORY getObjectFactory(const ::std::string&) const; void removeObjectFactory(const ::std::string&); void addTypeId(int, const ::std::string&); @@ -55,7 +59,7 @@ private: typedef ::std::map< ::std::string, EFPair> EFTable; EFTable _eft; - typedef ::std::pair<Ice::ObjectFactoryPtr, int> OFPair; + typedef ::std::pair<ICE_OBJECT_FACTORY, int> OFPair; typedef ::std::map< ::std::string, OFPair> OFTable; OFTable _oft; diff --git a/cpp/include/Ice/FactoryTableInit.h b/cpp/include/Ice/FactoryTableInit.h index 5d74985ea85..86287412375 100644 --- a/cpp/include/Ice/FactoryTableInit.h +++ b/cpp/include/Ice/FactoryTableInit.h @@ -69,7 +69,15 @@ public: DefaultObjectFactoryInit(const char* typeId) : _typeId(typeId) { +#ifdef ICE_CPP11_MAPPING + factoryTable->addObjectFactory(_typeId, + [](const std::string&) + { + return ::std::make_shared<O>(); + }); +#else factoryTable->addObjectFactory(_typeId, new DefaultObjectFactory<O>(_typeId)); +#endif } ~DefaultObjectFactoryInit() diff --git a/cpp/include/Ice/Functional.h b/cpp/include/Ice/Functional.h index 14e80302ef1..7265855f5b3 100644 --- a/cpp/include/Ice/Functional.h +++ b/cpp/include/Ice/Functional.h @@ -22,115 +22,115 @@ namespace Ice { template<class R, class T> -inline ::IceUtilInternal::MemFun<R, T, ::IceInternal::Handle<T> > +inline ::IceUtilInternal::MemFun<R, T, ICE_INTERNAL_HANDLE<T> > memFun(R (T::*p)(void)) { - return ::IceUtilInternal::MemFun<R, T, ::IceInternal::Handle<T> >(p); + return ::IceUtilInternal::MemFun<R, T, ICE_INTERNAL_HANDLE<T> >(p); } template<class R, class T, class A> -inline ::IceUtilInternal::MemFun1<R, T, ::IceInternal::Handle<T>, A> +inline ::IceUtilInternal::MemFun1<R, T, ICE_INTERNAL_HANDLE<T>, A> memFun1(R (T::*p)(A)) { - return ::IceUtilInternal::MemFun1<R, T, ::IceInternal::Handle<T>, A>(p); + return ::IceUtilInternal::MemFun1<R, T, ICE_INTERNAL_HANDLE<T>, A>(p); } template<class T> -inline ::IceUtilInternal::VoidMemFun<T, ::IceInternal::Handle<T> > +inline ::IceUtilInternal::VoidMemFun<T, ICE_INTERNAL_HANDLE<T> > voidMemFun(void (T::*p)(void)) { - return ::IceUtilInternal::VoidMemFun<T, ::IceInternal::Handle<T> >(p); + return ::IceUtilInternal::VoidMemFun<T, ICE_INTERNAL_HANDLE<T> >(p); } template<class T, class A> -inline ::IceUtilInternal::VoidMemFun1<T, ::IceInternal::Handle<T>, A> +inline ::IceUtilInternal::VoidMemFun1<T, ICE_INTERNAL_HANDLE<T>, A> voidMemFun1(void (T::*p)(A)) { - return ::IceUtilInternal::VoidMemFun1<T, ::IceInternal::Handle<T>, A>(p); + return ::IceUtilInternal::VoidMemFun1<T, ICE_INTERNAL_HANDLE<T>, A>(p); } template<class R, class K, class T> -inline ::IceUtilInternal::SecondMemFun<R, K, T, ::IceInternal::Handle<T> > +inline ::IceUtilInternal::SecondMemFun<R, K, T, ICE_INTERNAL_HANDLE<T> > secondMemFun(R (T::*p)(void)) { - return ::IceUtilInternal::SecondMemFun<R, K, T, ::IceInternal::Handle<T> >(p); + return ::IceUtilInternal::SecondMemFun<R, K, T, ICE_INTERNAL_HANDLE<T> >(p); } template<class R, class K, class T, class A> -inline ::IceUtilInternal::SecondMemFun1<R, K, T, ::IceInternal::Handle<T>, A> +inline ::IceUtilInternal::SecondMemFun1<R, K, T, ICE_INTERNAL_HANDLE<T>, A> secondMemFun1(R (T::*p)(A)) { - return ::IceUtilInternal::SecondMemFun1<R, K, T, ::IceInternal::Handle<T>, A>(p); + return ::IceUtilInternal::SecondMemFun1<R, K, T, ICE_INTERNAL_HANDLE<T>, A>(p); } template<class K, class T> -inline ::IceUtilInternal::SecondVoidMemFun<K, T, ::IceInternal::Handle<T> > +inline ::IceUtilInternal::SecondVoidMemFun<K, T, ICE_INTERNAL_HANDLE<T> > secondVoidMemFun(void (T::*p)(void)) { - return ::IceUtilInternal::SecondVoidMemFun<K, T, ::IceInternal::Handle<T> >(p); + return ::IceUtilInternal::SecondVoidMemFun<K, T, ICE_INTERNAL_HANDLE<T> >(p); } template<class K, class T, class A> -inline ::IceUtilInternal::SecondVoidMemFun1<K, T, ::IceInternal::Handle<T>, A> +inline ::IceUtilInternal::SecondVoidMemFun1<K, T, ICE_INTERNAL_HANDLE<T>, A> secondVoidMemFun1(void (T::*p)(A)) { - return ::IceUtilInternal::SecondVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>(p); + return ::IceUtilInternal::SecondVoidMemFun1<K, T, ICE_INTERNAL_HANDLE<T>, A>(p); } template<class R, class T> -inline ::IceUtilInternal::ConstMemFun<R, T, ::IceInternal::Handle<T> > +inline ::IceUtilInternal::ConstMemFun<R, T, ICE_INTERNAL_HANDLE<T> > constMemFun(R (T::*p)(void) const) { - return ::IceUtilInternal::ConstMemFun<R, T, ::IceInternal::Handle<T> >(p); + return ::IceUtilInternal::ConstMemFun<R, T, ICE_INTERNAL_HANDLE<T> >(p); } template<class R, class T, class A> -inline ::IceUtilInternal::ConstMemFun1<R, T, ::IceInternal::Handle<T>, A> +inline ::IceUtilInternal::ConstMemFun1<R, T, ICE_INTERNAL_HANDLE<T>, A> constMemFun1(R (T::*p)(A) const) { - return ::IceUtilInternal::ConstMemFun1<R, T, ::IceInternal::Handle<T>, A>(p); + return ::IceUtilInternal::ConstMemFun1<R, T, ICE_INTERNAL_HANDLE<T>, A>(p); } template<class T> -inline ::IceUtilInternal::ConstVoidMemFun<T, ::IceInternal::Handle<T> > +inline ::IceUtilInternal::ConstVoidMemFun<T, ICE_INTERNAL_HANDLE<T> > constVoidMemFun(void (T::*p)(void) const) { - return ::IceUtilInternal::ConstVoidMemFun<T, ::IceInternal::Handle<T> >(p); + return ::IceUtilInternal::ConstVoidMemFun<T, ICE_INTERNAL_HANDLE<T> >(p); } template<class T, class A> -inline ::IceUtilInternal::ConstVoidMemFun1<T, ::IceInternal::Handle<T>, A> +inline ::IceUtilInternal::ConstVoidMemFun1<T, ICE_INTERNAL_HANDLE<T>, A> constVoidMemFun1(void (T::*p)(A) const) { - return ::IceUtilInternal::ConstVoidMemFun1<T, ::IceInternal::Handle<T>, A>(p); + return ::IceUtilInternal::ConstVoidMemFun1<T, ICE_INTERNAL_HANDLE<T>, A>(p); } template<class R, class K, class T> -inline ::IceUtilInternal::SecondConstMemFun<R, K, T, ::IceInternal::Handle<T> > +inline ::IceUtilInternal::SecondConstMemFun<R, K, T, ICE_INTERNAL_HANDLE<T> > secondConstMemFun(R (T::*p)(void) const) { - return ::IceUtilInternal::SecondConstMemFun<R, K, T, ::IceInternal::Handle<T> >(p); + return ::IceUtilInternal::SecondConstMemFun<R, K, T, ICE_INTERNAL_HANDLE<T> >(p); } template<class R, class K, class T, class A> -inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, ::IceInternal::Handle<T>, A> +inline ::IceUtilInternal::SecondConstMemFun1<R, K, T, ICE_INTERNAL_HANDLE<T>, A> secondConstMemFun1(R (T::*p)(A) const) { - return ::IceUtilInternal::SecondConstMemFun1<R, K, T, ::IceInternal::Handle<T>, A>(p); + return ::IceUtilInternal::SecondConstMemFun1<R, K, T, ICE_INTERNAL_HANDLE<T>, A>(p); } template<class K, class T> -inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, ::IceInternal::Handle<T> > +inline ::IceUtilInternal::SecondConstVoidMemFun<K, T, ICE_INTERNAL_HANDLE<T> > secondConstVoidMemFun(void (T::*p)(void) const) { - return ::IceUtilInternal::SecondConstVoidMemFun<K, T, ::IceInternal::Handle<T> >(p); + return ::IceUtilInternal::SecondConstVoidMemFun<K, T, ICE_INTERNAL_HANDLE<T> >(p); } template<class K, class T, class A> -inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ::IceInternal::Handle<T>, A> +inline ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ICE_INTERNAL_HANDLE<T>, A> secondConstVoidMemFun1(void (T::*p)(A) const) { - return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ::IceInternal::Handle<T>, A>(p); + return ::IceUtilInternal::SecondConstVoidMemFun1<K, T, ICE_INTERNAL_HANDLE<T>, A>(p); } } diff --git a/cpp/include/Ice/GCObject.h b/cpp/include/Ice/GCObject.h index ec92f86465c..990dee9a475 100644 --- a/cpp/include/Ice/GCObject.h +++ b/cpp/include/Ice/GCObject.h @@ -15,6 +15,8 @@ #include <IceUtil/MutexPtrLock.h> #include <IceUtil/Mutex.h> +#ifndef ICE_CPP11_MAPPING + namespace IceInternal { @@ -75,3 +77,5 @@ private: } #endif + +#endif diff --git a/cpp/include/Ice/Ice.h b/cpp/include/Ice/Ice.h index 2f1850f3790..fd9375d26b1 100644 --- a/cpp/include/Ice/Ice.h +++ b/cpp/include/Ice/Ice.h @@ -12,6 +12,7 @@ #include <IceUtil/PushDisableWarnings.h> #include <Ice/Config.h> +#include <Ice/Comparable.h> #include <Ice/DeprecatedStringConverter.h> #include <Ice/Initialize.h> #include <Ice/LocalException.h> @@ -51,6 +52,7 @@ # include <Ice/Service.h> #endif #include <Ice/RegisterPlugins.h> +#include <Ice/InterfaceByValue.h> #include <IceUtil/PopDisableWarnings.h> #endif diff --git a/cpp/include/Ice/Incoming.h b/cpp/include/Ice/Incoming.h index 43628e2e800..b0b26542c83 100644 --- a/cpp/include/Ice/Incoming.h +++ b/cpp/include/Ice/Incoming.h @@ -55,7 +55,11 @@ protected: Ice::Current _current; Ice::ObjectPtr _servant; Ice::ServantLocatorPtr _locator; +#ifdef ICE_CPP11_MAPPING + ::std::shared_ptr<void> _cookie; +#else Ice::LocalObjectPtr _cookie; +#endif DispatchObserver _observer; bool _response; Ice::Byte _compress; diff --git a/cpp/include/Ice/IncomingAsync.h b/cpp/include/Ice/IncomingAsync.h index 18fccc41008..6a097698db0 100644 --- a/cpp/include/Ice/IncomingAsync.h +++ b/cpp/include/Ice/IncomingAsync.h @@ -13,6 +13,7 @@ #include <Ice/IncomingAsyncF.h> #include <Ice/Incoming.h> +#ifndef ICE_CPP11_MAPPING namespace Ice { @@ -25,6 +26,7 @@ public: }; } +#endif namespace IceInternal { @@ -33,7 +35,12 @@ namespace IceInternal // We need virtual inheritance from AMDCallback, because we use multiple // inheritance from Ice::AMDCallback for generated AMD code. // -class ICE_API IncomingAsync : public IncomingBase, virtual public Ice::AMDCallback +class ICE_API IncomingAsync : public IncomingBase, +#ifdef ICE_CPP11_MAPPING + public ::std::enable_shared_from_this<IncomingAsync> +#else + public virtual Ice::AMDCallback +#endif { public: @@ -44,8 +51,6 @@ public: virtual void ice_exception(const ::std::exception&); virtual void ice_exception(); -protected: - void __response(); void __exception(const std::exception&); void __exception(); @@ -72,6 +77,7 @@ private: } +#ifndef ICE_CPP11_MAPPING namespace Ice { @@ -104,5 +110,6 @@ public: } } +#endif #endif diff --git a/cpp/include/Ice/IncomingAsyncF.h b/cpp/include/Ice/IncomingAsyncF.h index f20b4b8121e..c315e584ebc 100644 --- a/cpp/include/Ice/IncomingAsyncF.h +++ b/cpp/include/Ice/IncomingAsyncF.h @@ -14,6 +14,13 @@ #include <Ice/Handle.h> +#ifdef ICE_CPP11_MAPPING +namespace IceInternal +{ +class IncomingAsync; +typedef std::shared_ptr<IncomingAsync> IncomingAsyncPtr; +}; +#else namespace IceInternal { @@ -31,5 +38,6 @@ ICE_API IceUtil::Shared* upCast(::Ice::AMD_Object_ice_invoke*); typedef IceInternal::Handle<AMD_Object_ice_invoke> AMD_Object_ice_invokePtr; } +#endif #endif diff --git a/cpp/include/Ice/InstanceF.h b/cpp/include/Ice/InstanceF.h index 43d73db5c31..66018616914 100644 --- a/cpp/include/Ice/InstanceF.h +++ b/cpp/include/Ice/InstanceF.h @@ -20,7 +20,6 @@ namespace IceInternal class Instance; ICE_API IceUtil::Shared* upCast(Instance*); typedef IceInternal::Handle<Instance> InstancePtr; - } #endif diff --git a/cpp/include/Ice/InterfaceByValue.h b/cpp/include/Ice/InterfaceByValue.h new file mode 100644 index 00000000000..b0ba02def8f --- /dev/null +++ b/cpp/include/Ice/InterfaceByValue.h @@ -0,0 +1,56 @@ +// ********************************************************************** +// +// 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_INTERFACE_BY_VALUE_H +#define ICE_INTERFACE_BY_VALUE_H + +#include <Ice/Value.h> +#include <Ice/BasicStream.h> + +#ifdef ICE_CPP11_MAPPING + +namespace Ice +{ + +template<typename T> +class InterfaceByValue : public Value +{ +public: + + virtual void + __writeImpl(::IceInternal::BasicStream* __os) const + { + __os->startWriteSlice(InterfaceTraits<T>::staticId, InterfaceTraits<T>::compactId, true); + __os->endWriteSlice(); + } + + virtual void + __readImpl(::IceInternal::BasicStream* __is) + { + __is->startReadSlice(); + __is->endReadSlice(); + } + + virtual const std::string& + ice_id() const + { + return InterfaceTraits<T>::staticId; + } + + static const std::string& + ice_staticId() + { + return InterfaceTraits<T>::staticId; + } +}; + +} +#endif + +#endif diff --git a/cpp/include/Ice/LoggerUtil.h b/cpp/include/Ice/LoggerUtil.h index 51ac31a1413..ee23b674690 100644 --- a/cpp/include/Ice/LoggerUtil.h +++ b/cpp/include/Ice/LoggerUtil.h @@ -23,7 +23,7 @@ class ICE_API LoggerOutputBase : private IceUtil::noncopyable public: std::string str() const; - + std::ostringstream& __str(); // For internal use only. Don't use in your code. private: @@ -68,12 +68,18 @@ template<typename T> inline LoggerOutputBase& operator<<(LoggerOutputBase& out, const T& val) { - return LoggerOutputInserter<T, IsException<T>::value>::insert(out, val); + return LoggerOutputInserter<T, IsException<T>::value>::insert(out, val); } +#ifdef ICE_CPP11_MAPPING +template<typename T, typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, T>::value>::type* = nullptr> +inline LoggerOutputBase& +operator<<(LoggerOutputBase& os, const ::std::shared_ptr<T>& p) +#else template<typename T> -inline LoggerOutputBase& +inline LoggerOutputBase& operator<<(LoggerOutputBase& os, const ::IceInternal::ProxyHandle<T>& p) +#endif { return os << (p ? p->ice_toString() : ""); } @@ -94,7 +100,7 @@ public: inline LoggerOutput(const LPtr& lptr) : _logger(lptr) {} - + inline ~LoggerOutput() { flush(); @@ -112,7 +118,7 @@ public: } private: - + LPtr _logger; }; @@ -126,9 +132,9 @@ public: Trace(const LoggerPtr&, const std::string&); ~Trace(); void flush(); - + private: - + LoggerPtr _logger; std::string _category; }; diff --git a/cpp/include/Ice/MetricsAdminI.h b/cpp/include/Ice/MetricsAdminI.h index d293201cde2..bd58a673435 100644 --- a/cpp/include/Ice/MetricsAdminI.h +++ b/cpp/include/Ice/MetricsAdminI.h @@ -17,7 +17,7 @@ #include <Ice/Metrics.h> #ifdef _MSC_VER -# define ICE_CPP11_REGEXP +# define ICE_CPP11_COMPILER_REGEXP #endif #ifdef __MINGW32__ @@ -25,7 +25,7 @@ // No regexp support with MinGW, when MinGW C++11 mode is not experimental // we can use std::regex. // -#elif defined(ICE_CPP11_REGEXP) +#elif defined(ICE_CPP11_COMPILER_REGEXP) # include <regex> #else # include <regex.h> @@ -44,14 +44,17 @@ template<typename T> class MetricsHelperT; namespace IceInternal { -class ICE_API MetricsMapI : public IceUtil::Shared +class ICE_API MetricsMapI; +ICE_DEFINE_PTR(MetricsMapIPtr, MetricsMapI); + +class ICE_API MetricsMapI : public ICE_ENABLE_SHARED_FROM_THIS(MetricsMapI) { public: class ICE_API RegExp : public IceUtil::Shared { public: - + RegExp(const std::string&, const std::string&); ~RegExp(); @@ -73,7 +76,7 @@ public: private: bool match(const std::string&); - + const std::string _attribute; #ifdef __MINGW32__ @@ -81,7 +84,7 @@ public: // No regexp support with MinGW, when MinGW C++11 mode is not experimental // we can use std::regex. // -#elif defined(ICE_CPP11_REGEXP) +#elif defined(ICE_CPP11_COMPILER_REGEXP) # if _MSC_VER < 1600 std::tr1::regex _regex; # else @@ -89,9 +92,9 @@ public: # endif #else regex_t _preg; -#endif +#endif }; - typedef IceUtil::Handle<RegExp> RegExpPtr; + ICE_DEFINE_PTR(RegExpPtr, RegExp); MetricsMapI(const std::string&, const Ice::PropertiesPtr&); MetricsMapI(const MetricsMapI&); @@ -102,7 +105,7 @@ public: virtual IceMX::MetricsFailures getFailures(const std::string&) = 0; virtual IceMX::MetricsMap getMetrics() const = 0; - virtual MetricsMapI* clone() const = 0; + virtual MetricsMapIPtr clone() const = 0; const Ice::PropertyDict& getProperties() const; @@ -115,7 +118,6 @@ protected: const std::vector<RegExpPtr> _accept; const std::vector<RegExpPtr> _reject; }; -typedef IceUtil::Handle<MetricsMapI> MetricsMapIPtr; class ICE_API MetricsMapFactory : public Ice::LocalObject { @@ -124,34 +126,39 @@ public: MetricsMapFactory(IceMX::Updater*); virtual MetricsMapIPtr create(const std::string&, const Ice::PropertiesPtr&) = 0; - + void update(); private: - + IceMX::Updater* _updater; }; -typedef IceUtil::Handle<MetricsMapFactory> MetricsMapFactoryPtr; +ICE_DEFINE_PTR(MetricsMapFactoryPtr, MetricsMapFactory); template<class MetricsType> class MetricsMapT : public MetricsMapI, private IceUtil::Mutex { public: typedef MetricsType T; - typedef IceInternal::Handle<MetricsType> TPtr; + typedef ICE_INTERNAL_HANDLE<MetricsType> TPtr; - typedef IceUtil::Handle<MetricsMapT> MetricsMapTPtr; + ICE_DEFINE_PTR(MetricsMapTPtr, MetricsMapT); typedef IceMX::MetricsMap MetricsType::* SubMapMember; class EntryT; - typedef IceUtil::Handle<EntryT> EntryTPtr; + ICE_DEFINE_PTR(EntryTPtr, EntryT); - class EntryT : public Ice::LocalObject + class EntryT +#ifdef ICE_CPP11_MAPPING + : public ::std::enable_shared_from_this<EntryT> +#else + : public Ice::LocalObject +#endif { public: - EntryT(MetricsMapT* map, const TPtr& object, const typename std::list<EntryTPtr>::iterator& p) : + EntryT(MetricsMapT* map, const TPtr& object, const typename std::list<EntryTPtr>::iterator& p) : _map(map), _object(object), _detachedPos(p) { } @@ -166,7 +173,7 @@ public: } } - void + void failed(const std::string& exceptionName) { IceUtil::Mutex::Lock sync(*_map); @@ -180,7 +187,7 @@ public: MetricsMapIPtr m; { IceUtil::Mutex::Lock sync(*_map); - typename std::map<std::string, std::pair<MetricsMapIPtr, SubMapMember> >::iterator p = + typename std::map<std::string, std::pair<MetricsMapIPtr, SubMapMember> >::iterator p = _subMaps.find(mapName); if(p == _subMaps.end()) { @@ -196,7 +203,7 @@ public: } m = p->second.first; } - + MetricsMapT<MemberMetricsType>* map = dynamic_cast<MetricsMapT<MemberMetricsType>*>(m.get()); assert(map); return map->getMatching(helper); @@ -209,7 +216,11 @@ public: _object->totalLifetime += lifetime; if(--_object->current == 0) { +#ifdef ICE_CPP11_MAPPING + _map->detached(this->shared_from_this()); +#else _map->detached(this); +#endif } } @@ -241,7 +252,7 @@ public: IceMX::MetricsPtr clone() const { - TPtr metrics = TPtr::dynamicCast(_object->ice_clone()); + TPtr metrics = ICE_DYNAMIC_CAST(T, _object->ice_clone()); for(typename std::map<std::string, std::pair<MetricsMapIPtr, SubMapMember> >::const_iterator p = _subMaps.begin(); p != _subMaps.end(); ++p) { @@ -364,9 +375,13 @@ public: _subMaps.find(subMapName); if(p != _subMaps.end()) { +#ifdef ICE_CPP11_MAPPING + return std::pair<MetricsMapIPtr, SubMapMember>(p->second.second->clone()->shared_from_this(), p->second.first); +#else return std::pair<MetricsMapIPtr, SubMapMember>(p->second.second->clone(), p->second.first); +#endif } - return std::pair<MetricsMapIPtr, SubMapMember>(MetricsMapIPtr(), static_cast<SubMapMember>(0)); + return std::pair<MetricsMapIPtr, SubMapMember>(MetricsMapIPtr(ICE_NULLPTR), static_cast<SubMapMember>(0)); } EntryTPtr @@ -440,10 +455,10 @@ public: typename std::map<std::string, EntryTPtr>::const_iterator p = _objects.find(key); if(p == _objects.end()) { - TPtr t = new T(); + TPtr t = ICE_MAKE_SHARED(T); t->id = key; p = _objects.insert(typename std::map<std::string, EntryTPtr>::value_type( - key, new EntryT(this, t, _detachedQueue.end()))).first; + key, ICE_MAKE_SHARED(EntryT, this, t, _detachedQueue.end()))).first; } p->second->attach(helper); return p->second; @@ -451,12 +466,12 @@ public: private: - virtual MetricsMapI* clone() const + virtual MetricsMapIPtr clone() const { - return new MetricsMapT<MetricsType>(*this); + return ICE_MAKE_SHARED(MetricsMapT<MetricsType>, *this); } - void detached(EntryT* entry) + void detached(EntryTPtr entry) { // This is called with the map mutex locked. @@ -529,14 +544,14 @@ public: virtual MetricsMapIPtr create(const std::string& mapPrefix, const Ice::PropertiesPtr& properties) { - return new MetricsMapT<MetricsType>(mapPrefix, properties, _subMaps); + return ICE_MAKE_SHARED(MetricsMapT<MetricsType>, mapPrefix, properties, _subMaps); } template<class SubMapMetricsType> void registerSubMap(const std::string& subMap, IceMX::MetricsMap MetricsType::* member) { _subMaps[subMap] = std::pair<IceMX::MetricsMap MetricsType::*, - MetricsMapFactoryPtr>(member, new MetricsMapFactoryT<SubMapMetricsType>(0)); + MetricsMapFactoryPtr>(member, ICE_MAKE_SHARED(MetricsMapFactoryT<SubMapMetricsType>, ICE_NULLPTR)); } private: @@ -569,7 +584,7 @@ private: const std::string _name; std::map<std::string, MetricsMapIPtr> _maps; }; -typedef IceUtil::Handle<MetricsViewI> MetricsViewIPtr; +ICE_DEFINE_PTR(MetricsViewIPtr, MetricsViewI); class ICE_API MetricsAdminI : public IceMX::MetricsAdmin, public Ice::PropertiesAdminUpdateCallback, private IceUtil::Mutex @@ -583,14 +598,14 @@ public: void updateViews(); - template<class MetricsType> void + template<class MetricsType> void registerMap(const std::string& map, IceMX::Updater* updater) { bool updated; MetricsMapFactoryPtr factory; { Lock sync(*this); - factory = new MetricsMapFactoryT<MetricsType>(updater); + factory = ICE_MAKE_SHARED(MetricsMapFactoryT<MetricsType>, updater); _factories[map] = factory; updated = addOrUpdateMap(map, factory); } @@ -604,16 +619,19 @@ public: registerSubMap(const std::string& map, const std::string& subMap, IceMX::MetricsMap MetricsType::* member) { bool updated; - IceUtil::Handle<MetricsMapFactoryT<MetricsType> > factory; + ICE_HANDLE<MetricsMapFactoryT<MetricsType> > factory; { Lock sync(*this); - std::map<std::string, MetricsMapFactoryPtr>::const_iterator p = _factories.find(map); if(p == _factories.end()) { return; } +#ifdef ICE_CPP11_MAPPING + factory = ::std::dynamic_pointer_cast<MetricsMapFactoryT<MetricsType>>(p->second); +#else factory = dynamic_cast<MetricsMapFactoryT<MetricsType>*>(p->second.get()); +#endif factory->template registerSubMap<MemberMetricsType>(subMap, member); removeMap(map); updated = addOrUpdateMap(map, factory); @@ -655,7 +673,7 @@ private: const Ice::LoggerPtr _logger; Ice::PropertiesPtr _properties; }; -typedef IceUtil::Handle<MetricsAdminI> MetricsAdminIPtr; +ICE_DEFINE_PTR(MetricsAdminIPtr, MetricsAdminI); }; diff --git a/cpp/include/Ice/MetricsFunctional.h b/cpp/include/Ice/MetricsFunctional.h index a40be09de17..1d738549803 100644 --- a/cpp/include/Ice/MetricsFunctional.h +++ b/cpp/include/Ice/MetricsFunctional.h @@ -21,6 +21,23 @@ template<typename R> struct ReferenceWrapper } }; +#ifdef ICE_CPP11_MAPPING // C++11 mapping +template<typename R> struct ReferenceWrapper<::std::shared_ptr<R> > +{ + static R* get(const ::std::shared_ptr<R>& v) + { + return v.get(); + } +}; + +template<typename R> struct ReferenceWrapper<const ::std::shared_ptr<R>& > +{ + static R* get(const ::std::shared_ptr<R>& v) + { + return v.get(); + } +}; +#else // C++98 mapping template<typename R> struct ReferenceWrapper<IceInternal::ProxyHandle<R> > { static R* get(const IceInternal::ProxyHandle<R>& v) @@ -52,6 +69,7 @@ template<typename R> struct ReferenceWrapper<const IceInternal::Handle<R>& > return v.get(); } }; +#endif template<typename R> struct ReferenceWrapper<R*> { diff --git a/cpp/include/Ice/MetricsObserverI.h b/cpp/include/Ice/MetricsObserverI.h index d87d62eecce..cedfcac6964 100644 --- a/cpp/include/Ice/MetricsObserverI.h +++ b/cpp/include/Ice/MetricsObserverI.h @@ -36,7 +36,7 @@ public: virtual std::string operator()(const std::string&) const = 0; - virtual void initMetrics(const IceInternal::Handle<T>&) const + virtual void initMetrics(const ICE_INTERNAL_HANDLE<T>&) const { // To be overriden in specialization to initialize state attributes } @@ -266,20 +266,28 @@ protected: }; }; -class Updater : public IceUtil::Shared +class Updater +#ifndef ICE_CPP11_MAPPING + : public IceUtil::Shared +#endif { public: virtual void update() = 0; }; -typedef IceUtil::Handle<Updater> UpdaterPtr; +ICE_DEFINE_PTR(UpdaterPtr, Updater); template<typename T> class UpdaterT : public Updater { public: +#ifdef ICE_CPP11_MAPPING + UpdaterT(const std::shared_ptr<T>& updater, void (T::*fn)()) : +#else UpdaterT(T* updater, void (T::*fn)()) : - _updater(updater), _fn(fn) +#endif + _updater(updater), + _fn(fn) { } @@ -290,22 +298,41 @@ public: private: +#ifdef ICE_CPP11_MAPPING + const ::std::shared_ptr<T> _updater; +#else const IceUtil::Handle<T> _updater; +#endif void (T::*_fn)(); }; -template<typename T> Updater* +#ifdef ICE_CPP11_MAPPING +template<typename T> UpdaterPtr +newUpdater(const std::shared_ptr<T>& updater, void (T::*fn)()) +{ + if(updater) + { + return std::make_shared<UpdaterT<T>>(updater, fn); + } + else + { + return nullptr; + } +} +#else +template<typename T> UpdaterPtr newUpdater(const IceInternal::Handle<T>& updater, void (T::*fn)()) { if(updater) { - return new UpdaterT<T>(updater.get(), fn); + return UpdaterPtr(new UpdaterT<T>(updater.get(), fn)); } else { return 0; } } +#endif template<typename T> class ObserverT : virtual public ::Ice::Instrumentation::Observer { @@ -394,7 +421,7 @@ public: return 0; } - template<typename ObserverImpl, typename ObserverMetricsType> IceInternal::Handle<ObserverImpl> + template<typename ObserverImpl, typename ObserverMetricsType> ICE_INTERNAL_HANDLE<ObserverImpl> getObserver(const std::string& mapName, const MetricsHelperT<ObserverMetricsType>& helper) { std::vector<typename IceInternal::MetricsMapT<ObserverMetricsType>::EntryTPtr> metricsObjects; @@ -412,7 +439,7 @@ public: return 0; } - IceInternal::Handle<ObserverImpl> obsv = new ObserverImpl(); + ICE_INTERNAL_HANDLE<ObserverImpl> obsv = ICE_MAKE_SHARED(ObserverImpl); obsv->init(helper, metricsObjects); return obsv; } @@ -429,10 +456,15 @@ class ObserverFactoryT : public Updater, private IceUtil::Mutex { public: +#ifdef ICE_CPP11_MAPPING + typedef ::std::shared_ptr<ObserverImplType> ObserverImplPtrType; + typedef typename ObserverImplType::MetricsType MetricsType; + typedef std::vector<::std::shared_ptr<IceInternal::MetricsMapT<MetricsType> > > MetricsMapSeqType; +#else typedef IceUtil::Handle<ObserverImplType> ObserverImplPtrType; typedef typename ObserverImplType::MetricsType MetricsType; - typedef std::vector<IceUtil::Handle<IceInternal::MetricsMapT<MetricsType> > > MetricsMapSeqType; +#endif ObserverFactoryT(const IceInternal::MetricsAdminIPtr& metrics, const std::string& name) : _metrics(metrics), _name(name), _enabled(0) @@ -472,7 +504,7 @@ public: return 0; } - ObserverImplPtrType obsv = new ObserverImplType(); + ObserverImplPtrType obsv = ICE_MAKE_SHARED(ObserverImplType); obsv->init(helper, metricsObjects); return obsv; } @@ -480,7 +512,11 @@ public: template<typename ObserverPtrType> ObserverImplPtrType getObserver(const MetricsHelperT<MetricsType>& helper, const ObserverPtrType& observer) { +#ifdef ICE_CPP11_MAPPING + ObserverImplPtrType old = ::std::dynamic_pointer_cast<ObserverImplType>(observer); +#else ObserverImplPtrType old = ObserverImplPtrType::dynamicCast(observer); +#endif if(!observer || !old) { return getObserver(helper); @@ -508,7 +544,7 @@ public: return 0; } - ObserverImplPtrType obsv = new ObserverImplType(); + ObserverImplPtrType obsv = ICE_MAKE_SHARED(ObserverImplType); obsv->init(helper, metricsObjects, old.get()); return obsv; } @@ -539,7 +575,11 @@ public: _maps.clear(); for(std::vector<IceInternal::MetricsMapIPtr>::const_iterator p = maps.begin(); p != maps.end(); ++p) { +#ifdef ICE_CPP11_MAPPING + _maps.push_back(::std::dynamic_pointer_cast<IceInternal::MetricsMapT<MetricsType>>(*p)); +#else _maps.push_back(IceUtil::Handle<IceInternal::MetricsMapT<MetricsType> >::dynamicCast(*p)); +#endif assert(_maps.back()); } _enabled.exchange(_maps.empty() ? 0 : 1); diff --git a/cpp/include/Ice/NativePropertiesAdmin.h b/cpp/include/Ice/NativePropertiesAdmin.h index f5ea2fa97bf..559e626413f 100644 --- a/cpp/include/Ice/NativePropertiesAdmin.h +++ b/cpp/include/Ice/NativePropertiesAdmin.h @@ -33,22 +33,28 @@ namespace Ice // Ice ignores any exceptions raised by the callback. // -class ICE_API PropertiesAdminUpdateCallback : virtual public Ice::LocalObject +class ICE_API PropertiesAdminUpdateCallback +#ifndef ICE_CPP11_MAPPING + : virtual public Ice::LocalObject +#endif { public: virtual void updated(const PropertyDict&) = 0; }; -typedef IceUtil::Handle<PropertiesAdminUpdateCallback> PropertiesAdminUpdateCallbackPtr; +ICE_DEFINE_PTR(PropertiesAdminUpdateCallbackPtr, PropertiesAdminUpdateCallback); -class ICE_API NativePropertiesAdmin : virtual public IceUtil::Shared +class ICE_API NativePropertiesAdmin +#ifndef ICE_CPP11_MAPPING + : virtual public IceUtil::Shared +#endif { public: virtual void addUpdateCallback(const PropertiesAdminUpdateCallbackPtr&) = 0; virtual void removeUpdateCallback(const PropertiesAdminUpdateCallbackPtr&) = 0; }; -typedef IceUtil::Handle<NativePropertiesAdmin> NativePropertiesAdminPtr; +ICE_DEFINE_PTR(NativePropertiesAdminPtr, NativePropertiesAdmin); } diff --git a/cpp/include/Ice/Object.h b/cpp/include/Ice/Object.h index 315e55a72e0..404fd23b6c5 100644 --- a/cpp/include/Ice/Object.h +++ b/cpp/include/Ice/Object.h @@ -58,10 +58,14 @@ public: virtual const Current& getCurrent() = 0; }; -class ICE_API Object : virtual public IceUtil::Shared + +#ifdef ICE_CPP11_MAPPING +class ICE_API Object { public: + virtual ~Object() = default; + virtual bool operator==(const Object&) const; virtual bool operator<(const Object&) const; @@ -76,21 +80,42 @@ public: virtual const std::string& ice_id(const Current& = Current()) const; DispatchStatus ___ice_id(IceInternal::Incoming&, const Current&); - - virtual Int ice_operationAttributes(const std::string&) const; - + static const std::string& ice_staticId(); virtual ObjectPtr ice_clone() const; - virtual void ice_preMarshal(); - virtual void ice_postUnmarshal(); - static std::string __all[]; virtual DispatchStatus ice_dispatch(Ice::Request&, const DispatchInterceptorAsyncCallbackPtr& = 0); virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); +protected: + + static void __checkMode(OperationMode, OperationMode); +}; +#else +class ICE_API Object : public virtual IceUtil::Shared +{ +public: + + virtual bool operator==(const Object&) const; + virtual bool operator<(const Object&) const; + + virtual bool ice_isA(const std::string&, const Current& = Current()) const; + DispatchStatus ___ice_isA(IceInternal::Incoming&, const Current&); + + virtual void ice_ping(const Current& = Current()) const; + DispatchStatus ___ice_ping(IceInternal::Incoming&, const Current&); + + virtual std::vector< std::string> ice_ids(const Current& = Current()) const; + DispatchStatus ___ice_ids(IceInternal::Incoming&, const Current&); + + virtual const std::string& ice_id(const Current& = Current()) const; + DispatchStatus ___ice_id(IceInternal::Incoming&, const Current&); + + virtual Int ice_operationAttributes(const std::string&) const; + virtual void __write(IceInternal::BasicStream*) const; virtual void __read(IceInternal::BasicStream*); @@ -99,12 +124,26 @@ public: virtual bool __gcVisit(IceInternal::GCVisitor&) { return false; }; virtual void ice_collectable(bool) { }; + + virtual void ice_preMarshal(); + virtual void ice_postUnmarshal(); + + static const std::string& ice_staticId(); + + virtual ObjectPtr ice_clone() const; + + static std::string __all[]; + + virtual DispatchStatus ice_dispatch(Ice::Request&, const DispatchInterceptorAsyncCallbackPtr& = 0); + virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); protected: Object() {} // This class is abstract. virtual ~Object() {} +protected: + virtual void __writeImpl(IceInternal::BasicStream*) const {} virtual void __readImpl(IceInternal::BasicStream*) {} @@ -113,6 +152,7 @@ protected: static void __checkMode(OperationMode, OperationMode); }; +#endif class ICE_API Blobject : virtual public Object { @@ -142,8 +182,11 @@ class ICE_API BlobjectAsync : virtual public Object { public: +#ifdef ICE_CPP11_MAPPING + // TODO +#else virtual void ice_invoke_async(const AMD_Object_ice_invokePtr&, const std::vector<Byte>&, const Current&) = 0; - +#endif virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); }; @@ -151,14 +194,17 @@ class ICE_API BlobjectArrayAsync : virtual public Object { public: +#ifdef ICE_CPP11_MAPPING + // TODO +#else virtual void ice_invoke_async(const AMD_Object_ice_invokePtr&, const std::pair<const Byte*, const Byte*>&, const Current&) = 0; - +#endif virtual DispatchStatus __dispatch(IceInternal::Incoming&, const Current&); }; -ICE_API void ice_writeObject(const OutputStreamPtr&, const ObjectPtr&); -ICE_API void ice_readObject(const InputStreamPtr&, ObjectPtr&); +ICE_API void ice_writeObject(const OutputStreamPtr&, const ValuePtr&); +ICE_API void ice_readObject(const InputStreamPtr&, ValuePtr&); } diff --git a/cpp/include/Ice/ObjectAdapterFactoryF.h b/cpp/include/Ice/ObjectAdapterFactoryF.h index 76a68fd34d1..a763f462813 100644 --- a/cpp/include/Ice/ObjectAdapterFactoryF.h +++ b/cpp/include/Ice/ObjectAdapterFactoryF.h @@ -18,8 +18,12 @@ namespace IceInternal { class ObjectAdapterFactory; +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<ObjectAdapterFactory> ObjectAdapterFactoryPtr; +#else IceUtil::Shared* upCast(ObjectAdapterFactory*); typedef IceInternal::Handle<ObjectAdapterFactory> ObjectAdapterFactoryPtr; +#endif } diff --git a/cpp/include/Ice/ObjectF.h b/cpp/include/Ice/ObjectF.h index b338248efc5..d579cb4e87f 100644 --- a/cpp/include/Ice/ObjectF.h +++ b/cpp/include/Ice/ObjectF.h @@ -17,9 +17,14 @@ namespace Ice { class Object; +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<Object> ObjectPtr; +#else ICE_API Object* upCast(Object*); typedef IceInternal::Handle< Object > ObjectPtr; +typedef ObjectPtr ValuePtr; ICE_API void __patch(ObjectPtr&, const ObjectPtr&); +#endif } diff --git a/cpp/include/Ice/ObserverHelper.h b/cpp/include/Ice/ObserverHelper.h index 869fba423db..b294ee872d9 100644 --- a/cpp/include/Ice/ObserverHelper.h +++ b/cpp/include/Ice/ObserverHelper.h @@ -21,7 +21,11 @@ template<typename T = Ice::Instrumentation::Observer> class ObserverHelperT { public: +#ifdef ICE_CPP11_MAPPING + typedef ::std::shared_ptr<T> TPtr; +#else typedef IceInternal::Handle<T> TPtr; +#endif ObserverHelperT() { @@ -37,7 +41,7 @@ public: operator bool() const { - return _observer; + return _observer != ICE_NULLPTR; } T* operator->() const @@ -63,11 +67,17 @@ public: } } +#ifdef ICE_CPP11_MAPPING + TPtr get() const + { + return _observer; + } +#else T* get() const { return _observer.get(); } - +#endif void adopt(ObserverHelperT& other) { _observer = other._observer; @@ -121,13 +131,13 @@ class ICE_API InvocationObserver : public ObserverHelperT<Ice::Instrumentation:: { public: - InvocationObserver(IceProxy::Ice::Object*, const std::string&, const Ice::Context*); + InvocationObserver(const Ice::ObjectPrxPtr&, const std::string&, const Ice::Context*); InvocationObserver(Instance*, const std::string&); InvocationObserver() { } - void attach(IceProxy::Ice::Object*, const std::string&, const Ice::Context*); + void attach(const Ice::ObjectPrxPtr&, const std::string&, const Ice::Context*); void attach(Instance*, const std::string&); void retried() diff --git a/cpp/include/Ice/Outgoing.h b/cpp/include/Ice/Outgoing.h index 62aea1f7c63..e518e528d94 100644 --- a/cpp/include/Ice/Outgoing.h +++ b/cpp/include/Ice/Outgoing.h @@ -77,7 +77,7 @@ class ICE_API ProxyOutgoingBase : public OutgoingBase { public: - ProxyOutgoingBase(IceProxy::Ice::Object*, Ice::OperationMode); + ProxyOutgoingBase(const Ice::ObjectPrxPtr&, Ice::OperationMode); ~ProxyOutgoingBase(); virtual bool invokeRemote(const Ice::ConnectionIPtr&, bool, bool) = 0; @@ -96,7 +96,7 @@ protected: // Optimization. The request handler and the reference may not be // deleted while a stack-allocated Outgoing still holds it. // - IceProxy::Ice::Object* _proxy; + Ice::ObjectPrxPtr _proxy; Ice::OperationMode _mode; RequestHandlerPtr _handler; IceUtil::Time _invocationTimeoutDeadline; @@ -117,7 +117,7 @@ class ICE_API Outgoing : public ProxyOutgoingBase { public: - Outgoing(IceProxy::Ice::Object*, const std::string&, Ice::OperationMode, const Ice::Context*); + Outgoing(const Ice::ObjectPrxPtr&, const std::string&, Ice::OperationMode, const Ice::Context*); ~Outgoing(); virtual bool invokeRemote(const Ice::ConnectionIPtr&, bool, bool); @@ -190,7 +190,7 @@ class ProxyFlushBatch : public ProxyOutgoingBase { public: - ProxyFlushBatch(IceProxy::Ice::Object*, const std::string&); + ProxyFlushBatch(const Ice::ObjectPrxPtr&, const std::string&); virtual bool invokeRemote(const Ice::ConnectionIPtr&, bool, bool); virtual void invokeCollocated(CollocatedRequestHandler*); diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index 440a39138fb..3646dd58351 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -17,6 +17,8 @@ #include <Ice/ConnectionIF.h> #include <Ice/ObjectAdapterF.h> +#include <exception> + namespace IceInternal { @@ -64,9 +66,12 @@ public: protected: +#ifdef ICE_CPP11_MAPPING + OutgoingAsyncBase(const Ice::CommunicatorPtr&, const InstancePtr&, const std::string&, const CallbackBasePtr&); +#else OutgoingAsyncBase(const Ice::CommunicatorPtr&, const InstancePtr&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); - +#endif bool sent(bool); bool finished(const Ice::Exception&); @@ -88,7 +93,7 @@ public: virtual AsyncStatus invokeRemote(const Ice::ConnectionIPtr&, bool, bool) = 0; virtual AsyncStatus invokeCollocated(CollocatedRequestHandler*) = 0; - virtual Ice::ObjectPrx getProxy() const; + virtual Ice::ObjectPrxPtr getProxy() const; using OutgoingAsyncBase::sent; virtual bool completed(const Ice::Exception&); @@ -100,9 +105,12 @@ public: protected: - ProxyOutgoingAsyncBase(const Ice::ObjectPrx&, const std::string&, const CallbackBasePtr&, +#ifdef ICE_CPP11_MAPPING + ProxyOutgoingAsyncBase(const Ice::ObjectPrxPtr&, const std::string&, const CallbackBasePtr&); +#else + ProxyOutgoingAsyncBase(const Ice::ObjectPrxPtr&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); - +#endif void invokeImpl(bool); bool sent(bool); @@ -112,7 +120,7 @@ protected: int handleException(const Ice::Exception&); virtual void runTimerTask(); - const Ice::ObjectPrx _proxy; + const Ice::ObjectPrxPtr _proxy; RequestHandlerPtr _handler; Ice::OperationMode _mode; @@ -129,8 +137,11 @@ class ICE_API OutgoingAsync : public ProxyOutgoingAsyncBase { public: - OutgoingAsync(const Ice::ObjectPrx&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); - +#ifdef ICE_CPP11_MAPPING + OutgoingAsync(const Ice::ObjectPrxPtr&, const std::string&, const CallbackBasePtr&); +#else + OutgoingAsync(const Ice::ObjectPrxPtr&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); +#endif void prepare(const std::string&, Ice::OperationMode, const Ice::Context*); virtual bool sent(); @@ -187,7 +198,11 @@ class ICE_API ProxyFlushBatchAsync : public ProxyOutgoingAsyncBase { public: - ProxyFlushBatchAsync(const Ice::ObjectPrx&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); +#ifdef ICE_CPP11_MAPPING + ProxyFlushBatchAsync(const Ice::ObjectPrxPtr&, const std::string&, const CallbackBasePtr&); +#else + ProxyFlushBatchAsync(const Ice::ObjectPrxPtr&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); +#endif virtual AsyncStatus invokeRemote(const Ice::ConnectionIPtr&, bool, bool); virtual AsyncStatus invokeCollocated(CollocatedRequestHandler*); @@ -207,8 +222,11 @@ class ICE_API ProxyGetConnection : public ProxyOutgoingAsyncBase { public: - ProxyGetConnection(const Ice::ObjectPrx&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); - +#ifdef ICE_CPP11_MAPPING + ProxyGetConnection(const Ice::ObjectPrxPtr&, const std::string&, const CallbackBasePtr&); +#else + ProxyGetConnection(const Ice::ObjectPrxPtr&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); +#endif virtual AsyncStatus invokeRemote(const Ice::ConnectionIPtr&, bool, bool); virtual AsyncStatus invokeCollocated(CollocatedRequestHandler*); @@ -223,9 +241,13 @@ class ICE_API ConnectionFlushBatchAsync : public OutgoingAsyncBase { public: +#ifdef ICE_CPP11_MAPPING + ConnectionFlushBatchAsync(const Ice::ConnectionIPtr&, const Ice::CommunicatorPtr&, const InstancePtr&, + const std::string&, const CallbackBasePtr&); +#else ConnectionFlushBatchAsync(const Ice::ConnectionIPtr&, const Ice::CommunicatorPtr&, const InstancePtr&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); - +#endif virtual Ice::ConnectionPtr getConnection() const; void invoke(); @@ -243,8 +265,13 @@ class ICE_API CommunicatorFlushBatchAsync : public Ice::AsyncResult { public: +#ifdef ICE_CPP11_MAPPING + CommunicatorFlushBatchAsync(const Ice::CommunicatorPtr&, const InstancePtr&, const std::string&, + const CallbackBasePtr&); +#else CommunicatorFlushBatchAsync(const Ice::CommunicatorPtr&, const InstancePtr&, const std::string&, const CallbackBasePtr&, const Ice::LocalObjectPtr&); +#endif void flushConnection(const Ice::ConnectionIPtr&); void ready(); @@ -258,4 +285,98 @@ private: } +// +// Base callback for C++11 mapping +// +#ifdef ICE_CPP11_MAPPING +namespace IceInternal +{ + +class ICE_API OnewayClosureCallback : public ::IceInternal::GenericCallbackBase +{ +public: + + OnewayClosureCallback(const std::string&, + const std::shared_ptr<Ice::ObjectPrx>&, + std::function<void ()>, + std::function<void (::std::exception_ptr)>, + std::function<void (bool)>); + + virtual void + sent(const ::Ice::AsyncResultPtr&) const; + + virtual bool + hasSentCallback() const; + + virtual void + completed(const ::Ice::AsyncResultPtr&) const; + + static std::function<void ()> + invoke(const std::string&, + const std::shared_ptr<Ice::ObjectPrx>&, + Ice::OperationMode, + Ice::FormatType, + std::function<void (::IceInternal::BasicStream*)>, + std::function<void ()>, + std::function<void (::std::exception_ptr)>, + std::function<void (bool)>, + const Ice::Context&); + +private: + + const std::string& __name; + std::shared_ptr<Ice::ObjectPrx> __proxy; + std::function<void ()> __response; + std::function<void (::std::exception_ptr)> __exception; + std::function<void (bool)> __sent; +}; + +class ICE_API TwowayClosureCallback : public ::IceInternal::GenericCallbackBase +{ +public: + + TwowayClosureCallback(const std::string&, + const std::shared_ptr<Ice::ObjectPrx>&, + bool, + std::function<void (::IceInternal::BasicStream*)>, + std::function<void (const ::Ice::UserException&)>, + std::function<void (::std::exception_ptr)>, + std::function<void (bool)>); + + virtual void + sent(const ::Ice::AsyncResultPtr&) const; + + virtual bool + hasSentCallback() const; + + virtual void + completed(const ::Ice::AsyncResultPtr&) const; + + static std::function<void ()> + invoke(const std::string&, + const std::shared_ptr<Ice::ObjectPrx>&, + Ice::OperationMode, + Ice::FormatType, + std::function<void (::IceInternal::BasicStream*)>, + bool, + std::function<void (::IceInternal::BasicStream*)>, + std::function<void (const ::Ice::UserException&)>, + std::function<void (::std::exception_ptr)>, + std::function<void (bool)>, + const Ice::Context&); + +private: + + const std::string& __name; + std::shared_ptr<Ice::ObjectPrx> __proxy; + bool __readEmptyParams; + std::function<void (::IceInternal::BasicStream*)> __read; + std::function<void (const ::Ice::UserException&)> __userException; + std::function<void (::std::exception_ptr)> __exception; + std::function<void (bool)> __sent; +}; + +} +#endif + #endif diff --git a/cpp/include/Ice/OutgoingAsyncF.h b/cpp/include/Ice/OutgoingAsyncF.h index c889ba32c4c..677139e7c9b 100644 --- a/cpp/include/Ice/OutgoingAsyncF.h +++ b/cpp/include/Ice/OutgoingAsyncF.h @@ -18,21 +18,28 @@ namespace IceInternal { class OutgoingAsyncBase; +class OutgoingAsync; +class ProxyOutgoingAsyncBase; +class CommunicatorFlushBatchAsync; + +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<OutgoingAsyncBase> OutgoingAsyncBasePtr; +typedef ::std::shared_ptr<OutgoingAsync> OutgoingAsyncPtr; +typedef ::std::shared_ptr<ProxyOutgoingAsyncBase> ProxyOutgoingAsyncBasePtr; +typedef ::std::shared_ptr<CommunicatorFlushBatchAsync> CommunicatorFlushBatchAsyncPtr; +#else ICE_API IceUtil::Shared* upCast(OutgoingAsyncBase*); typedef IceInternal::Handle<OutgoingAsyncBase> OutgoingAsyncBasePtr; -class OutgoingAsync; ICE_API IceUtil::Shared* upCast(OutgoingAsync*); typedef IceInternal::Handle<OutgoingAsync> OutgoingAsyncPtr; -class ProxyOutgoingAsyncBase; ICE_API IceUtil::Shared* upCast(ProxyOutgoingAsyncBase*); typedef IceInternal::Handle<ProxyOutgoingAsyncBase> ProxyOutgoingAsyncBasePtr; -class CommunicatorFlushBatchAsync; ICE_API IceUtil::Shared* upCast(CommunicatorFlushBatchAsync*); typedef IceInternal::Handle<CommunicatorFlushBatchAsync> CommunicatorFlushBatchAsyncPtr; - +#endif } #endif diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index 0d36364fcc9..1f064928b36 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -29,22 +29,12 @@ #include <Ice/StreamF.h> #include <Ice/CommunicatorF.h> #include <Ice/ObserverHelper.h> +#include <Ice/LocalException.h> #include <iosfwd> -namespace IceProxy -{ - namespace Ice { - -class Locator; -ICE_API ::IceProxy::Ice::Object* upCast(::IceProxy::Ice::Locator*); - -class Router; -ICE_API ::IceProxy::Ice::Object* upCast(::IceProxy::Ice::Router*); - -} - +ICE_API extern const Context noExplicitContext; } namespace IceInternal @@ -54,41 +44,457 @@ class Outgoing; } +#ifdef ICE_CPP11_MAPPING // C++11 mapping namespace Ice { -typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::Router> RouterPrx; -typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::Locator> LocatorPrx; +class RouterPrx; +typedef ::std::shared_ptr<::Ice::RouterPrx> RouterPrxPtr; + +class LocatorPrx; +typedef ::std::shared_ptr<::Ice::LocatorPrx> LocatorPrxPtr; class LocalException; +} -ICE_API void ice_writeObjectPrx(const ::Ice::OutputStreamPtr&, const ObjectPrx&); -ICE_API void ice_readObjectPrx(const ::Ice::InputStreamPtr&, ObjectPrx&); +namespace Ice +{ -class Callback_Object_ice_isA_Base : virtual public ::IceInternal::CallbackBase { }; -typedef ::IceUtil::Handle< Callback_Object_ice_isA_Base> Callback_Object_ice_isAPtr; +class ICE_API ObjectPrx : public ::std::enable_shared_from_this<ObjectPrx> +{ +public: -class Callback_Object_ice_ping_Base : virtual public ::IceInternal::CallbackBase { }; -typedef ::IceUtil::Handle< Callback_Object_ice_ping_Base> Callback_Object_ice_pingPtr; + virtual ~ObjectPrx() = default; -class Callback_Object_ice_ids_Base : virtual public ::IceInternal::CallbackBase { }; -typedef ::IceUtil::Handle< Callback_Object_ice_ids_Base> Callback_Object_ice_idsPtr; + bool operator==(const ObjectPrx&) const; + bool operator!=(const ObjectPrx&) const; + bool operator<(const ObjectPrx&) const; -class Callback_Object_ice_id_Base : virtual public ::IceInternal::CallbackBase { }; -typedef ::IceUtil::Handle< Callback_Object_ice_id_Base> Callback_Object_ice_idPtr; + ::std::shared_ptr<::Ice::Communicator> ice_getCommunicator() const; -class Callback_Object_ice_invoke_Base : virtual public ::IceInternal::CallbackBase { }; -typedef ::IceUtil::Handle< Callback_Object_ice_invoke_Base> Callback_Object_ice_invokePtr; + ::std::string ice_toString() const; -class Callback_Object_ice_flushBatchRequests_Base : virtual public ::IceInternal::CallbackBase { }; -typedef ::IceUtil::Handle< Callback_Object_ice_flushBatchRequests_Base> Callback_Object_ice_flushBatchRequestsPtr; + bool ice_isA(const ::std::string& typeId, const ::Ice::Context& context = ::Ice::noExplicitContext); -class Callback_Object_ice_getConnection_Base : virtual public ::IceInternal::CallbackBase { }; -typedef ::IceUtil::Handle< Callback_Object_ice_getConnection_Base> Callback_Object_ice_getConnectionPtr; + ::std::function<void()> + ice_isA_async(const ::std::string& typeId, + ::std::function<void (bool)> response, + ::std::function<void (::std::exception_ptr)> = nullptr, + ::std::function<void (bool)> sent = nullptr, + const ::Ice::Context& context = ::Ice::noExplicitContext); + + template<template<typename> class P = std::promise> + auto ice_isA_async(const ::std::string& typeId, const ::Ice::Context& context = ::Ice::noExplicitContext) + -> decltype(std::declval<P<bool>>().get_future()) + { + auto promise = ::std::make_shared<P<bool>>(); + + ice_isA_async( + typeId, + [promise](bool value) + { + promise->set_value(value); + }, + [promise](::std::exception_ptr ex) + { + promise->set_exception(::std::move(ex)); + }, + nullptr, context); + + return promise->get_future(); + } + + void + ice_ping(const ::Ice::Context& context = ::Ice::noExplicitContext); + + ::std::function<void()> + ice_ping_async(::std::function<void ()> response, + ::std::function<void (::std::exception_ptr)> exception = nullptr, + ::std::function<void (bool)> sent = nullptr, + const ::Ice::Context& context = ::Ice::noExplicitContext); + + template<template<typename> class P = std::promise> + auto ice_ping_async(const ::Ice::Context& context = ::Ice::noExplicitContext) + -> decltype(std::declval<P<void>>().get_future()) + { + auto promise = ::std::make_shared<P<void>>(); + if(ice_isTwoway()) + { + ice_ping_async( + [promise]() + { + promise->set_value(); + }, + [promise](::std::exception_ptr ex) + { + promise->set_exception(::std::move(ex)); + }, + nullptr, context); + } + else if(ice_isOneway() || ice_isDatagram()) + { + ice_ping_async( + nullptr, + [promise](::std::exception_ptr ex) + { + promise->set_exception(::std::move(ex)); + }, + [promise](bool) + { + promise->set_value(); + }, + context); + } + else + { + ice_ping_async(nullptr, nullptr, nullptr, context); + promise->set_value(); + } + return promise->get_future(); + } + ::std::vector<::std::string> + ice_ids(const ::Ice::Context& context = ::Ice::noExplicitContext); + + ::std::function<void()> + ice_ids_async(::std::function<void (::std::vector< ::std::string>)> response, + ::std::function<void (::std::exception_ptr)> exception = nullptr, + ::std::function<void (bool)> sent = nullptr, + const ::Ice::Context& context = ::Ice::noExplicitContext); + + template<template<typename> class P = std::promise> + auto ice_ids_async(const ::Ice::Context& context = ::Ice::noExplicitContext) + -> decltype(std::declval<P<::std::vector<::std::string>>>().get_future()) + { + auto promise = ::std::make_shared<P<::std::vector<::std::string>>>(); + ice_ids_async( + [promise](::std::vector<::std::string> ids) + { + promise->set_value(::std::move(ids)); + }, + [promise](::std::exception_ptr ex) + { + promise->set_exception(::std::move(ex)); + }, + nullptr, context); + return promise->get_future(); + } + + ::std::string + ice_id(const ::Ice::Context& context = ::Ice::noExplicitContext); + + ::std::function<void ()> + ice_id_async(::std::function<void (::std::string)> response, + ::std::function<void (::std::exception_ptr)> exception = nullptr, + ::std::function<void (bool)> sent = nullptr, + const ::Ice::Context& context = ::Ice::noExplicitContext); + + template<template<typename> class P = std::promise> + auto ice_id_async(const ::Ice::Context& context = ::Ice::noExplicitContext) + -> decltype(std::declval<P<::std::string>>().get_future()) + { + auto promise = ::std::make_shared<P<::std::string>>(); + ice_id_async( + [promise](::std::string id) + { + promise->set_value(::std::move(id)); + }, + [promise](::std::exception_ptr ex) + { + promise->set_exception(::std::move(ex)); + }, + nullptr, context); + return promise->get_future(); + } + + static const ::std::string& ice_staticId() + { + return ::Ice::Object::ice_staticId(); + } + + // Returns true if ok, false if user exception. + bool + ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, + const ::std::vector< ::Ice::Byte>& inParams, + ::std::vector< ::Ice::Byte>& outParams, + const ::Ice::Context& context = ::Ice::noExplicitContext); + + ::std::function<void ()> + ice_invoke_async( + const ::std::string&, + ::Ice::OperationMode, + const ::std::vector<::Ice::Byte>&, + ::std::function<void (bool, ::std::vector<::Ice::Byte>)> response, + ::std::function<void (::std::exception_ptr)> exception = nullptr, + ::std::function<void (bool)> sent = nullptr, + const ::Ice::Context& context = ::Ice::noExplicitContext); + + ::Ice::Identity ice_getIdentity() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_identity(const ::Ice::Identity&) const; + + ::Ice::Context ice_getContext() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_context(const ::Ice::Context&) const; + + const ::std::string& ice_getFacet() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_facet(const ::std::string&) const; + + ::std::string ice_getAdapterId() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_adapterId(const ::std::string&) const; + + ::Ice::EndpointSeq ice_getEndpoints() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_endpoints(const ::Ice::EndpointSeq&) const; + + ::Ice::Int ice_getLocatorCacheTimeout() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_locatorCacheTimeout(::Ice::Int) const; + + bool ice_isConnectionCached() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_connectionCached(bool) const; + + ::Ice::EndpointSelectionType ice_getEndpointSelection() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_endpointSelection(::Ice::EndpointSelectionType) const; + + bool ice_isSecure() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_secure(bool) const; + + ::Ice::EncodingVersion ice_getEncodingVersion() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_encodingVersion(const ::Ice::EncodingVersion&) const; + + bool ice_isPreferSecure() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_preferSecure(bool) const; + + ::std::shared_ptr<::Ice::RouterPrx> ice_getRouter() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_router(const ::std::shared_ptr<::Ice::RouterPrx>&) const; + + ::std::shared_ptr<::Ice::LocatorPrx> ice_getLocator() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_locator(const ::std::shared_ptr<::Ice::LocatorPrx>&) const; + + bool ice_isCollocationOptimized() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_collocationOptimized(bool) const; + + ::Ice::Int ice_getInvocationTimeout() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_invocationTimeout(::Ice::Int) const; + + ::std::shared_ptr<::Ice::ObjectPrx> ice_twoway() const; + bool ice_isTwoway() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_oneway() const; + bool ice_isOneway() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_batchOneway() const; + bool ice_isBatchOneway() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_datagram() const; + bool ice_isDatagram() const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_batchDatagram() const; + bool ice_isBatchDatagram() const; + + ::std::shared_ptr<::Ice::ObjectPrx> ice_compress(bool) const; + ::std::shared_ptr<::Ice::ObjectPrx> ice_timeout(int) const; + + ::std::shared_ptr<::Ice::ObjectPrx> ice_connectionId(const ::std::string&) const; + ::std::string ice_getConnectionId() const; + + + ::std::shared_ptr<::Ice::Connection> ice_getConnection(); + + ::std::function<void ()> + ice_getConnection_async( + ::std::function<void (::std::shared_ptr<::Ice::Connection>)> response, + ::std::function<void (::std::exception_ptr)> exception = nullptr); + + + template<template<typename> class P = std::promise> + auto ice_getConnection_async() + -> decltype(std::declval<P<::std::shared_ptr<::Ice::Connection>>>().get_future()) + { + auto promise = ::std::make_shared<P<::std::shared_ptr<::Ice::Connection>>>(); + ice_getConnection_async( + [promise](::std::shared_ptr<::Ice::Connection> connection) + { + promise->set_value(::std::move(connection)); + }, + [promise](::std::exception_ptr ex) + { + promise->set_exception(::std::move(ex)); + }); + return promise->get_future(); + } + + ::std::shared_ptr<::Ice::Connection> ice_getCachedConnection() const; + + void ice_flushBatchRequests(); + + std::function<void ()> + ice_flushBatchRequests_async( + ::std::function<void (::std::exception_ptr)> exception, + ::std::function<void (bool)> sent = nullptr); + + + template<template<typename> class P = std::promise> + auto ice_flushBatchRequests_async() + -> decltype(std::declval<P<bool>>().get_future()) + { + auto promise = ::std::make_shared<P<bool>>(); + ice_flushBatchRequests_async( + [promise](::std::exception_ptr ex) + { + promise->set_exception(::std::move(ex)); + }, + [promise](bool sent) + { + promise->set_value(sent); + }); + return promise->get_future(); + } + + const ::IceInternal::ReferencePtr& __reference() const { return _reference; } + + void __copyFrom(const ::Ice::ObjectPrxPtr&); + + int __handleException(const ::Ice::Exception&, const ::IceInternal::RequestHandlerPtr&, ::Ice::OperationMode, + bool, int&); + + void __checkAsyncTwowayOnly(const ::std::string&) const; + + ::IceInternal::RequestHandlerPtr __getRequestHandler(); + ::IceInternal::BatchRequestQueuePtr __getBatchRequestQueue(); + ::IceInternal::RequestHandlerPtr __setRequestHandler(const ::IceInternal::RequestHandlerPtr&); + void __updateRequestHandler(const ::IceInternal::RequestHandlerPtr&, const ::IceInternal::RequestHandlerPtr&); + +protected: + + virtual ::std::shared_ptr<ObjectPrx> __newInstance() const; + +private: + + void setup(const ::IceInternal::ReferencePtr&); + friend class ::IceInternal::ProxyFactory; + + ::IceInternal::ReferencePtr _reference; + ::IceInternal::RequestHandlerPtr _requestHandler; + ::IceInternal::BatchRequestQueuePtr _batchRequestQueue; + IceUtil::Mutex _mutex; +}; + +ICE_API ::std::ostream& operator<<(::std::ostream&, const ::Ice::ObjectPrx&); + +ICE_API bool proxyIdentityLess(const ::std::shared_ptr<ObjectPrx>&, const ::std::shared_ptr<ObjectPrx>&); +ICE_API bool proxyIdentityEqual(const ::std::shared_ptr<ObjectPrx>&, const ::std::shared_ptr<ObjectPrx>&); + +ICE_API bool proxyIdentityAndFacetLess(const ::std::shared_ptr<ObjectPrx>&, const ::std::shared_ptr<ObjectPrx>&); +ICE_API bool proxyIdentityAndFacetEqual(const ::std::shared_ptr<ObjectPrx>&, const ::std::shared_ptr<ObjectPrx>&); + +struct ProxyIdentityLess : std::binary_function<bool, ::std::shared_ptr<ObjectPrx>&, ::std::shared_ptr<ObjectPrx>&> +{ + bool operator()(const ::std::shared_ptr<ObjectPrx>& lhs, const ::std::shared_ptr<ObjectPrx>& rhs) const + { + return proxyIdentityLess(lhs, rhs); + } +}; + +struct ProxyIdentityEqual : std::binary_function<bool, ::std::shared_ptr<ObjectPrx>&, ::std::shared_ptr<ObjectPrx>&> +{ + bool operator()(const ::std::shared_ptr<ObjectPrx>& lhs, const ::std::shared_ptr<ObjectPrx>& rhs) const + { + return proxyIdentityEqual(lhs, rhs); + } +}; + +struct ProxyIdentityAndFacetLess : std::binary_function<bool, ::std::shared_ptr<ObjectPrx>&, ::std::shared_ptr<ObjectPrx>&> +{ + bool operator()(const ::std::shared_ptr<ObjectPrx>& lhs, const ::std::shared_ptr<ObjectPrx>& rhs) const + { + return proxyIdentityAndFacetLess(lhs, rhs); + } +}; + +struct ProxyIdentityAndFacetEqual : std::binary_function<bool, ::std::shared_ptr<ObjectPrx>&, ::std::shared_ptr<ObjectPrx>&> +{ + bool operator()(const ::std::shared_ptr<ObjectPrx>& lhs, const ::std::shared_ptr<ObjectPrx>& rhs) const + { + return proxyIdentityAndFacetEqual(lhs, rhs); + } +}; + +template<typename P, + typename T, + typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, P>::value>::type* = nullptr, + typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, T>::value>::type* = nullptr> ::std::shared_ptr<P> +uncheckedCast(const ::std::shared_ptr<T>& b) +{ + ::std::shared_ptr<P> r; + if(b) + { + r = ::std::dynamic_pointer_cast<P>(b); + if(!r) + { + r = ::std::make_shared<P>(); + r->__copyFrom(b); + } + } + return r; } -#ifdef ICE_CPP11 +template<typename P, + typename T, + typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, P>::value>::type* = nullptr, + typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, T>::value>::type* = nullptr> ::std::shared_ptr<P> +uncheckedCast(const ::std::shared_ptr<T>& b, const std::string& f) +{ + ::std::shared_ptr<P> r; + if(b) + { + r = ::std::make_shared<P>(); + r->__copyFrom(b->ice_facet(f)); + } + return r; +} + +template<typename P, + typename T, + typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, P>::value>::type* = nullptr, + typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, T>::value>::type* = nullptr> ::std::shared_ptr<P> +checkedCast(const ::std::shared_ptr<T>& b, const ::Ice::Context& context = Ice::noExplicitContext) +{ + ::std::shared_ptr<P> r; + if(b) + { + if(b->ice_isA(P::ice_staticId(), context)) + { + r = ::std::make_shared<P>(); + r->__copyFrom(b); + } + } + return r; +} + +template<typename P, + typename T, + typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, P>::value>::type* = nullptr, + typename ::std::enable_if<::std::is_base_of<::Ice::ObjectPrx, T>::value>::type* = nullptr> ::std::shared_ptr<P> +checkedCast(const ::std::shared_ptr<T>& b, const std::string& f, const ::Ice::Context& context = Ice::noExplicitContext) +{ + ::std::shared_ptr<P> r; + if(b) + { + try + { + ::std::shared_ptr<::Ice::ObjectPrx> bb = b->ice_facet(f); + if(bb->ice_isA(P::ice_staticId(), context)) + { + r = ::std::make_shared<P>(); + r->__copyFrom(bb); + } + } + catch(const Ice::FacetNotExistException&) + { + } + } + return r; +} + +} + +#else // C++98 mapping +# ifdef ICE_CPP11_COMPILER namespace IceInternal { @@ -130,7 +536,59 @@ private: }; } -#endif +# endif + +namespace IceProxy +{ + +namespace Ice +{ + +class Locator; +ICE_API ::IceProxy::Ice::Object* upCast(::IceProxy::Ice::Locator*); + +class Router; +ICE_API ::IceProxy::Ice::Object* upCast(::IceProxy::Ice::Router*); + +} + +} + +namespace Ice +{ + +typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::Router> RouterPrx; +typedef RouterPrx RouterPrxPtr; +typedef ::IceInternal::ProxyHandle< ::IceProxy::Ice::Locator> LocatorPrx; +typedef LocatorPrx LocatorPrxPtr; + +class LocalException; + +ICE_API void ice_writeObjectPrx(const ::Ice::OutputStreamPtr&, const ObjectPrxPtr&); +ICE_API void ice_readObjectPrx(const ::Ice::InputStreamPtr&, ObjectPrxPtr&); + +class Callback_Object_ice_isA_Base : virtual public ::IceInternal::CallbackBase { }; +typedef ::IceUtil::Handle< Callback_Object_ice_isA_Base> Callback_Object_ice_isAPtr; + +class Callback_Object_ice_ping_Base : virtual public ::IceInternal::CallbackBase { }; +typedef ::IceUtil::Handle< Callback_Object_ice_ping_Base> Callback_Object_ice_pingPtr; + +class Callback_Object_ice_ids_Base : virtual public ::IceInternal::CallbackBase { }; +typedef ::IceUtil::Handle< Callback_Object_ice_ids_Base> Callback_Object_ice_idsPtr; + +class Callback_Object_ice_id_Base : virtual public ::IceInternal::CallbackBase { }; +typedef ::IceUtil::Handle< Callback_Object_ice_id_Base> Callback_Object_ice_idPtr; + +class Callback_Object_ice_invoke_Base : virtual public ::IceInternal::CallbackBase { }; +typedef ::IceUtil::Handle< Callback_Object_ice_invoke_Base> Callback_Object_ice_invokePtr; + +class Callback_Object_ice_flushBatchRequests_Base : virtual public ::IceInternal::CallbackBase { }; +typedef ::IceUtil::Handle< Callback_Object_ice_flushBatchRequests_Base> Callback_Object_ice_flushBatchRequestsPtr; + +class Callback_Object_ice_getConnection_Base : virtual public ::IceInternal::CallbackBase { }; +typedef ::IceUtil::Handle< Callback_Object_ice_getConnection_Base> Callback_Object_ice_getConnectionPtr; + +} namespace IceProxy { namespace Ice { @@ -147,16 +605,12 @@ public: ::std::string ice_toString() const; - bool ice_isA(const ::std::string& typeId) - { - return ice_isA(typeId, 0); - } - bool ice_isA(const ::std::string& typeId, const ::Ice::Context& context) + bool ice_isA(const ::std::string& typeId, const ::Ice::Context& context = ::Ice::noExplicitContext) { return ice_isA(typeId, &context); } -#ifdef ICE_CPP11 +# ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr begin_ice_isA(const ::std::string& typeId, const ::Ice::Context& ctx, @@ -175,7 +629,7 @@ public: ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { - return __begin_ice_isA(typeId, 0, response, exception, sent); + return __begin_ice_isA(typeId, &::Ice::noExplicitContext, response, exception, sent); } ::Ice::AsyncResultPtr @@ -184,7 +638,7 @@ public: const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { - return begin_ice_isA(typeId, 0, ::Ice::newCallback(completed, sent), 0); + return begin_ice_isA(typeId, &::Ice::noExplicitContext, ::Ice::newCallback(completed, sent), 0); } ::Ice::AsyncResultPtr @@ -196,14 +650,9 @@ public: { return begin_ice_isA(typeId, &ctx, ::Ice::newCallback(completed, sent), 0); } -#endif - - ::Ice::AsyncResultPtr begin_ice_isA(const ::std::string& typeId) - { - return begin_ice_isA(typeId, 0, ::IceInternal::__dummyCallback, 0); - } +# endif - ::Ice::AsyncResultPtr begin_ice_isA(const ::std::string& typeId, const ::Ice::Context& __ctx) + ::Ice::AsyncResultPtr begin_ice_isA(const ::std::string& typeId, const ::Ice::Context& __ctx = ::Ice::noExplicitContext) { return begin_ice_isA(typeId, &__ctx, ::IceInternal::__dummyCallback, 0); } @@ -212,7 +661,7 @@ public: const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_isA(typeId, 0, __del, __cookie); + return begin_ice_isA(typeId, &::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_isA(const ::std::string& typeId, @@ -227,7 +676,7 @@ public: const ::Ice::Callback_Object_ice_isAPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_isA(typeId, 0, __del, __cookie); + return begin_ice_isA(typeId, &::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_isA(const ::std::string& typeId, @@ -240,23 +689,19 @@ public: bool end_ice_isA(const ::Ice::AsyncResultPtr&); - void ice_ping() - { - ice_ping(0); - } - void ice_ping(const ::Ice::Context& context) + void ice_ping(const ::Ice::Context& context = ::Ice::noExplicitContext) { ice_ping(&context); } -#ifdef ICE_CPP11 +# ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr begin_ice_ping(const ::IceInternal::Function<void ()>& response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { - return __begin_ice_ping(0, response, exception, sent); + return __begin_ice_ping(&::Ice::noExplicitContext, response, exception, sent); } ::Ice::AsyncResultPtr @@ -274,7 +719,7 @@ public: const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { - return begin_ice_ping(0, ::Ice::newCallback(completed, sent), 0); + return begin_ice_ping(&::Ice::noExplicitContext, ::Ice::newCallback(completed, sent), 0); } ::Ice::AsyncResultPtr @@ -285,14 +730,9 @@ public: { return begin_ice_ping(&ctx, ::Ice::newCallback(completed, sent), 0); } -#endif +# endif - ::Ice::AsyncResultPtr begin_ice_ping() - { - return begin_ice_ping(0, ::IceInternal::__dummyCallback, 0); - } - - ::Ice::AsyncResultPtr begin_ice_ping(const ::Ice::Context& __ctx) + ::Ice::AsyncResultPtr begin_ice_ping(const ::Ice::Context& __ctx = ::Ice::noExplicitContext) { return begin_ice_ping(&__ctx, ::IceInternal::__dummyCallback, 0); } @@ -300,7 +740,7 @@ public: ::Ice::AsyncResultPtr begin_ice_ping(const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_ping(0, __del, __cookie); + return begin_ice_ping(&::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_ping(const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, @@ -313,7 +753,7 @@ public: ::Ice::AsyncResultPtr begin_ice_ping(const ::Ice::Callback_Object_ice_pingPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_ping(0, __del, __cookie); + return begin_ice_ping(&::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_ping(const ::Ice::Context& __ctx, const ::Ice::Callback_Object_ice_pingPtr& __del, @@ -324,23 +764,19 @@ public: void end_ice_ping(const ::Ice::AsyncResultPtr&); - ::std::vector< ::std::string> ice_ids() - { - return ice_ids(0); - } - ::std::vector< ::std::string> ice_ids(const ::Ice::Context& context) + ::std::vector< ::std::string> ice_ids(const ::Ice::Context& context = ::Ice::noExplicitContext) { return ice_ids(&context); } -#ifdef ICE_CPP11 +# ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr begin_ice_ids(const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>& response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { - return __begin_ice_ids(0, response, exception, sent); + return __begin_ice_ids(&::Ice::noExplicitContext, response, exception, sent); } ::Ice::AsyncResultPtr @@ -358,7 +794,7 @@ public: const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { - return begin_ice_ids(0, ::Ice::newCallback(completed, sent), 0); + return begin_ice_ids(&::Ice::noExplicitContext, ::Ice::newCallback(completed, sent), 0); } ::Ice::AsyncResultPtr @@ -369,14 +805,9 @@ public: { return begin_ice_ids(&ctx, ::Ice::newCallback(completed, sent), 0); } -#endif +# endif - ::Ice::AsyncResultPtr begin_ice_ids() - { - return begin_ice_ids(0, ::IceInternal::__dummyCallback, 0); - } - - ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::Context& __ctx) + ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::Context& __ctx = ::Ice::noExplicitContext) { return begin_ice_ids(&__ctx, ::IceInternal::__dummyCallback, 0); } @@ -384,7 +815,7 @@ public: ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_ids(0, __del, __cookie); + return begin_ice_ids(&::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::Context& __ctx, @@ -397,7 +828,7 @@ public: ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::Callback_Object_ice_idsPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_ids(0, __del, __cookie); + return begin_ice_ids(&::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::Context& __ctx, @@ -409,23 +840,19 @@ public: ::std::vector< ::std::string> end_ice_ids(const ::Ice::AsyncResultPtr&); - ::std::string ice_id() - { - return ice_id(0); - } - ::std::string ice_id(const ::Ice::Context& context) + ::std::string ice_id(const ::Ice::Context& context = ::Ice::noExplicitContext) { return ice_id(&context); } -#ifdef ICE_CPP11 +# ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr begin_ice_id(const ::IceInternal::Function<void (const ::std::string&)>& response, const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { - return __begin_ice_id(0, response, exception, sent); + return __begin_ice_id(&::Ice::noExplicitContext, response, exception, sent); } ::Ice::AsyncResultPtr @@ -443,7 +870,7 @@ public: const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) { - return begin_ice_id(0, ::Ice::newCallback(completed, sent), 0); + return begin_ice_id(&::Ice::noExplicitContext, ::Ice::newCallback(completed, sent), 0); } ::Ice::AsyncResultPtr @@ -454,14 +881,9 @@ public: { return begin_ice_id(&ctx, ::Ice::newCallback(completed, sent), 0); } -#endif - - ::Ice::AsyncResultPtr begin_ice_id() - { - return begin_ice_id(0, ::IceInternal::__dummyCallback, 0); - } +# endif - ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context& __ctx) + ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context& __ctx = ::Ice::noExplicitContext) { return begin_ice_id(&__ctx, ::IceInternal::__dummyCallback, 0); } @@ -469,7 +891,7 @@ public: ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_id(0, __del, __cookie); + return begin_ice_id(&::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context& __ctx, @@ -482,7 +904,7 @@ public: ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Callback_Object_ice_idPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_id(0, __del, __cookie); + return begin_ice_id(&::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context& __ctx, @@ -505,21 +927,13 @@ public: bool ice_invoke(const ::std::string& operation, ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams, - ::std::vector< ::Ice::Byte>& outParams) - { - return ice_invoke(operation, mode, inParams, outParams, 0); - } - - bool ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, - const ::std::vector< ::Ice::Byte>& inParams, ::std::vector< ::Ice::Byte>& outParams, - const ::Ice::Context& context) + const ::Ice::Context& context = ::Ice::noExplicitContext) { return ice_invoke(operation, mode, inParams, outParams, &context); } -#ifdef ICE_CPP11 +# ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr begin_ice_invoke( const ::std::string& operation, ::Ice::OperationMode mode, @@ -529,7 +943,7 @@ public: ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { - return __begin_ice_invoke(operation, mode, inParams, 0, response, exception, sent); + return __begin_ice_invoke(operation, mode, inParams, &::Ice::noExplicitContext, response, exception, sent); } ::Ice::AsyncResultPtr begin_ice_invoke( @@ -554,7 +968,7 @@ public: ::IceInternal::Function<void (const ::Ice::Exception&)>(), const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) { - return __begin_ice_invoke(operation, mode, inParams, 0, response, exception, sent); + return __begin_ice_invoke(operation, mode, inParams, &::Ice::noExplicitContext, response, exception, sent); } ::Ice::AsyncResultPtr begin_ice_invoke( @@ -570,13 +984,13 @@ public: { return __begin_ice_invoke(operation, mode, inParams, &ctx, response, exception, sent); } -#endif +# endif ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams) { - return begin_ice_invoke(operation, mode, inParams, 0, ::IceInternal::__dummyCallback, 0); + return begin_ice_invoke(operation, mode, inParams, &::Ice::noExplicitContext, ::IceInternal::__dummyCallback, 0); } ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, @@ -593,7 +1007,7 @@ public: const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_invoke(operation, mode, inParams, 0, __del, __cookie); + return begin_ice_invoke(operation, mode, inParams, &::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, @@ -612,7 +1026,7 @@ public: const ::Ice::Callback_Object_ice_invokePtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_invoke(operation, mode, inParams, 0, __del, __cookie); + return begin_ice_invoke(operation, mode, inParams, &::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, @@ -630,16 +1044,8 @@ public: bool ice_invoke(const ::std::string& operation, ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, - ::std::vector< ::Ice::Byte>& outParams) - { - return ice_invoke(operation, mode, inParams, outParams, 0); - } - - bool ice_invoke(const ::std::string& operation, - ::Ice::OperationMode mode, - const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, ::std::vector< ::Ice::Byte>& outParams, - const ::Ice::Context& context) + const ::Ice::Context& context = ::Ice::noExplicitContext) { return ice_invoke(operation, mode, inParams, outParams, &context); } @@ -648,7 +1054,7 @@ public: ::Ice::OperationMode mode, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams) { - return begin_ice_invoke(operation, mode, inParams, 0, ::IceInternal::__dummyCallback, 0); + return begin_ice_invoke(operation, mode, inParams, &::Ice::noExplicitContext, ::IceInternal::__dummyCallback, 0); } ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, @@ -666,7 +1072,7 @@ public: const ::Ice::CallbackPtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_invoke(operation, mode, inParams, 0, __del, __cookie); + return begin_ice_invoke(operation, mode, inParams, &::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, @@ -685,7 +1091,7 @@ public: const ::Ice::Callback_Object_ice_invokePtr& __del, const ::Ice::LocalObjectPtr& __cookie = 0) { - return begin_ice_invoke(operation, mode, inParams, 0, __del, __cookie); + return begin_ice_invoke(operation, mode, inParams, &::Ice::noExplicitContext, __del, __cookie); } ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, @@ -701,37 +1107,37 @@ public: bool ___end_ice_invoke(::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&, const ::Ice::AsyncResultPtr&); ::Ice::Identity ice_getIdentity() const; - ::Ice::ObjectPrx ice_identity(const ::Ice::Identity&) const; + ::Ice::ObjectPrxPtr ice_identity(const ::Ice::Identity&) const; ::Ice::Context ice_getContext() const; - ::Ice::ObjectPrx ice_context(const ::Ice::Context&) const; + ::Ice::ObjectPrxPtr ice_context(const ::Ice::Context&) const; const ::std::string& ice_getFacet() const; - ::Ice::ObjectPrx ice_facet(const ::std::string&) const; + ::Ice::ObjectPrxPtr ice_facet(const ::std::string&) const; ::std::string ice_getAdapterId() const; - ::Ice::ObjectPrx ice_adapterId(const ::std::string&) const; + ::Ice::ObjectPrxPtr ice_adapterId(const ::std::string&) const; ::Ice::EndpointSeq ice_getEndpoints() const; - ::Ice::ObjectPrx ice_endpoints(const ::Ice::EndpointSeq&) const; + ::Ice::ObjectPrxPtr ice_endpoints(const ::Ice::EndpointSeq&) const; ::Ice::Int ice_getLocatorCacheTimeout() const; - ::Ice::ObjectPrx ice_locatorCacheTimeout(::Ice::Int) const; + ::Ice::ObjectPrxPtr ice_locatorCacheTimeout(::Ice::Int) const; bool ice_isConnectionCached() const; - ::Ice::ObjectPrx ice_connectionCached(bool) const; + ::Ice::ObjectPrxPtr ice_connectionCached(bool) const; ::Ice::EndpointSelectionType ice_getEndpointSelection() const; - ::Ice::ObjectPrx ice_endpointSelection(::Ice::EndpointSelectionType) const; + ::Ice::ObjectPrxPtr ice_endpointSelection(::Ice::EndpointSelectionType) const; bool ice_isSecure() const; - ::Ice::ObjectPrx ice_secure(bool) const; + ::Ice::ObjectPrxPtr ice_secure(bool) const; ::Ice::EncodingVersion ice_getEncodingVersion() const; - ::Ice::ObjectPrx ice_encodingVersion(const ::Ice::EncodingVersion&) const; + ::Ice::ObjectPrxPtr ice_encodingVersion(const ::Ice::EncodingVersion&) const; bool ice_isPreferSecure() const; - ::Ice::ObjectPrx ice_preferSecure(bool) const; + ::Ice::ObjectPrxPtr ice_preferSecure(bool) const; ::Ice::RouterPrx ice_getRouter() const; ::Ice::ObjectPrx ice_router(const ::Ice::RouterPrx&) const; @@ -764,7 +1170,7 @@ public: ::Ice::ConnectionPtr ice_getConnection(); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr begin_ice_getConnection( const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed) { @@ -800,7 +1206,7 @@ public: void ice_flushBatchRequests(); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr begin_ice_flushBatchRequests( const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception, const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) @@ -833,7 +1239,7 @@ public: ::Ice::Int __hash() const; - void __copyFrom(const ::Ice::ObjectPrx&); + void __copyFrom(const ::Ice::ObjectPrxPtr&); int __handleException(const ::Ice::Exception&, const ::IceInternal::RequestHandlerPtr&, ::Ice::OperationMode, bool, int&); @@ -861,7 +1267,7 @@ private: const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr&); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr __begin_ice_isA( const ::std::string&, const ::Ice::Context*, @@ -877,7 +1283,7 @@ private: const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr&); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr __begin_ice_ping( const ::Ice::Context* ctx, const ::IceInternal::Function<void ()>& response, @@ -894,7 +1300,7 @@ private: const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr&); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr __begin_ice_ids( const ::Ice::Context*, const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>&, @@ -908,7 +1314,7 @@ private: ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr&); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr __begin_ice_id( const ::Ice::Context*, const ::IceInternal::Function<void (const ::std::string&)>&, @@ -931,7 +1337,7 @@ private: const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr&); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr __begin_ice_invoke( const ::std::string&, ::Ice::OperationMode, @@ -957,7 +1363,7 @@ private: const ::IceInternal::CallbackBasePtr&, const ::Ice::LocalObjectPtr&); -#ifdef ICE_CPP11 +#ifdef ICE_CPP11_COMPILER ::Ice::AsyncResultPtr __begin_ice_invoke( const ::std::string&, ::Ice::OperationMode, @@ -991,39 +1397,39 @@ ICE_API ::std::ostream& operator<<(::std::ostream&, const ::IceProxy::Ice::Objec namespace Ice { -ICE_API bool proxyIdentityLess(const ObjectPrx&, const ObjectPrx&); -ICE_API bool proxyIdentityEqual(const ObjectPrx&, const ObjectPrx&); +ICE_API bool proxyIdentityLess(const ObjectPrxPtr&, const ObjectPrxPtr&); +ICE_API bool proxyIdentityEqual(const ObjectPrxPtr&, const ObjectPrxPtr&); -ICE_API bool proxyIdentityAndFacetLess(const ObjectPrx&, const ObjectPrx&); -ICE_API bool proxyIdentityAndFacetEqual(const ObjectPrx&, const ObjectPrx&); +ICE_API bool proxyIdentityAndFacetLess(const ObjectPrxPtr&, const ObjectPrxPtr&); +ICE_API bool proxyIdentityAndFacetEqual(const ObjectPrxPtr&, const ObjectPrxPtr&); -struct ProxyIdentityLess : std::binary_function<bool, ObjectPrx&, ObjectPrx&> +struct ProxyIdentityLess : std::binary_function<bool, ObjectPrxPtr&, ObjectPrxPtr&> { - bool operator()(const ObjectPrx& lhs, const ObjectPrx& rhs) const + bool operator()(const ObjectPrxPtr& lhs, const ObjectPrxPtr& rhs) const { return proxyIdentityLess(lhs, rhs); } }; -struct ProxyIdentityEqual : std::binary_function<bool, ObjectPrx&, ObjectPrx&> +struct ProxyIdentityEqual : std::binary_function<bool, ObjectPrxPtr&, ObjectPrxPtr&> { - bool operator()(const ObjectPrx& lhs, const ObjectPrx& rhs) const + bool operator()(const ObjectPrxPtr& lhs, const ObjectPrxPtr& rhs) const { return proxyIdentityEqual(lhs, rhs); } }; -struct ProxyIdentityAndFacetLess : std::binary_function<bool, ObjectPrx&, ObjectPrx&> +struct ProxyIdentityAndFacetLess : std::binary_function<bool, ObjectPrxPtr&, ObjectPrxPtr&> { - bool operator()(const ObjectPrx& lhs, const ObjectPrx& rhs) const + bool operator()(const ObjectPrxPtr& lhs, const ObjectPrxPtr& rhs) const { return proxyIdentityAndFacetLess(lhs, rhs); } }; -struct ProxyIdentityAndFacetEqual : std::binary_function<bool, ObjectPrx&, ObjectPrx&> +struct ProxyIdentityAndFacetEqual : std::binary_function<bool, ObjectPrxPtr&, ObjectPrxPtr&> { - bool operator()(const ObjectPrx& lhs, const ObjectPrx& rhs) const + bool operator()(const ObjectPrxPtr& lhs, const ObjectPrxPtr& rhs) const { return proxyIdentityAndFacetEqual(lhs, rhs); } @@ -1096,7 +1502,7 @@ inline bool operator>=(const ProxyHandle<T>& lhs, const ProxyHandle<U>& rhs) // checkedCast and uncheckedCast functions without facet: // template<typename P> P -checkedCastImpl(const ::Ice::ObjectPrx& b, const ::Ice::Context* context) +checkedCastImpl(const ::Ice::ObjectPrxPtr& b, const ::Ice::Context* context) { P d = 0; if(b.get()) @@ -1116,7 +1522,7 @@ checkedCastImpl(const ::Ice::ObjectPrx& b, const ::Ice::Context* context) } template<typename P> P -uncheckedCastImpl(const ::Ice::ObjectPrx& b) +uncheckedCastImpl(const ::Ice::ObjectPrxPtr& b) { P d = 0; if(b) @@ -1140,24 +1546,24 @@ uncheckedCastImpl(const ::Ice::ObjectPrx& b) // // Helper with type ID. // -ICE_API ::Ice::ObjectPrx checkedCastImpl(const ::Ice::ObjectPrx&, const std::string&, const std::string&, +ICE_API ::Ice::ObjectPrxPtr checkedCastImpl(const ::Ice::ObjectPrxPtr&, const std::string&, const std::string&, const ::Ice::Context*); // -// Specializations for P = ::Ice::ObjectPrx +// Specializations for P = ::Ice::ObjectPrxPtr // We have to use inline functions for broken compilers such as VC7. // -template<> inline ::Ice::ObjectPrx -checkedCastImpl< ::Ice::ObjectPrx>(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Context* context) +template<> inline ::Ice::ObjectPrxPtr +checkedCastImpl< ::Ice::ObjectPrxPtr>(const ::Ice::ObjectPrxPtr& b, const std::string& f, const ::Ice::Context* context) { return checkedCastImpl(b, f, "::Ice::Object", context); } -template<> inline ::Ice::ObjectPrx -uncheckedCastImpl< ::Ice::ObjectPrx>(const ::Ice::ObjectPrx& b, const std::string& f) +template<> inline ::Ice::ObjectPrxPtr +uncheckedCastImpl< ::Ice::ObjectPrxPtr>(const ::Ice::ObjectPrxPtr& b, const std::string& f) { - ::Ice::ObjectPrx d = 0; + ::Ice::ObjectPrxPtr d = 0; if(b) { d = b->ice_facet(f); @@ -1166,12 +1572,12 @@ uncheckedCastImpl< ::Ice::ObjectPrx>(const ::Ice::ObjectPrx& b, const std::strin } template<typename P> P -checkedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Context* context) +checkedCastImpl(const ::Ice::ObjectPrxPtr& b, const std::string& f, const ::Ice::Context* context) { P d = 0; typedef typename P::element_type T; - ::Ice::ObjectPrx bb = checkedCastImpl(b, f, T::ice_staticId(), context); + ::Ice::ObjectPrxPtr bb = checkedCastImpl(b, f, T::ice_staticId(), context); if(bb) { @@ -1182,14 +1588,14 @@ checkedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Co } template<typename P> P -uncheckedCastImpl(const ::Ice::ObjectPrx& b, const std::string& f) +uncheckedCastImpl(const ::Ice::ObjectPrxPtr& b, const std::string& f) { P d = 0; if(b) { typedef typename P::element_type T; - ::Ice::ObjectPrx bb = b->ice_facet(f); + ::Ice::ObjectPrxPtr bb = b->ice_facet(f); d = new T; d->__copyFrom(bb); } @@ -1224,20 +1630,20 @@ uncheckedCast(const ::IceInternal::ProxyHandle<Y>& b) } template<typename P> inline P -checkedCast(const ::Ice::ObjectPrx& b, const std::string& f) +checkedCast(const ::Ice::ObjectPrxPtr& b, const std::string& f) { Ice::Context* ctx = 0; return ::IceInternal::checkedCastImpl<P>(b, f, ctx); } template<typename P> inline P -checkedCast(const ::Ice::ObjectPrx& b, const std::string& f, const ::Ice::Context& context) +checkedCast(const ::Ice::ObjectPrxPtr& b, const std::string& f, const ::Ice::Context& context) { return ::IceInternal::checkedCastImpl<P>(b, f, &context); } template<typename P> inline P -uncheckedCast(const ::Ice::ObjectPrx& b, const std::string& f) +uncheckedCast(const ::Ice::ObjectPrxPtr& b, const std::string& f) { return ::IceInternal::uncheckedCastImpl<P>(b, f); } @@ -2448,5 +2854,6 @@ newCallback_Object_ice_flushBatchRequests(T* instance, } } +#endif #endif diff --git a/cpp/include/Ice/ProxyF.h b/cpp/include/Ice/ProxyF.h index a310540d7ee..2f0a5a223c9 100644 --- a/cpp/include/Ice/ProxyF.h +++ b/cpp/include/Ice/ProxyF.h @@ -15,6 +15,7 @@ #include <Ice/Config.h> #include <Ice/ProxyHandle.h> +#ifndef ICE_CPP11_MAPPING // C++98 mapping namespace IceProxy { @@ -71,8 +72,32 @@ namespace Ice { typedef IceInternal::ProxyHandle< ::IceProxy::Ice::Object> ObjectPrx; +typedef ObjectPrx ObjectPrxPtr; } +#else // C++11 mapping +namespace Ice +{ + +class ObjectPrx; +typedef ::std::shared_ptr<ObjectPrx> ObjectPrxPtr; + +} + +namespace IceProxy +{ + +namespace Ice +{ + +// +// ObjectPrx alias for compatibility with C++98 mapping +// +typedef ::Ice::ObjectPrx Object; +} + +} +#endif #endif diff --git a/cpp/include/Ice/ProxyHandle.h b/cpp/include/Ice/ProxyHandle.h index 3d127f33494..eabf9acf003 100644 --- a/cpp/include/Ice/ProxyHandle.h +++ b/cpp/include/Ice/ProxyHandle.h @@ -15,6 +15,7 @@ #include <iosfwd> +#ifndef ICE_CPP11_MAPPING // C++98 mapping namespace IceInternal { @@ -328,3 +329,5 @@ std::ostream& operator<<(std::ostream& os, ::IceInternal::ProxyHandle<Y> p) } #endif + +#endif diff --git a/cpp/include/Ice/RequestHandlerF.h b/cpp/include/Ice/RequestHandlerF.h index ac777d61761..7dfbe6aca72 100644 --- a/cpp/include/Ice/RequestHandlerF.h +++ b/cpp/include/Ice/RequestHandlerF.h @@ -16,14 +16,20 @@ namespace IceInternal { +class CancellationHandler; class RequestHandler; -ICE_API IceUtil::Shared* upCast(RequestHandler*); -typedef IceInternal::Handle<RequestHandler> RequestHandlerPtr; -class CancellationHandler; +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<CancellationHandler> CancellationHandlerPtr; +typedef ::std::shared_ptr<RequestHandler> RequestHandlerPtr; +#else ICE_API IceUtil::Shared* upCast(CancellationHandler*); typedef IceInternal::Handle<CancellationHandler> CancellationHandlerPtr; +ICE_API IceUtil::Shared* upCast(RequestHandler*); +typedef IceInternal::Handle<RequestHandler> RequestHandlerPtr; +#endif + } #endif diff --git a/cpp/include/Ice/ResponseHandlerF.h b/cpp/include/Ice/ResponseHandlerF.h index 88a5c05e063..109a2697981 100644 --- a/cpp/include/Ice/ResponseHandlerF.h +++ b/cpp/include/Ice/ResponseHandlerF.h @@ -17,8 +17,13 @@ namespace IceInternal { class ResponseHandler; + +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<ResponseHandler> ResponseHandlerPtr; +#else ICE_API IceUtil::Shared* upCast(ResponseHandler*); typedef IceInternal::Handle<ResponseHandler> ResponseHandlerPtr; +#endif } diff --git a/cpp/include/Ice/SlicedData.h b/cpp/include/Ice/SlicedData.h index 96ec59fd24c..2956e7431f2 100644 --- a/cpp/include/Ice/SlicedData.h +++ b/cpp/include/Ice/SlicedData.h @@ -12,6 +12,7 @@ #include <Ice/SlicedDataF.h> #include <Ice/GCObject.h> +#include <Ice/Value.h> namespace Ice { @@ -19,7 +20,10 @@ namespace Ice // // SliceInfo encapsulates the details of a slice for an unknown class or exception type. // -struct ICE_API SliceInfo : public ::IceUtil::Shared +struct ICE_API SliceInfo +#ifndef ICE_CPP11_MAPPING + : public ::IceUtil::Shared +#endif { // // The Slice type ID for this slice. @@ -39,7 +43,7 @@ struct ICE_API SliceInfo : public ::IceUtil::Shared // // The Ice objects referenced by this slice. // - ::std::vector<ObjectPtr> objects; + ::std::vector<ValuePtr> objects; // // Whether or not the slice contains optional members. @@ -55,21 +59,30 @@ struct ICE_API SliceInfo : public ::IceUtil::Shared // // SlicedData holds the slices of unknown types. // -class ICE_API SlicedData : public ::IceUtil::Shared +class ICE_API SlicedData +#ifndef ICE_CPP11_MAPPING + : public ::IceUtil::Shared +#endif { public: SlicedData(const SliceInfoSeq&); const SliceInfoSeq slices; - +#ifndef ICE_CPP11_MAPPING void __gcVisitMembers(IceInternal::GCVisitor&); +#endif }; // // Unknown sliced object holds instance of unknown type. // -class ICE_API UnknownSlicedObject : virtual public Object, private IceInternal::GCObject +class ICE_API UnknownSlicedObject +#ifdef ICE_CPP11_MAPPING + : public Value +#else + : virtual public Object, private IceInternal::GCObject +#endif { public: @@ -79,13 +92,12 @@ public: SlicedDataPtr getSlicedData() const; +#ifndef ICE_CPP11_MAPPING virtual void __gcVisitMembers(IceInternal::GCVisitor&); +#endif virtual void __write(::IceInternal::BasicStream*) const; virtual void __read(::IceInternal::BasicStream*); - - using Object::__write; - using Object::__read; private: diff --git a/cpp/include/Ice/SlicedDataF.h b/cpp/include/Ice/SlicedDataF.h index d72444347c1..dd2d1f71277 100644 --- a/cpp/include/Ice/SlicedDataF.h +++ b/cpp/include/Ice/SlicedDataF.h @@ -17,17 +17,25 @@ namespace Ice { struct SliceInfo; +class SlicedData; +class UnknownSlicedObject; + +#ifdef ICE_CPP11_MAPPING +typedef ::std::shared_ptr<SliceInfo> SliceInfoPtr; +typedef ::std::shared_ptr<SlicedData> SlicedDataPtr; +typedef ::std::shared_ptr<UnknownSlicedObject> UnknownSlicedObjectPtr; +#else ICE_API IceUtil::Shared* upCast(SliceInfo*); typedef IceInternal::Handle<SliceInfo> SliceInfoPtr; -typedef ::std::vector<SliceInfoPtr> SliceInfoSeq; -class SlicedData; ICE_API IceUtil::Shared* upCast(SlicedData*); typedef IceInternal::Handle<SlicedData> SlicedDataPtr; -class UnknownSlicedObject; ICE_API IceUtil::Shared* upCast(UnknownSlicedObject*); typedef IceInternal::Handle<UnknownSlicedObject> UnknownSlicedObjectPtr; +#endif + +typedef ::std::vector<SliceInfoPtr> SliceInfoSeq; } diff --git a/cpp/include/Ice/Stream.h b/cpp/include/Ice/Stream.h index 551e55f9b70..84d58abdc10 100644 --- a/cpp/include/Ice/Stream.h +++ b/cpp/include/Ice/Stream.h @@ -26,7 +26,7 @@ class ICE_API ReadObjectCallback : public ::IceUtil::Shared { public: - virtual void invoke(const ObjectPtr&) = 0; + virtual void invoke(const ValuePtr&) = 0; }; typedef IceUtil::Handle<ReadObjectCallback> ReadObjectCallbackPtr; @@ -36,14 +36,18 @@ class ReadObjectCallbackI : public ReadObjectCallback public: - ReadObjectCallbackI(::IceInternal::Handle<T>& v) : + ReadObjectCallbackI(ICE_INTERNAL_HANDLE<T>& v) : _v(v) { } - virtual void invoke(const ObjectPtr& p) + virtual void invoke(const ValuePtr& p) { +#ifdef ICE_CPP11_MAPPING + _v = ::std::dynamic_pointer_cast<T>(p); +#else _v = ::IceInternal::Handle<T>::dynamicCast(p); +#endif if(p && !_v) { IceInternal::Ex::throwUOE(T::ice_staticId(), p); @@ -52,7 +56,7 @@ public: private: - ::IceInternal::Handle<T>& _v; + ICE_INTERNAL_HANDLE<T>& _v; }; class ICE_API UserExceptionReader : public UserException @@ -109,23 +113,33 @@ public: virtual Int readSize() = 0; virtual Int readAndCheckSeqSize(int) = 0; - virtual ObjectPrx readProxy() = 0; + virtual ObjectPrxPtr readProxy() = 0; +#ifndef ICE_CPP11_MAPPING template<typename T> void read(IceInternal::ProxyHandle<T>& v) +#else + template<typename T, typename ::std::enable_if<IsProxy<T>::value>::type* = nullptr> + void read(::std::shared_ptr<T>& v) +#endif { - ObjectPrx proxy = readProxy(); + ObjectPrxPtr proxy = readProxy(); if(!proxy) { v = 0; } else { - v = new T; + v = ICE_MAKE_SHARED(T); v->__copyFrom(proxy); } } virtual void readObject(const ReadObjectCallbackPtr&) = 0; +#ifndef ICE_CPP11_MAPPING template<typename T> void read(IceInternal::Handle<T>& v) +#else + template<typename T, typename ::std::enable_if<IsValue<T>::value>::type* = nullptr> + void read(::std::shared_ptr<T>& v) +#endif { readObject(new ReadObjectCallbackI<T>(v)); } @@ -255,17 +269,33 @@ public: virtual void writeSize(Int) = 0; - virtual void writeProxy(const ObjectPrx&) = 0; + virtual void writeProxy(const ObjectPrxPtr&) = 0; +#ifndef ICE_CPP11_MAPPING template<typename T> void write(const IceInternal::ProxyHandle<T>& v) { writeProxy(ObjectPrx(v.get())); } +#else + template<typename T, typename ::std::enable_if<IsProxy<T>::value>::type* = nullptr> + void write(const ::std::shared_ptr<T>& v) + { + writeProxy(::std::dynamic_pointer_cast<ObjectPrx>(v)); + } +#endif - virtual void writeObject(const ObjectPtr&) = 0; + virtual void writeObject(const ValuePtr&) = 0; +#ifndef ICE_CPP11_MAPPING template<typename T> void write(const IceInternal::Handle<T>& v) { writeObject(ObjectPtr(v.get())); } +#else + template<typename T, typename ::std::enable_if<IsValue<T>::value>::type* = nullptr> + void write(const ::std::shared_ptr<T>& v) + { + writeObject(::std::dynamic_pointer_cast<Value>(v)); + } +#endif virtual void writeEnum(Int v, Int maxValue) { diff --git a/cpp/include/Ice/StreamHelpers.h b/cpp/include/Ice/StreamHelpers.h index 9ffd6634b60..10bd6e723af 100644 --- a/cpp/include/Ice/StreamHelpers.h +++ b/cpp/include/Ice/StreamHelpers.h @@ -14,6 +14,7 @@ #include <IceUtil/Iterator.h> #include <Ice/ObjectF.h> +#include <Ice/Traits.h> namespace Ice { @@ -233,6 +234,15 @@ struct StreamableTraits< ::std::vector<bool> > }; +#ifdef ICE_CPP11_MAPPING +template<typename T> +struct StreamableTraits<::std::shared_ptr<T>, typename ::std::enable_if<IsProxy<T>::value>::type> +{ + static const StreamHelperCategory helper = StreamHelperCategoryProxy; + static const int minWireSize = 2; + static const bool fixedLength = false; +}; +#else template<typename T> struct StreamableTraits< ::IceInternal::ProxyHandle<T> > { @@ -240,7 +250,17 @@ struct StreamableTraits< ::IceInternal::ProxyHandle<T> > static const int minWireSize = 2; static const bool fixedLength = false; }; +#endif +#ifdef ICE_CPP11_MAPPING +template<typename T> +struct StreamableTraits<::std::shared_ptr<T>, typename ::std::enable_if<IsValue<T>::value>::type> +{ + static const StreamHelperCategory helper = StreamHelperCategoryClass; + static const int minWireSize = 1; + static const bool fixedLength = false; +}; +#else template<typename T> struct StreamableTraits< ::IceInternal::Handle<T> > { @@ -248,6 +268,7 @@ struct StreamableTraits< ::IceInternal::Handle<T> > static const int minWireSize = 1; static const bool fixedLength = false; }; +#endif // // StreamHelper templates used by streams to read and write data. diff --git a/cpp/include/Ice/Traits.h b/cpp/include/Ice/Traits.h new file mode 100644 index 00000000000..e81cffdeaa1 --- /dev/null +++ b/cpp/include/Ice/Traits.h @@ -0,0 +1,45 @@ +#ifndef ICE_TRAITS_H +#define ICE_TRAITS_H + +#ifdef ICE_CPP11_MAPPING + +#include <type_traits> + +namespace Ice +{ + +class ObjectPrx; +class Value; + +template<class T> using IsProxy = ::std::is_base_of<::Ice::ObjectPrx, T>; +template<class T> using IsValue = ::std::is_base_of<::Ice::Value, T>; + +enum class Kind { Value, Proxy }; + +template<typename T> +struct TypeTraits +{ + constexpr static bool isKind(Kind kind) + { + switch(kind) + { + case Kind::Value: + { + return std::is_base_of<Value, T>::value; + } + case Kind::Proxy: + { + return std::is_base_of<ObjectPrx, T>::value; + } + default: + { + return false; + } + } + } +}; + +} +#endif + +#endif diff --git a/cpp/include/Ice/Value.h b/cpp/include/Ice/Value.h new file mode 100644 index 00000000000..4d66fe4fd33 --- /dev/null +++ b/cpp/include/Ice/Value.h @@ -0,0 +1,62 @@ +// ********************************************************************** +// +// 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_VALUE_H +#define ICE_VALUE_H + +#ifdef ICE_CPP11_MAPPING // C++11 mapping + +#include <Ice/ValueF.h> +#include <Ice/StreamF.h> + +namespace IceInternal +{ + +class BasicStream; + +} + +namespace Ice +{ + +class ICE_API Value +{ +public: + + virtual ~Value() = default; + + virtual void ice_preMarshal(); + virtual void ice_postUnmarshal(); + + virtual void __write(IceInternal::BasicStream*) const; + virtual void __read(IceInternal::BasicStream*); + + virtual const std::string& ice_id() const; + static const std::string& ice_staticId(); + +protected: + + virtual void __writeImpl(IceInternal::BasicStream*) const {} + virtual void __readImpl(IceInternal::BasicStream*) {} +}; + +template<typename T> +struct ICE_API InterfaceTraits +{ + static const int compactId = -1; + static const std::string staticId; +}; + +ICE_API void ice_writeObject(const OutputStreamPtr&, const ValuePtr&); +ICE_API void ice_readObject(const InputStreamPtr&, ValuePtr&); + +} +#endif // C++11 mapping end + +#endif diff --git a/cpp/include/Ice/ValueF.h b/cpp/include/Ice/ValueF.h new file mode 100644 index 00000000000..d441f6f096b --- /dev/null +++ b/cpp/include/Ice/ValueF.h @@ -0,0 +1,34 @@ +// ********************************************************************** +// +// 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_VALUE_F_H +#define ICE_VALUE_F_H + +#include <IceUtil/Shared.h> +#include <Ice/Handle.h> +#include <Ice/ObjectF.h> + +#ifdef ICE_CPP11_MAPPING // C++11 mapping +namespace Ice +{ + +class Value; +typedef ::std::shared_ptr< ::Ice::Value> ValuePtr; +ICE_API void __patch(ValuePtr&, const ValuePtr&); + +} +#else // C++98 mapping +// +// Define value as an alias to Object +// +//typedef ::Ice::Object Value; +//typedef ::Ice::ObjectPtr ValuePtr; +#endif + +#endif diff --git a/cpp/include/IceSSL/Plugin.h b/cpp/include/IceSSL/Plugin.h index bf773f143d1..0578f689fbf 100644 --- a/cpp/include/IceSSL/Plugin.h +++ b/cpp/include/IceSSL/Plugin.h @@ -164,14 +164,16 @@ private: // Forward declaration. // class Certificate; -typedef IceUtil::Handle<Certificate> CertificatePtr; +ICE_DEFINE_PTR(CertificatePtr, Certificate); // // A representation of a PublicKey. // -class ICE_SSL_API PublicKey : public IceUtil::Shared +class ICE_SSL_API PublicKey : public ICE_ENABLE_SHARED_FROM_THIS(PublicKey) { public: + + PublicKey(const CertificatePtr&, KeyRef); ~PublicKey(); @@ -186,14 +188,13 @@ public: private: - PublicKey(const CertificatePtr&, KeyRef); friend class Certificate; CertificatePtr _cert; KeyRef _key; }; -typedef IceUtil::Handle<PublicKey> PublicKeyPtr; +ICE_DEFINE_PTR(PublicKeyPtr, PublicKey); // // This class represents a DistinguishedName, similar to the Java @@ -266,7 +267,7 @@ private: // This convenience class is a wrapper around a native certificate. // The interface is inspired by java.security.cert.X509Certificate. // -class ICE_SSL_API Certificate : public IceUtil::Shared +class ICE_SSL_API Certificate : public ICE_ENABLE_SHARED_FROM_THIS(Certificate) { public: @@ -456,7 +457,7 @@ public: // std::vector<CertificatePtr> nativeCerts; }; -typedef IceUtil::Handle<NativeConnectionInfo> NativeConnectionInfoPtr; +ICE_DEFINE_PTR(NativeConnectionInfoPtr, NativeConnectionInfo); // // WSSNativeConnectionInfo is an extension of IceSSL::WSSConnectionInfo @@ -473,13 +474,13 @@ public: // std::vector<CertificatePtr> nativeCerts; }; -typedef IceUtil::Handle<WSSNativeConnectionInfo> WSSNativeConnectionInfoPtr; +ICE_DEFINE_PTR(WSSNativeConnectionInfoPtr, WSSNativeConnectionInfo); // // An application can customize the certificate verification process // by implementing the CertificateVerifier interface. // -class ICE_SSL_API CertificateVerifier : public IceUtil::Shared +class ICE_SSL_API CertificateVerifier : public ICE_ENABLE_SHARED_FROM_THIS(CertificateVerifier) { public: @@ -489,7 +490,7 @@ public: // virtual bool verify(const NativeConnectionInfoPtr&) = 0; }; -typedef IceUtil::Handle<CertificateVerifier> CertificateVerifierPtr; +ICE_DEFINE_PTR(CertificateVerifierPtr, CertificateVerifier); // // In order to read an encrypted file, such as one containing a @@ -506,7 +507,7 @@ typedef IceUtil::Handle<CertificateVerifier> CertificateVerifierPtr; // IceSSL.DelayInit=1), configure the PasswordPrompt, then manually // initialize the plug-in. // -class ICE_SSL_API PasswordPrompt : public IceUtil::Shared +class ICE_SSL_API PasswordPrompt : public ICE_ENABLE_SHARED_FROM_THIS(PasswordPrompt) { public: @@ -517,7 +518,7 @@ public: // virtual std::string getPassword() = 0; }; -typedef IceUtil::Handle<PasswordPrompt> PasswordPromptPtr; +ICE_DEFINE_PTR(PasswordPromptPtr, PasswordPrompt); class ICE_SSL_API Plugin : public Ice::Plugin { @@ -557,7 +558,7 @@ public: virtual SSL_CTX* getContext() = 0; #endif }; -typedef IceUtil::Handle<Plugin> PluginPtr; +ICE_DEFINE_PTR(PluginPtr, Plugin); } diff --git a/cpp/include/IceUtil/Atomic.h b/cpp/include/IceUtil/Atomic.h index dcf705bb612..2ed19c2bc7d 100644 --- a/cpp/include/IceUtil/Atomic.h +++ b/cpp/include/IceUtil/Atomic.h @@ -10,12 +10,12 @@ #ifndef ICE_UTIL_ATOMIC_H #define ICE_UTIL_ATOMIC_H -#if ((defined(ICE_CPP11) && defined(_MSC_VER) && (_MSC_VER > 1600)) || \ - (defined(ICE_CPP11) && !defined(_MSC_VER))) -# define ICE_CPP11_HAS_ATOMIC +#if ((defined(ICE_CPP11_COMPILER) && defined(_MSC_VER) && (_MSC_VER > 1600)) || \ + (defined(ICE_CPP11_COMPILER) && !defined(_MSC_VER))) +# define ICE_CPP11_COMPILER_HAS_ATOMIC #endif -#if defined(ICE_CPP11_HAS_ATOMIC) +#if defined(ICE_CPP11_COMPILER_HAS_ATOMIC) # include <atomic> #elif defined(ICE_USE_MUTEX_SHARED) @@ -45,7 +45,7 @@ namespace IceUtilInternal { -#ifdef ICE_CPP11_HAS_ATOMIC +#ifdef ICE_CPP11_COMPILER_HAS_ATOMIC typedef std::atomic<int> Atomic; #else diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h index c656374d1f9..7f0aebb879c 100644 --- a/cpp/include/IceUtil/Config.h +++ b/cpp/include/IceUtil/Config.h @@ -57,11 +57,18 @@ #if (__cplusplus >= 201103) || \ ((defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && ((__GNUC__* 100) + __GNUC_MINOR__) >= 405)) || \ (defined(_MSC_VER) && (_MSC_VER >= 1600)) -# define ICE_CPP11 +# define ICE_CPP11_COMPILER +#endif + +// +// Check C++11 compiler is used when building the C++11 mapping +// +#if defined(ICE_CPP11_MAPPING) && !defined(ICE_CPP11_COMPILER) +# error "you need a C++11 capble compiler to use C++11 mapping" #endif -#if defined(ICE_CPP11) && (!defined(_MSC_VER) || (_MSC_VER >= 1900)) +#if defined(ICE_CPP11_COMPILER) && (!defined(_MSC_VER) || (_MSC_VER >= 1900)) # define ICE_NOEXCEPT noexcept # define ICE_NOEXCEPT_FALSE noexcept(false) #else @@ -242,4 +249,39 @@ typedef long long Int64; #define ICE_STRING_VERSION "3.7.0" // "A.B.C", with A=major, B=minor, C=patch #define ICE_INT_VERSION 30700 // AABBCC, with AA=major, BB=minor, CC=patch +// +// Macros to facilitate C++98 -> C++11 transition +// +#ifdef ICE_CPP11_MAPPING // C++11 mapping +# include <memory> +# include <future> +# define ICE_HANDLE ::std::shared_ptr +# define ICE_INTERNAL_HANDLE ::std::shared_ptr +# define ICE_PROXY_HANDLE ::std::shared_ptr +# define ICE_MAKE_SHARED(T, ...) ::std::make_shared<T>(__VA_ARGS__) +# define ICE_DEFINE_PTR(TPtr, T) typedef ::std::shared_ptr<T> TPtr +# define ICE_ENUM(CLASS,ENUMERATOR) CLASS::ENUMERATOR +# define ICE_NULLPTR nullptr +# define ICE_DYNAMIC_CAST(T,V) ::std::dynamic_pointer_cast<T>(V) +# define ICE_ENABLE_SHARED_FROM_THIS(T) ::std::enable_shared_from_this<T> +# define ICE_SHARED_FROM_THIS shared_from_this() +# define ICE_CHECKED_CAST(T,V) Ice::checkedCast<T>(V) +# define ICE_UNCHECKED_CAST(T,V) Ice::uncheckedCast<T>(V) +# define ICE_OBJECT_FACTORY ::std::function<::Ice::ValuePtr (const std::string& type)> +#else // C++98 mapping +# define ICE_HANDLE ::IceUtil::Handle +# define ICE_INTERNAL_HANDLE ::IceInternal::Handle +# define ICE_PROXY_HANDLE ::IceInternal::ProxyHandle +# define ICE_MAKE_SHARED(T, ...) new T(__VA_ARGS__) +# define ICE_DEFINE_PTR(TPtr, T) typedef ::IceUtil::Handle<T> TPtr +# define ICE_ENUM(CLASS,ENUMERATOR) ENUMERATOR +# define ICE_NULLPTR 0 +# define ICE_DYNAMIC_CAST(T,V) T##Ptr::dynamicCast(V) +# define ICE_ENABLE_SHARED_FROM_THIS(T) virtual ::IceUtil::Shared +# define ICE_SHARED_FROM_THIS this +# define ICE_CHECKED_CAST(T,V) T::checkedCast(V) +# define ICE_UNCHECKED_CAST(T,V) T::uncheckedCast(V) +# define ICE_OBJECT_FACTORY ::Ice::ObjectFactoryPtr +#endif + #endif diff --git a/cpp/include/IceUtil/Timer.h b/cpp/include/IceUtil/Timer.h index fdaab7fe473..9457730abf6 100644 --- a/cpp/include/IceUtil/Timer.h +++ b/cpp/include/IceUtil/Timer.h @@ -28,7 +28,10 @@ typedef IceUtil::Handle<Timer> TimerPtr; // Extend the TimerTask class and override the runTimerTask() method to execute // code at a specific time or repeatedly. // -class ICE_UTIL_API TimerTask : virtual public IceUtil::Shared +class ICE_UTIL_API TimerTask +#ifndef ICE_CPP11_MAPPING + : virtual public IceUtil::Shared +#endif { public: @@ -36,7 +39,7 @@ public: virtual void runTimerTask() = 0; }; -typedef IceUtil::Handle<TimerTask> TimerTaskPtr; +ICE_DEFINE_PTR(TimerTaskPtr, TimerTask); // // The timer class is used to schedule tasks for one-time execution or diff --git a/cpp/include/Slice/CPlusPlusUtil.h b/cpp/include/Slice/CPlusPlusUtil.h index 9338bfe32cd..6f25e95ea9c 100644 --- a/cpp/include/Slice/CPlusPlusUtil.h +++ b/cpp/include/Slice/CPlusPlusUtil.h @@ -32,15 +32,17 @@ const int TypeContextInParam = 1; const int TypeContextAMIEnd = 2; const int TypeContextAMIPrivateEnd = 4; const int TypeContextAMICallPrivateEnd = 8; - const int TypeContextUseWstring = 16; +const int TypeContextReadClosure = 32; + +SLICE_API bool isMovable(const TypePtr&); -SLICE_API std::string typeToString(const TypePtr&, const StringList& = StringList(), int = 0); -SLICE_API std::string typeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0); -SLICE_API std::string returnTypeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0); -SLICE_API std::string inputTypeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0); -SLICE_API std::string outputTypeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0); -SLICE_API std::string operationModeToString(Operation::Mode); +SLICE_API std::string typeToString(const TypePtr&, const StringList& = StringList(), int = 0, bool = false); +SLICE_API std::string typeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0, bool = false); +SLICE_API std::string returnTypeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0, bool = false); +SLICE_API std::string inputTypeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0, bool = false); +SLICE_API std::string outputTypeToString(const TypePtr&, bool, const StringList& = StringList(), int = 0, bool = false); +SLICE_API std::string operationModeToString(Operation::Mode, bool cpp11 = false); SLICE_API std::string opFormatTypeToString(const OperationPtr&); SLICE_API std::string fixKwd(const std::string&); @@ -51,11 +53,13 @@ SLICE_API void writeMarshalUnmarshalCode(::IceUtilInternal::Output&, const TypeP SLICE_API void writeMarshalCode(::IceUtilInternal::Output&, const ParamDeclList&, const OperationPtr&, bool, int = 0); SLICE_API void writeUnmarshalCode(::IceUtilInternal::Output&, const ParamDeclList&, const OperationPtr&, bool, int = 0); -SLICE_API void writeAllocateCode(::IceUtilInternal::Output&, const ParamDeclList&, const OperationPtr&, bool, int = 0); +SLICE_API void writeAllocateCode(::IceUtilInternal::Output&, const ParamDeclList&, const OperationPtr&, bool, int = 0, bool = false); SLICE_API std::string getEndArg(const TypePtr&, const StringList&, const std::string&); SLICE_API void writeEndCode(::IceUtilInternal::Output&, const ParamDeclList&, const OperationPtr&, bool = false); +SLICE_API bool findMetaData(const std::string&, const ClassDeclPtr&, std::string&); +SLICE_API bool findMetaData(const std::string&, const StringList&, std::string&); SLICE_API std::string findMetaData(const StringList&, int = 0); SLICE_API bool inWstringModule(const SequencePtr&); diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index d3b507d790a..b2854910d67 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -344,7 +344,8 @@ public: KindString, KindObject, KindObjectProxy, - KindLocalObject + KindLocalObject, + KindValue }; virtual bool isLocal() const; @@ -478,6 +479,9 @@ public: bool hasOnlyDictionaries(DictionaryList&) const; bool hasClassDecls() const; bool hasClassDefs() const; + bool hasLocalClassDefs() const; + bool hasNonLocalInterfaceDefs() const; + bool hasValueDefs() const; bool hasOnlyClassDecls() const; bool hasAbstractClassDefs() const; bool hasNonLocalDataOnlyClasses() const; |