From d6541f161be541f9c8224e41e132ab7252d07342 Mon Sep 17 00:00:00 2001 From: Jeff Ithier Date: Wed, 13 Nov 2024 15:05:04 +0100 Subject: [PATCH] [#500] Use iox::vector instead of std::array --- iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp | 5 ++--- iceoryx2-ffi/cxx/src/unique_port_id.cpp | 8 ++++---- iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp index 865b4156f..616bdfffe 100644 --- a/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp +++ b/iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp @@ -14,14 +14,13 @@ #define IOX2_UNIQUE_PORT_ID_HPP #include "iox/optional.hpp" +#include "iox/vector.hpp" #include "iox2/internal/iceoryx2.hpp" -#include - namespace iox2 { constexpr uint64_t UNIQUE_PORT_ID_LENGTH = 128; -using RawIdType = std::array; +using RawIdType = iox::vector; /// The system-wide unique id of a [`Publisher`]. class UniquePublisherId { diff --git a/iceoryx2-ffi/cxx/src/unique_port_id.cpp b/iceoryx2-ffi/cxx/src/unique_port_id.cpp index 4055f53f7..25c3041a2 100644 --- a/iceoryx2-ffi/cxx/src/unique_port_id.cpp +++ b/iceoryx2-ffi/cxx/src/unique_port_id.cpp @@ -45,7 +45,7 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle) auto UniquePublisherId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { - RawIdType bytes {}; + RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_publisher_id_value(m_handle, bytes.data()); m_raw_id.emplace(std::move(bytes)); } @@ -92,7 +92,7 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle) auto UniqueSubscriberId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { - RawIdType bytes {}; + RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_subscriber_id_value(m_handle, bytes.data()); m_raw_id.emplace(std::move(bytes)); } @@ -138,7 +138,7 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle) auto UniqueNotifierId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { - RawIdType bytes {}; + RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_notifier_id_value(m_handle, bytes.data()); m_raw_id.emplace(std::move(bytes)); } @@ -184,7 +184,7 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle) auto UniqueListenerId::bytes() -> iox::optional& { if (!m_raw_id.has_value() && m_handle != nullptr) { - RawIdType bytes {}; + RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 }; iox2_unique_listener_id_value(m_handle, bytes.data()); m_raw_id.emplace(std::move(bytes)); } diff --git a/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp b/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp index 89e86cd4c..8a318d8ff 100644 --- a/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp +++ b/iceoryx2-ffi/cxx/tests/src/unique_port_id_tests.cpp @@ -66,13 +66,13 @@ struct UniquePortIdTest : public ::testing::Test { TYPED_TEST_SUITE(UniquePortIdTest, iox2_testing::ServiceTypes); TYPED_TEST(UniquePortIdTest, unique_port_id_value) { - auto null_id = std::array {}; + auto null_id = iox::vector { iox2::UNIQUE_PORT_ID_LENGTH, 0 }; auto unique_publisher_id = this->publisher_1.id(); ASSERT_TRUE(unique_publisher_id.bytes().has_value()); ASSERT_NE(unique_publisher_id.bytes().value(), null_id); - auto unique_subscriber_id = this->publisher_1.id(); + auto unique_subscriber_id = this->subscriber_1.id(); ASSERT_TRUE(unique_subscriber_id.bytes().has_value()); ASSERT_NE(unique_subscriber_id.bytes().value(), null_id);