From ed151797ba953abe211461b45fcc197f39b0b3c2 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Tue, 10 Dec 2024 14:14:59 -0500 Subject: [PATCH] Remove class-by-value support in DataStorm --- cpp/include/DataStorm/DataStorm.h | 3 +- cpp/include/DataStorm/InternalT.h | 5 ++- cpp/include/DataStorm/Types.h | 52 ----------------------------- cpp/test/DataStorm/types/Reader.cpp | 7 ---- cpp/test/DataStorm/types/Writer.cpp | 10 ------ 5 files changed, 3 insertions(+), 74 deletions(-) diff --git a/cpp/include/DataStorm/DataStorm.h b/cpp/include/DataStorm/DataStorm.h index 3e578b5ef20..5b1205bd4c5 100644 --- a/cpp/include/DataStorm/DataStorm.h +++ b/cpp/include/DataStorm/DataStorm.h @@ -1997,8 +1997,7 @@ namespace DataStorm Value value; if (previous) { - value = Cloner::clone( - std::static_pointer_cast>(previous)->getValue()); + value = std::static_pointer_cast>(previous)->getValue(); } updater(value, Decoder::decode(communicator, next->getEncodedValue())); std::static_pointer_cast>(next)->setValue(std::move(value)); diff --git a/cpp/include/DataStorm/InternalT.h b/cpp/include/DataStorm/InternalT.h index f176e498210..444894b2b61 100644 --- a/cpp/include/DataStorm/InternalT.h +++ b/cpp/include/DataStorm/InternalT.h @@ -355,12 +355,11 @@ namespace DataStormI { if (sample) { - _value = DataStorm::Cloner::clone( - std::static_pointer_cast>(sample)->getValue()); + _value = std::static_pointer_cast>(sample)->getValue(); } else { - _value = Value(); + _value = Value{}; } _hasValue = true; } diff --git a/cpp/include/DataStorm/Types.h b/cpp/include/DataStorm/Types.h index 2b8fec0e139..1cf30413ee4 100644 --- a/cpp/include/DataStorm/Types.h +++ b/cpp/include/DataStorm/Types.h @@ -240,58 +240,6 @@ namespace DataStorm static T decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& value) noexcept; }; - /** - * The Cloner template provides a method to clone user types. - * - * The cloner template can be specialized to provide cloning for types that require special cloning. By - * default, the template uses plain C++ copy. - * - * @headerfile DataStorm/DataStorm.h - */ - template struct Cloner - { - /** - * Clone the given value. This helper is used when processing partial update to clone the previous value - * and compute the new value with the partial update. The default implementation performs a plain C++ copy - * with the copy constructor. - * - * @param value The value to encode - * @return The cloned value - */ - static T clone(const T& value) noexcept { return value; } - }; - - /** - * Encoder template specialization to encode Ice::Value instances. - **/ - template struct Encoder::value>::type> - { - static Ice::ByteSeq encode(const Ice::CommunicatorPtr& communicator, const T& value) noexcept - { - return Encoder>::encode(communicator, std::make_shared(value)); - } - }; - - /** - * Decoder template specialization to decode Ice::Value instances. - **/ - template struct Decoder::value>::type> - { - static T decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) noexcept - { - return *Decoder>::decode(communicator, data); - } - }; - - /** - * Cloner template specialization to clone shared Ice values using ice_clone. - */ - template - struct Cloner, typename std::enable_if::value>::type> - { - static std::shared_ptr clone(const std::shared_ptr& value) noexcept { return value->ice_clone(); } - }; - /** * Encoder template implementation */ diff --git a/cpp/test/DataStorm/types/Reader.cpp b/cpp/test/DataStorm/types/Reader.cpp index 1a72b3dda6c..b69d56dd6a7 100644 --- a/cpp/test/DataStorm/types/Reader.cpp +++ b/cpp/test/DataStorm/types/Reader.cpp @@ -110,13 +110,6 @@ void ::Reader::run(int argc, char* argv[]) map{{{"firstName", "lastName", 10}, "v2"}, {{"fn", "ln", 12}, "v3"}}, map{{{"firstName", "lastName", 10}, "v4"}, {{"fn", "ln", 12}, "v5"}}); - /* - testReader(Topic(node, "stringclassbyvalue"), - map { { "k1", Extended("v1", 8) }, - { "k2", Extended("v2", 8) } }, - map { { "k1", Extended("v1", 10) }, - { "k2", Extended("v2", 10) } }); - */ testReader( Topic>(node, "stringclassbyref"), map>{{"k1", make_shared("v1")}, {"k2", make_shared("v2")}}, diff --git a/cpp/test/DataStorm/types/Writer.cpp b/cpp/test/DataStorm/types/Writer.cpp index 2074b6d9638..ae17ffa23ab 100644 --- a/cpp/test/DataStorm/types/Writer.cpp +++ b/cpp/test/DataStorm/types/Writer.cpp @@ -107,16 +107,6 @@ main(int argc, char* argv[]) map{{{"firstName", "lastName", 10}, "v4"}, {{"fn", "ln", 12}, "v5"}}); cout << "ok" << endl; - /* - cout << "testing string/class by value... " << flush; - testWriter(Topic(node, "stringclassbyvalue"), - map { { string("k1"), Extended("v1", 8) }, - { string("k2"), Extended("v2", 8) } }, - map { { "k1", Extended("v1", 10) }, - { "k2", Extended("v2", 10) } }); - cout << "ok" << endl; - */ - cout << "testing string/class by ref... " << flush; testWriter( Topic>(node, "stringclassbyref"),