diff --git a/include/fastdds/rtps/RTPSDomain.h b/include/fastdds/rtps/RTPSDomain.h index 05a206f47f5..c510222f86d 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,50 @@ 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 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, + 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 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 f2108080f95..a1647a79cba 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -314,6 +314,39 @@ 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 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) +{ + return RTPSDomainImpl::create_rtps_writer(p, entity_id, watt, payload_pool, change_pool, hist, listen); +} + RTPSWriter* RTPSDomain::createRTPSWriter( RTPSParticipant* p, const EntityId_t& entity_id,