Skip to content

Commit

Permalink
Refs #21313: Add RTPSParticipantImplt::type_propagation API to group …
Browse files Browse the repository at this point in the history
…code

Signed-off-by: eduponz <eduardoponz@eprosima.com>
  • Loading branch information
EduPonz committed Jul 19, 2024
1 parent 13e7778 commit c8cb4da
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ bool TypeLookupManager::init(
protocols->mp_participantImpl->getRTPSParticipantAttributes().allocation.locators.max_unicast_locators,
protocols->mp_participantImpl->getRTPSParticipantAttributes().allocation.locators.max_multicast_locators);

auto properties = participant_->getAttributes().properties;
type_propagation_ = utils::to_type_propagation(properties);
type_propagation_ = participant_->type_propagation();

// Check if ReaderProxyData and WriterProxyData objects were created successfully
if (temp_reader_proxy_data_ && temp_writer_proxy_data_)
Expand Down
3 changes: 1 addition & 2 deletions src/cpp/rtps/builtin/BuiltinProtocols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ bool BuiltinProtocols::initBuiltinProtocols(
}

// TypeLookupManager
auto properties = p_part->getAttributes().properties;
auto type_propagation = dds::utils::to_type_propagation(properties);
auto type_propagation = p_part->type_propagation();
bool should_create_typelookup =
(dds::utils::TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) ||
(dds::utils::TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation);
Expand Down
8 changes: 2 additions & 6 deletions src/cpp/rtps/builtin/discovery/endpoint/EDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,10 @@ bool EDP::newLocalReaderProxyData(
rpd->typeName(att.getTopicDataType());
rpd->topicKind(att.getTopicKind());

using dds::utils::to_type_propagation;
using dds::utils::TypePropagation;
using dds::xtypes::TypeInformationParameter;

auto properties = mp_RTPSParticipant->getAttributes().properties;
auto type_propagation = to_type_propagation(properties);
auto type_propagation = mp_RTPSParticipant->type_propagation();
assert(TypePropagation::TYPEPROPAGATION_UNKNOWN != type_propagation);

if (att.type_information.assigned())
Expand Down Expand Up @@ -277,12 +275,10 @@ bool EDP::newLocalWriterProxyData(
wpd->typeName(att.getTopicDataType());
wpd->topicKind(att.getTopicKind());

using dds::utils::to_type_propagation;
using dds::utils::TypePropagation;
using dds::xtypes::TypeInformationParameter;

auto properties = mp_RTPSParticipant->getAttributes().properties;
auto type_propagation = to_type_propagation(properties);
auto type_propagation = mp_RTPSParticipant->type_propagation();
assert(TypePropagation::TYPEPROPAGATION_UNKNOWN != type_propagation);

if (att.type_information.assigned())
Expand Down
3 changes: 1 addition & 2 deletions src/cpp/rtps/builtin/discovery/participant/PDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ void PDP::initializeParticipantProxyData(
}

// TypeLookupManager
auto properties = mp_RTPSParticipant->getAttributes().properties;
auto type_propagation = dds::utils::to_type_propagation(properties);
auto type_propagation = mp_RTPSParticipant->type_propagation();
bool should_announce_typelookup =
(dds::utils::TypePropagation::TYPEPROPAGATION_ENABLED == type_propagation) ||
(dds::utils::TypePropagation::TYPEPROPAGATION_MINIMAL_BANDWIDTH == type_propagation);
Expand Down
12 changes: 9 additions & 3 deletions src/cpp/rtps/participant/RTPSParticipantImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <fastdds/rtps/transport/UDPv4TransportDescriptor.hpp>
#include <fastdds/utils/IPFinder.hpp>

#include <fastdds/utils/TypePropagation.hpp>
#include <rtps/attributes/ServerAttributes.hpp>
#include <rtps/builtin/BuiltinProtocols.h>
#include <rtps/builtin/data/ProxyDataConverters.hpp>
Expand Down Expand Up @@ -265,7 +266,6 @@ RTPSParticipantImpl::RTPSParticipantImpl(
#endif // if HAVE_SECURITY
, mp_participantListener(plisten)
, mp_userParticipant(par)
, mp_mutex(new std::recursive_mutex())
, is_intraprocess_only_(should_be_intraprocess_only(PParam))
#ifdef FASTDDS_STATISTICS
, monitor_server_(nullptr)
Expand Down Expand Up @@ -795,8 +795,6 @@ RTPSParticipantImpl::~RTPSParticipantImpl()
delete mp_userParticipant;
mp_userParticipant = nullptr;
send_resource_list_.clear();

delete mp_mutex;
}

template <EndpointKind_t kind, octet no_key, octet with_key>
Expand Down Expand Up @@ -1426,6 +1424,8 @@ bool RTPSParticipantImpl::registerReader(
void RTPSParticipantImpl::update_attributes(
const RTPSParticipantAttributes& patt)
{
std::lock_guard<std::mutex> _(mutex_);

bool local_interfaces_changed = false;

// Update cached network interfaces
Expand Down Expand Up @@ -3155,6 +3155,12 @@ void RTPSParticipantImpl::update_removed_participant(
}
}

dds::utils::TypePropagation RTPSParticipantImpl::type_propagation() const
{
std::lock_guard<std::mutex> _(mutex_);
return dds::utils::to_type_propagation(m_att.properties);
}

} /* namespace rtps */
} /* namespace fastdds */
} /* namespace eprosima */
21 changes: 11 additions & 10 deletions src/cpp/rtps/participant/RTPSParticipantImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <fastdds/rtps/transport/SenderResource.hpp>

#include "../flowcontrol/FlowControllerFactory.hpp"
#include <fastdds/utils/TypePropagation.hpp>
#include <rtps/builtin/data/ReaderProxyData.hpp>
#include <rtps/builtin/data/WriterProxyData.hpp>
#include <rtps/messages/MessageReceiver.h>
Expand All @@ -60,7 +61,6 @@
#include <statistics/rtps/StatisticsBase.hpp>
#include <statistics/types/monitorservice_types.hpp>
#include <utils/shared_mutex.hpp>
#include <utils/Semaphore.hpp>

#if HAVE_SECURITY
#include <fastdds/rtps/Endpoint.hpp>
Expand Down Expand Up @@ -340,19 +340,13 @@ class RTPSParticipantImpl
return ret_code;
}

//!Get the participant Mutex
std::recursive_mutex* getParticipantMutex() const
{
return mp_mutex;
}

/**
* Get the participant listener
* @return participant listener
*/
inline RTPSParticipantListener* getListener()
{
std::lock_guard<std::recursive_mutex> _(*getParticipantMutex());
std::lock_guard<std::mutex> _(mutex_);
return mp_participantListener;
}

Expand All @@ -363,7 +357,7 @@ class RTPSParticipantImpl
void set_listener(
RTPSParticipantListener* listener)
{
std::lock_guard<std::recursive_mutex> _(*getParticipantMutex());
std::lock_guard<std::mutex> _(mutex_);
mp_participantListener = listener;
}

Expand Down Expand Up @@ -713,7 +707,7 @@ class RTPSParticipantImpl
EndpointAttributes& endpoint_att);

//!Participant Mutex
std::recursive_mutex* mp_mutex;
mutable std::mutex mutex_;

//!Will this participant use intraprocess only?
bool is_intraprocess_only_;
Expand Down Expand Up @@ -1286,6 +1280,13 @@ class RTPSParticipantImpl
void update_removed_participant(
const LocatorList_t& remote_participant_locators);

/**
* @brief Get participant's @ref dds::utils::TypePropagation
*
* @return This participant's @ref dds::utils::TypePropagation
*/
dds::utils::TypePropagation type_propagation() const;

};
} // namespace rtps
} /* namespace rtps */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <vector>

#include <fastdds/dds/core/policy/ParameterTypes.hpp>
#include <fastdds/rtps/attributes/PropertyPolicy.hpp>
#include <fastdds/rtps/common/Time_t.hpp>
#include <fastdds/rtps/common/Types.hpp>
#include <fastdds/utils/collections/ResourceLimitedVector.hpp>
Expand Down Expand Up @@ -1539,6 +1540,8 @@ class TypeObjectV1 : public Parameter_t, public QosPolicy

};

using PropertyPolicyQos = fastdds::rtps::PropertyPolicy;

namespace xtypes {
class TypeInformation;
} // namespace types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <fastdds/rtps/reader/RTPSReader.hpp>
#include <fastdds/rtps/writer/RTPSWriter.hpp>

#include <fastdds/utils/TypePropagation.hpp>
#include <rtps/network/NetworkFactory.h>
#include <rtps/reader/BaseReader.hpp>
#include <rtps/resources/ResourceEvent.h>
Expand Down Expand Up @@ -412,6 +413,8 @@ class RTPSParticipantImpl
return nullptr;
}

MOCK_METHOD(dds::utils::TypePropagation, type_propagation, (), (const));

private:

MockParticipantListener listener_;
Expand Down
1 change: 1 addition & 0 deletions test/unittest/rtps/security/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ endif()
set(SOURCES_SECURITY_TEST_SOURCE
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/publisher/qos/WriterQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/subscriber/qos/ReaderQos.cpp
${PROJECT_SOURCE_DIR}/src/cpp/fastdds/utils/TypePropagation.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/EndpointSecurityAttributes.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/attributes/PropertyPolicy.cpp
${PROJECT_SOURCE_DIR}/src/cpp/rtps/common/LocatorWithMask.cpp
Expand Down

0 comments on commit c8cb4da

Please sign in to comment.