diff --git a/README.md b/README.md index a0895d20..25e8b819 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,6 @@ [![Fast DDS Python Ubuntu CI (nightly)](https://github.com/eProsima/Fast-DDS-Python/actions/workflows/nightly-ubuntu-ci.yml/badge.svg)](https://github.com/eProsima/Fast-DDS-Python/actions/workflows/nightly-ubuntu-ci.yml) [![Fast DDS Python Windows CI (nightly)](https://github.com/eProsima/Fast-DDS-Python/actions/workflows/nightly-windows-ci.yml/badge.svg)](https://github.com/eProsima/Fast-DDS-Python/actions/workflows/nightly-windows-ci.yml) - -> [!WARNING] -> In preparation for v2.0.0 (bindings for Fast DDS v3.0.0), Fast DDS Python's master branch is undergoing major changes entailing **API breaks**. -> Until Fast DDS Python v2.0.0 is released, it is strongly advisable to use the latest stable version, [v1.4.1](https://github.com/eProsima/Fast-DDS-python/tree/v1.4.1). - *eProsima Fast DDS Python* is a Python binding for the [*eProsima Fast DDS*](https://github.com/eProsima/Fast-DDS) C++ library. This is a work in progress, but ultimately the goal is having the complete *Fast DDS* API available in Python. Two packages are available in this repository: the proper Python binding, `fastdds_python`, and the examples, `fastdds_python_examples`. diff --git a/fastdds_python/test/types/test_completeCdrAux.ipp b/fastdds_python/test/types/test_completeCdrAux.ipp index 79915c10..3d86a41c 100644 --- a/fastdds_python/test/types/test_completeCdrAux.ipp +++ b/fastdds_python/test/types/test_completeCdrAux.ipp @@ -217,8 +217,43 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const StructType& data) { + extern void serialize_key( + Cdr& scdr, + const eprosima::test2::StructType2& data); + + static_cast(scdr); static_cast(data); + scdr << data.char_field(); + + scdr << data.uint8_field(); + + scdr << data.int16_field(); + + scdr << data.uint16_field(); + + scdr << data.int32_field(); + + scdr << data.uint32_field(); + + scdr << data.int64_field(); + + scdr << data.uint64_field(); + + scdr << data.float_field(); + + scdr << data.double_field(); + + scdr << data.bool_field(); + + scdr << data.string_field(); + + scdr << data.enum_field(); + + scdr << data.enum2_field(); + + serialize_key(scdr, data.included_module_struct()); + } @@ -863,8 +898,262 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const CompleteTestType& data) { + extern void serialize_key( + Cdr& scdr, + const StructType& data); + + + + + + + + + + + + + + + + extern void serialize_key( + Cdr& scdr, + const StructType& data); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + static_cast(scdr); static_cast(data); + scdr << data.char_field(); + + scdr << data.uint8_field(); + + scdr << data.int16_field(); + + scdr << data.uint16_field(); + + scdr << data.int32_field(); + + scdr << data.uint32_field(); + + scdr << data.int64_field(); + + scdr << data.uint64_field(); + + scdr << data.float_field(); + + scdr << data.double_field(); + + scdr << data.bool_field(); + + scdr << data.string_field(); + + scdr << data.enum_field(); + + scdr << data.enum2_field(); + + serialize_key(scdr, data.struct_field()); + + if (data.char_opt_field().has_value()) + { + scdr << data.char_opt_field().value(); + } + + if (data.uint8_opt_field().has_value()) + { + scdr << data.uint8_opt_field().value(); + } + + if (data.int16_opt_field().has_value()) + { + scdr << data.int16_opt_field().value(); + } + + if (data.uint16_opt_field().has_value()) + { + scdr << data.uint16_opt_field().value(); + } + + if (data.int32_opt_field().has_value()) + { + scdr << data.int32_opt_field().value(); + } + + if (data.uint32_opt_field().has_value()) + { + scdr << data.uint32_opt_field().value(); + } + + if (data.int64_opt_field().has_value()) + { + scdr << data.int64_opt_field().value(); + } + + if (data.uint64_opt_field().has_value()) + { + scdr << data.uint64_opt_field().value(); + } + + if (data.float_opt_field().has_value()) + { + scdr << data.float_opt_field().value(); + } + + if (data.double_opt_field().has_value()) + { + scdr << data.double_opt_field().value(); + } + + if (data.bool_opt_field().has_value()) + { + scdr << data.bool_opt_field().value(); + } + + if (data.string_opt_field().has_value()) + { + scdr << data.string_opt_field().value(); + } + + if (data.enum_opt_field().has_value()) + { + scdr << data.enum_opt_field().value(); + } + + if (data.enum2_opt_field().has_value()) + { + scdr << data.enum2_opt_field().value(); + } + + if (data.struct_opt_field().has_value()) + { + serialize_key(scdr, data.struct_opt_field().value()); + } + + scdr << data.array_char_field(); + + scdr << data.array_uint8_field(); + + scdr << data.array_int16_field(); + + scdr << data.array_uint16_field(); + + scdr << data.array_int32_field(); + + scdr << data.array_uint32_field(); + + scdr << data.array_int64_field(); + + scdr << data.array_uint64_field(); + + scdr << data.array_float_field(); + + scdr << data.array_double_field(); + + scdr << data.array_bool_field(); + + scdr << data.array_enum_field(); + + scdr << data.array_enum2_field(); + + scdr << data.array_struct_field(); + + scdr << data.bounded_sequence_char_field(); + + scdr << data.bounded_sequence_uint8_field(); + + scdr << data.bounded_sequence_int16_field(); + + scdr << data.bounded_sequence_uint16_field(); + + scdr << data.bounded_sequence_int32_field(); + + scdr << data.bounded_sequence_uint32_field(); + + scdr << data.bounded_sequence_int64_field(); + + scdr << data.bounded_sequence_uint64_field(); + + scdr << data.bounded_sequence_float_field(); + + scdr << data.bounded_sequence_double_field(); + + scdr << data.bounded_sequence_bool_field(); + + scdr << data.bounded_sequence_enum_field(); + + scdr << data.bounded_sequence_enum2_field(); + + scdr << data.bounded_sequence_struct_field(); + + scdr << data.unbounded_sequence_char_field(); + + scdr << data.unbounded_sequence_uint8_field(); + + scdr << data.unbounded_sequence_int16_field(); + + scdr << data.unbounded_sequence_uint16_field(); + + scdr << data.unbounded_sequence_int32_field(); + + scdr << data.unbounded_sequence_uint32_field(); + + scdr << data.unbounded_sequence_int64_field(); + + scdr << data.unbounded_sequence_uint64_field(); + + scdr << data.unbounded_sequence_float_field(); + + scdr << data.unbounded_sequence_double_field(); + + scdr << data.unbounded_sequence_bool_field(); + + scdr << data.unbounded_sequence_enum_field(); + + scdr << data.unbounded_sequence_enum2_field(); + + scdr << data.unbounded_sequence_struct_field(); + } @@ -1515,9 +1804,74 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const KeyedCompleteTestType& data) { + extern void serialize_key( + Cdr& scdr, + const StructType& data); + + + + + + + + + + + + + + + + extern void serialize_key( + Cdr& scdr, + const StructType& data); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + static_cast(scdr); static_cast(data); - scdr << data.id(); + scdr << data.id(); diff --git a/fastdds_python/test/types/test_completePubSubTypes.cxx b/fastdds_python/test/types/test_completePubSubTypes.cxx index 4ff52c5e..3801713e 100644 --- a/fastdds_python/test/types/test_completePubSubTypes.cxx +++ b/fastdds_python/test/types/test_completePubSubTypes.cxx @@ -184,7 +184,8 @@ bool StructTypePubSubType::compute_key( StructType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || StructType_max_key_cdr_typesize > 16) { @@ -366,7 +367,8 @@ bool CompleteTestTypePubSubType::compute_key( CompleteTestType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || CompleteTestType_max_key_cdr_typesize > 16) { @@ -546,7 +548,8 @@ bool KeyedCompleteTestTypePubSubType::compute_key( KeyedCompleteTestType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || KeyedCompleteTestType_max_key_cdr_typesize > 16) { diff --git a/fastdds_python/test/types/test_included_modulesCdrAux.ipp b/fastdds_python/test/types/test_included_modulesCdrAux.ipp index 663352f6..e362129b 100644 --- a/fastdds_python/test/types/test_included_modulesCdrAux.ipp +++ b/fastdds_python/test/types/test_included_modulesCdrAux.ipp @@ -219,6 +219,34 @@ void serialize_key( static_cast(scdr); static_cast(data); + scdr << data.char_field(); + + scdr << data.uint8_field(); + + scdr << data.int16_field(); + + scdr << data.uint16_field(); + + scdr << data.int32_field(); + + scdr << data.uint32_field(); + + scdr << data.int64_field(); + + scdr << data.uint64_field(); + + scdr << data.float_field(); + + scdr << data.double_field(); + + scdr << data.bool_field(); + + scdr << data.string_field(); + + scdr << data.enum_field(); + + scdr << data.enum2_field(); + } diff --git a/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx b/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx index ce24f19a..a7559e7e 100644 --- a/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx +++ b/fastdds_python/test/types/test_included_modulesPubSubTypes.cxx @@ -186,7 +186,8 @@ namespace eprosima { eprosima_test2_StructType2_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || eprosima_test2_StructType2_max_key_cdr_typesize > 16) { diff --git a/fastdds_python/test/types/test_modulesCdrAux.ipp b/fastdds_python/test/types/test_modulesCdrAux.ipp index 2d6f8790..1024feac 100644 --- a/fastdds_python/test/types/test_modulesCdrAux.ipp +++ b/fastdds_python/test/types/test_modulesCdrAux.ipp @@ -219,6 +219,34 @@ void serialize_key( static_cast(scdr); static_cast(data); + scdr << data.char_field(); + + scdr << data.uint8_field(); + + scdr << data.int16_field(); + + scdr << data.uint16_field(); + + scdr << data.int32_field(); + + scdr << data.uint32_field(); + + scdr << data.int64_field(); + + scdr << data.uint64_field(); + + scdr << data.float_field(); + + scdr << data.double_field(); + + scdr << data.bool_field(); + + scdr << data.string_field(); + + scdr << data.enum_field(); + + scdr << data.enum2_field(); + } @@ -870,9 +898,262 @@ void serialize_key( const eprosima::test::CompleteTestType& data) { using namespace eprosima::test; + extern void serialize_key( + Cdr& scdr, + const eprosima::test::StructType& data); + + + + + + + + + + + + + + + + extern void serialize_key( + Cdr& scdr, + const eprosima::test::StructType& data); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + static_cast(scdr); static_cast(data); + scdr << data.char_field(); + + scdr << data.uint8_field(); + + scdr << data.int16_field(); + + scdr << data.uint16_field(); + + scdr << data.int32_field(); + + scdr << data.uint32_field(); + + scdr << data.int64_field(); + + scdr << data.uint64_field(); + + scdr << data.float_field(); + + scdr << data.double_field(); + + scdr << data.bool_field(); + + scdr << data.string_field(); + + scdr << data.enum_field(); + + scdr << data.enum2_field(); + + serialize_key(scdr, data.struct_field()); + + if (data.char_opt_field().has_value()) + { + scdr << data.char_opt_field().value(); + } + + if (data.uint8_opt_field().has_value()) + { + scdr << data.uint8_opt_field().value(); + } + + if (data.int16_opt_field().has_value()) + { + scdr << data.int16_opt_field().value(); + } + + if (data.uint16_opt_field().has_value()) + { + scdr << data.uint16_opt_field().value(); + } + + if (data.int32_opt_field().has_value()) + { + scdr << data.int32_opt_field().value(); + } + + if (data.uint32_opt_field().has_value()) + { + scdr << data.uint32_opt_field().value(); + } + + if (data.int64_opt_field().has_value()) + { + scdr << data.int64_opt_field().value(); + } + + if (data.uint64_opt_field().has_value()) + { + scdr << data.uint64_opt_field().value(); + } + + if (data.float_opt_field().has_value()) + { + scdr << data.float_opt_field().value(); + } + + if (data.double_opt_field().has_value()) + { + scdr << data.double_opt_field().value(); + } + + if (data.bool_opt_field().has_value()) + { + scdr << data.bool_opt_field().value(); + } + + if (data.string_opt_field().has_value()) + { + scdr << data.string_opt_field().value(); + } + + if (data.enum_opt_field().has_value()) + { + scdr << data.enum_opt_field().value(); + } + + if (data.enum2_opt_field().has_value()) + { + scdr << data.enum2_opt_field().value(); + } + + if (data.struct_opt_field().has_value()) + { + serialize_key(scdr, data.struct_opt_field().value()); + } + + scdr << data.array_char_field(); + + scdr << data.array_uint8_field(); + + scdr << data.array_int16_field(); + + scdr << data.array_uint16_field(); + + scdr << data.array_int32_field(); + + scdr << data.array_uint32_field(); + + scdr << data.array_int64_field(); + + scdr << data.array_uint64_field(); + + scdr << data.array_float_field(); + + scdr << data.array_double_field(); + + scdr << data.array_bool_field(); + + scdr << data.array_enum_field(); + + scdr << data.array_enum2_field(); + + scdr << data.array_struct_field(); + + scdr << data.bounded_sequence_char_field(); + + scdr << data.bounded_sequence_uint8_field(); + + scdr << data.bounded_sequence_int16_field(); + + scdr << data.bounded_sequence_uint16_field(); + + scdr << data.bounded_sequence_int32_field(); + + scdr << data.bounded_sequence_uint32_field(); + + scdr << data.bounded_sequence_int64_field(); + + scdr << data.bounded_sequence_uint64_field(); + + scdr << data.bounded_sequence_float_field(); + + scdr << data.bounded_sequence_double_field(); + + scdr << data.bounded_sequence_bool_field(); + + scdr << data.bounded_sequence_enum_field(); + + scdr << data.bounded_sequence_enum2_field(); + + scdr << data.bounded_sequence_struct_field(); + + scdr << data.unbounded_sequence_char_field(); + + scdr << data.unbounded_sequence_uint8_field(); + + scdr << data.unbounded_sequence_int16_field(); + + scdr << data.unbounded_sequence_uint16_field(); + + scdr << data.unbounded_sequence_int32_field(); + + scdr << data.unbounded_sequence_uint32_field(); + + scdr << data.unbounded_sequence_int64_field(); + + scdr << data.unbounded_sequence_uint64_field(); + + scdr << data.unbounded_sequence_float_field(); + + scdr << data.unbounded_sequence_double_field(); + + scdr << data.unbounded_sequence_bool_field(); + + scdr << data.unbounded_sequence_enum_field(); + + scdr << data.unbounded_sequence_enum2_field(); + + scdr << data.unbounded_sequence_struct_field(); + } @@ -1530,10 +1811,74 @@ void serialize_key( const eprosima::test::KeyedCompleteTestType& data) { using namespace eprosima::test; + extern void serialize_key( + Cdr& scdr, + const eprosima::test::StructType& data); + + + + + + + + + + + + + + + + extern void serialize_key( + Cdr& scdr, + const eprosima::test::StructType& data); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + static_cast(scdr); static_cast(data); - scdr << data.id(); + scdr << data.id(); diff --git a/fastdds_python/test/types/test_modulesPubSubTypes.cxx b/fastdds_python/test/types/test_modulesPubSubTypes.cxx index e7c7bed6..297004fb 100644 --- a/fastdds_python/test/types/test_modulesPubSubTypes.cxx +++ b/fastdds_python/test/types/test_modulesPubSubTypes.cxx @@ -186,7 +186,8 @@ namespace eprosima { eprosima_test_StructType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || eprosima_test_StructType_max_key_cdr_typesize > 16) { @@ -368,7 +369,8 @@ namespace eprosima { eprosima_test_CompleteTestType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || eprosima_test_CompleteTestType_max_key_cdr_typesize > 16) { @@ -548,7 +550,8 @@ namespace eprosima { eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || eprosima_test_KeyedCompleteTestType_max_key_cdr_typesize > 16) { diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.ipp b/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.ipp index 19316df7..30f135e3 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.ipp +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldCdrAux.ipp @@ -113,8 +113,13 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data) { + static_cast(scdr); static_cast(data); + scdr << data.index(); + + scdr << data.message(); + } diff --git a/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx b/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx index f9a6f740..865410fd 100644 --- a/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx +++ b/fastdds_python_examples/HelloWorldExample/HelloWorldPubSubTypes.cxx @@ -184,7 +184,8 @@ bool HelloWorldPubSubType::compute_key( HelloWorld_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2); + ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2); eprosima::fastcdr::serialize_key(ser, *p_type); if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) {