summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-01-11 22:44:55 +0100
committerJose <jose@zeroc.com>2016-01-11 22:44:55 +0100
commitd159c9f1574a2e768c947ad697a1e1e2205d194c (patch)
tree86e784ac7347c1dfa92304be2a9355a7a535dbcc /cpp/include
parentAdd ICE_RESET_EXCEPTION macro to simplify C++ builds (diff)
downloadice-d159c9f1574a2e768c947ad697a1e1e2205d194c.tar.bz2
ice-d159c9f1574a2e768c947ad697a1e1e2205d194c.tar.xz
ice-d159c9f1574a2e768c947ad697a1e1e2205d194c.zip
C++11 Value::ice_clone improvements
Diffstat (limited to 'cpp/include')
-rw-r--r--cpp/include/Ice/InterfaceByValue.h2
-rw-r--r--cpp/include/Ice/SlicedData.h2
-rw-r--r--cpp/include/Ice/Value.h36
-rw-r--r--cpp/include/IceUtil/Config.h2
4 files changed, 35 insertions, 7 deletions
diff --git a/cpp/include/Ice/InterfaceByValue.h b/cpp/include/Ice/InterfaceByValue.h
index 3f042bae2c1..c2be72d3eb9 100644
--- a/cpp/include/Ice/InterfaceByValue.h
+++ b/cpp/include/Ice/InterfaceByValue.h
@@ -19,7 +19,7 @@ namespace Ice
{
template<typename T>
-class InterfaceByValue : public Value
+class InterfaceByValue : public Ice::ValueHelper<Ice::InterfaceByValue<T>, Ice::Value>
{
public:
diff --git a/cpp/include/Ice/SlicedData.h b/cpp/include/Ice/SlicedData.h
index 2956e7431f2..f104ceb15f4 100644
--- a/cpp/include/Ice/SlicedData.h
+++ b/cpp/include/Ice/SlicedData.h
@@ -79,7 +79,7 @@ public:
//
class ICE_API UnknownSlicedObject
#ifdef ICE_CPP11_MAPPING
- : public Value
+ : public ValueHelper<UnknownSlicedObject, Value>
#else
: virtual public Object, private IceInternal::GCObject
#endif
diff --git a/cpp/include/Ice/Value.h b/cpp/include/Ice/Value.h
index 8aba347abbd..9e3d0449bd1 100644
--- a/cpp/include/Ice/Value.h
+++ b/cpp/include/Ice/Value.h
@@ -40,16 +40,44 @@ public:
virtual const std::string& ice_id() const;
static const std::string& ice_staticId();
- virtual ValuePtr ice_clone() const;
+ std::shared_ptr<Value> ice_clone() const;
protected:
-
+
+ virtual std::shared_ptr<Value> cloneImpl() const = 0;
+
virtual void __writeImpl(IceInternal::BasicStream*) const {}
virtual void __readImpl(IceInternal::BasicStream*) {}
};
-ICE_API void ice_writeObject(const OutputStreamPtr&, const ValuePtr&);
-ICE_API void ice_readObject(const InputStreamPtr&, ValuePtr&);
+template<typename T, typename Base> class ValueHelper : public Base
+{
+public:
+
+ using Base::Base;
+
+ ValueHelper() = default;
+
+ std::shared_ptr<T> ice_clone() const
+ {
+ return std::static_pointer_cast<T>(cloneImpl());
+ }
+
+ virtual const std::string& ice_id() const override
+ {
+ return T::ice_staticId();
+ }
+
+protected:
+
+ virtual std::shared_ptr<Value> cloneImpl() const
+ {
+ return std::make_shared<T>(static_cast<const T&>(*this));
+ }
+};
+
+ICE_API void ice_writeObject(const OutputStreamPtr&, const std::shared_ptr<Value>&);
+ICE_API void ice_readObject(const InputStreamPtr&, std::shared_ptr<Value>&);
}
#endif // C++11 mapping end
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index 74033859774..8e75fc73f45 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -291,7 +291,7 @@ typedef long long Int64;
# define ICE_IN(T) const T&
# define ICE_EXCEPTION_GET(T) T.get()
# define ICE_RETHROW_EXCEPTION(T) T->ice_throw()
-# define ICE_RESET_EXCEPTION(T, V) = T.reset(V)
+# define ICE_RESET_EXCEPTION(T,V) T.reset(V)
#endif
#endif