diff --git a/include/fastdds/rtps/builtin/discovery/participant/PDP.h b/include/fastdds/rtps/builtin/discovery/participant/PDP.h index 5515edae779..1722ba0a041 100644 --- a/include/fastdds/rtps/builtin/discovery/participant/PDP.h +++ b/include/fastdds/rtps/builtin/discovery/participant/PDP.h @@ -138,8 +138,15 @@ class PDP */ virtual void announceParticipantState( bool new_change, - bool dispose = false, - WriteParams& wparams = WriteParams::WRITE_PARAM_DEFAULT) = 0; + bool dispose, + WriteParams& wparams) = 0; + + /** + * \c announceParticipantState method without optional output parameter \c wparams . + */ + virtual void announceParticipantState( + bool new_change, + bool dispose = false); //!Stop the RTPSParticipantAnnouncement (only used in tests). virtual void stopParticipantAnnouncement(); diff --git a/include/fastdds/rtps/builtin/discovery/participant/PDPSimple.h b/include/fastdds/rtps/builtin/discovery/participant/PDPSimple.h index 7ad96e2511c..e576a3ba969 100644 --- a/include/fastdds/rtps/builtin/discovery/participant/PDPSimple.h +++ b/include/fastdds/rtps/builtin/discovery/participant/PDPSimple.h @@ -77,12 +77,19 @@ class PDPSimple : public PDP * Force the sending of our local DPD to all remote RTPSParticipants and multicast Locators. * @param new_change If true a new change (with new seqNum) is created and sent; if false the last change is re-sent * @param dispose Sets change kind to NOT_ALIVE_DISPOSED_UNREGISTERED - * @param wparams allows to identify the change + * @param[in, out] wparams allows to identify the change */ void announceParticipantState( bool new_change, - bool dispose = false, - WriteParams& wparams = WriteParams::WRITE_PARAM_DEFAULT) override; + bool dispose, + WriteParams& wparams) override; + + /** + * \c announceParticipantState method without optional output parameter \c wparams . + */ + void announceParticipantState( + bool new_change, + bool dispose = false) override; /** * This method assigns remote endpoints to the builtin endpoints defined in this protocol. It also calls diff --git a/include/fastdds/rtps/common/WriteParams.h b/include/fastdds/rtps/common/WriteParams.h index c3873370bfa..be7d2d66ab0 100644 --- a/include/fastdds/rtps/common/WriteParams.h +++ b/include/fastdds/rtps/common/WriteParams.h @@ -178,6 +178,8 @@ class RTPS_DllAPI WriteParams return *this; } + static WriteParams WRITE_PARAM_DEFAULT; + /** * Default value for methods receiving a WriteParams. * @@ -185,8 +187,14 @@ class RTPS_DllAPI WriteParams * - sample_identity: Invalid SampleIdentity * - related_sample_identity: Invalid SampleIdentity * - source_timestamp: Invalid Time_t + * + * @note This should not return a reference to the static value if this value is meant to be + * read and written from different threads. */ - static WriteParams WRITE_PARAM_DEFAULT; + static WriteParams write_params_default() noexcept + { + return WriteParams(); + } private: diff --git a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp index c7bf9d7c733..3c72f2e0364 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDP.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDP.cpp @@ -448,6 +448,14 @@ bool PDP::enable() return builtin_endpoints_->enable_pdp_readers(mp_RTPSParticipant); } +void PDP::announceParticipantState( + bool new_change, + bool dispose /* = false */) +{ + WriteParams __wp = WriteParams::write_params_default(); + announceParticipantState(new_change, dispose, __wp); +} + void PDP::announceParticipantState( RTPSWriter& writer, WriterHistory& history, diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPClient.h b/src/cpp/rtps/builtin/discovery/participant/PDPClient.h index e7053c3f1e4..4a5d5d7aee4 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPClient.h +++ b/src/cpp/rtps/builtin/discovery/participant/PDPClient.h @@ -105,7 +105,12 @@ class PDPClient : public PDP * @param new_change If true a new change (with new seqNum) is created and sent; * if false the last change is re-sent * @param dispose Sets change kind to NOT_ALIVE_DISPOSED_UNREGISTERED - * @param wparams allows to identify the change + * @param wparams allows to identify the change [unused] + * + * @warning this method uses the static variable reference as it does not use the parameter \c wparams + * and this avoids a creation of an object WriteParams. + * However, if in future versions this method uses this argument, it must change to the function + * \c write_params_default for thread safety reasons. */ void announceParticipantState( bool new_change, diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp b/src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp index 0a4ad9b98ba..c5a30905e6d 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPServer.hpp @@ -108,7 +108,12 @@ class PDPServer : public fastrtps::rtps::PDP * Force the sending of our local PDP to all servers * @param new_change If true a new change (with new seqNum) is created and sent; if false the last change is re-sent * @param dispose Sets change kind to NOT_ALIVE_DISPOSED_UNREGISTERED - * @param wparams allows to identify the change + * @param wparams allows to identify the change [unused] + * + * @warning this method uses the static variable reference as it does not use the parameter \c wparams + * and this avoids a creation of an object WriteParams. + * However, if in future versions this method uses this argument, it must change to the function + * \c write_params_default for thread safety reasons. */ void announceParticipantState( bool new_change, diff --git a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp index 3579ceb0fc2..8868acb4298 100644 --- a/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp +++ b/src/cpp/rtps/builtin/discovery/participant/PDPSimple.cpp @@ -223,6 +223,14 @@ bool PDPSimple::updateInfoMatchesEDP() return dynamic_cast(mp_EDP) != nullptr; } +void PDPSimple::announceParticipantState( + bool new_change, + bool dispose /* = false */) +{ + WriteParams __wp = WriteParams::write_params_default(); + announceParticipantState(new_change, dispose, __wp); +} + void PDPSimple::announceParticipantState( bool new_change, bool dispose,