From 6d1c1bf32d2b9d64bd392e25e291224807e0a51f Mon Sep 17 00:00:00 2001 From: jparisu Date: Thu, 14 Jul 2022 10:18:54 +0200 Subject: [PATCH 1/4] Add API to createRTPSWriter with a custom change pool Signed-off-by: jparisu --- include/fastdds/rtps/RTPSDomain.h | 21 +++++++++++++++++++++ src/cpp/rtps/RTPSDomain.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/fastdds/rtps/RTPSDomain.h b/include/fastdds/rtps/RTPSDomain.h index 05a206f47f5..14a83c6b8c5 100644 --- a/include/fastdds/rtps/RTPSDomain.h +++ b/include/fastdds/rtps/RTPSDomain.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace eprosima { namespace fastrtps { @@ -134,6 +135,26 @@ class RTPSDomain WriterHistory* hist, WriterListener* listen = nullptr); + /** + * Create a RTPSWriter in a participant using a custom payload pool. + * @param p Pointer to the RTPSParticipant. + * @param watt Writer Attributes. + * @param payload_pool Shared pointer to the IPayloadPool + * @param hist Pointer to the WriterHistory. + * @param listen Pointer to the WriterListener. + * @return Pointer to the created RTPSWriter. + * + * \warning The returned pointer is invalidated after a call to removeRTPSWriter() or stopAll(), + * so its use may result in undefined behaviour. + */ + RTPS_DllAPI static RTPSWriter* createRTPSWriter( + RTPSParticipant* p, + WriterAttributes& watt, + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool, + WriterHistory* hist, + WriterListener* listen = nullptr); + /** * Create a RTPSWriter in a participant. * @param p Pointer to the RTPSParticipant. diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index f2108080f95..65b204c2312 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -314,6 +314,30 @@ RTPSWriter* RTPSDomain::createRTPSWriter( return nullptr; } +RTPSWriter* RTPSDomain::createRTPSWriter( + RTPSParticipant* p, + WriterAttributes& watt, + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool, + WriterHistory* hist, + WriterListener* listen) +{ + RTPSParticipantImpl* impl = RTPSDomainImpl::find_local_participant(p->getGuid()); + if (impl) + { + RTPSWriter* ret_val = nullptr; + if (impl->create_writer(&ret_val, watt, payload_pool, change_pool, hist, listen)) + { + return ret_val; + } + { + return ret_val; + } + } + + return nullptr; +} + RTPSWriter* RTPSDomain::createRTPSWriter( RTPSParticipant* p, const EntityId_t& entity_id, From ffa1cebeb547574961d2b3e9927148f128dd0432 Mon Sep 17 00:00:00 2001 From: jparisu Date: Mon, 18 Jul 2022 15:24:22 +0200 Subject: [PATCH 2/4] apply suggestions Signed-off-by: jparisu --- include/fastdds/rtps/RTPSDomain.h | 1 + src/cpp/rtps/RTPSDomain.cpp | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/fastdds/rtps/RTPSDomain.h b/include/fastdds/rtps/RTPSDomain.h index 14a83c6b8c5..fd22519bcf9 100644 --- a/include/fastdds/rtps/RTPSDomain.h +++ b/include/fastdds/rtps/RTPSDomain.h @@ -140,6 +140,7 @@ class RTPSDomain * @param p Pointer to the RTPSParticipant. * @param watt Writer Attributes. * @param payload_pool Shared pointer to the IPayloadPool + * @param change_pool Shared pointer to the IChangePool * @param hist Pointer to the WriterHistory. * @param listen Pointer to the WriterListener. * @return Pointer to the created RTPSWriter. diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index 65b204c2312..a201c7c6d31 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -330,9 +330,6 @@ RTPSWriter* RTPSDomain::createRTPSWriter( { return ret_val; } - { - return ret_val; - } } return nullptr; From 053d769f57a4cb8387cfdfd874e2d8bb74e28d81 Mon Sep 17 00:00:00 2001 From: jparisu Date: Fri, 29 Jul 2022 10:01:57 +0200 Subject: [PATCH 3/4] extend API to entity Id Signed-off-by: jparisu --- include/fastdds/rtps/RTPSDomain.h | 23 +++++++++++++++++++++++ src/cpp/rtps/RTPSDomain.cpp | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/fastdds/rtps/RTPSDomain.h b/include/fastdds/rtps/RTPSDomain.h index fd22519bcf9..c510222f86d 100644 --- a/include/fastdds/rtps/RTPSDomain.h +++ b/include/fastdds/rtps/RTPSDomain.h @@ -156,6 +156,29 @@ class RTPSDomain WriterHistory* hist, WriterListener* listen = nullptr); + /** + * Create a RTPSWriter in a participant using a custom payload pool. + * @param p Pointer to the RTPSParticipant. + * @param entity_id Specific entity id to use for the created writer. + * @param watt Writer Attributes. + * @param payload_pool Shared pointer to the IPayloadPool + * @param change_pool Shared pointer to the IChangePool + * @param hist Pointer to the WriterHistory. + * @param listen Pointer to the WriterListener. + * @return Pointer to the created RTPSWriter. + * + * \warning The returned pointer is invalidated after a call to removeRTPSWriter() or stopAll(), + * so its use may result in undefined behaviour. + */ + RTPS_DllAPI static RTPSWriter* createRTPSWriter( + RTPSParticipant* p, + const EntityId_t& entity_id, + WriterAttributes& watt, + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool, + WriterHistory* hist, + WriterListener* listen = nullptr); + /** * Create a RTPSWriter in a participant. * @param p Pointer to the RTPSParticipant. diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index a201c7c6d31..9bcf0a66e31 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -335,6 +335,28 @@ RTPSWriter* RTPSDomain::createRTPSWriter( return nullptr; } +RTPSWriter* RTPSDomain::createRTPSWriter( + RTPSParticipant* p, + const EntityId_t& entity_id, + WriterAttributes& watt, + const std::shared_ptr& payload_pool, + const std::shared_ptr& change_pool, + WriterHistory* hist, + WriterListener* listen) +{ + RTPSParticipantImpl* impl = RTPSDomainImpl::find_local_participant(p->getGuid()); + if (impl) + { + RTPSWriter* ret_val = nullptr; + if (impl->create_writer(&ret_val, watt, payload_pool, change_pool, hist, listen, entity_id)) + { + return ret_val; + } + } + + return nullptr; +} + RTPSWriter* RTPSDomain::createRTPSWriter( RTPSParticipant* p, const EntityId_t& entity_id, From be4dd02b985a9c8fbccfb282adbeedd2ec0dc92d Mon Sep 17 00:00:00 2001 From: jparisu Date: Fri, 29 Jul 2022 11:02:45 +0200 Subject: [PATCH 4/4] apply suggestion Signed-off-by: jparisu --- src/cpp/rtps/RTPSDomain.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index 9bcf0a66e31..a1647a79cba 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -344,17 +344,7 @@ RTPSWriter* RTPSDomain::createRTPSWriter( WriterHistory* hist, WriterListener* listen) { - RTPSParticipantImpl* impl = RTPSDomainImpl::find_local_participant(p->getGuid()); - if (impl) - { - RTPSWriter* ret_val = nullptr; - if (impl->create_writer(&ret_val, watt, payload_pool, change_pool, hist, listen, entity_id)) - { - return ret_val; - } - } - - return nullptr; + return RTPSDomainImpl::create_rtps_writer(p, entity_id, watt, payload_pool, change_pool, hist, listen); } RTPSWriter* RTPSDomain::createRTPSWriter(