Skip to content

Commit

Permalink
Add a check for keyed topics
Browse files Browse the repository at this point in the history
If this commit is applied, Participants will check if the topic is keyed
or not before Readerhandler creation.
So that we can use this information to know in which PLotJugglerGroup
received data needs to be added.

Issue: [eProsima#56]
Signed-off-by: Manuel Valch <manuelValch@proton.me>
  • Loading branch information
manuelValch committed Aug 29, 2024
1 parent 2fea81d commit 3ba855b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
9 changes: 8 additions & 1 deletion plugins/datastreamer_plugin/fastdds/Participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ void Participant::create_subscription(
// Get Dyn Type for type
// This could not fail, as we know type is registered
eprosima::fastrtps::types::DynamicType_ptr dyn_type = get_type_registered_(type_name);
// In order to find out if the topic is keyed or not, create a dynamicPubSubType and then
std::string topicName = topic->get_type_name();
eprosima::fastrtps::types::DynamicPubSubType* pIsKeyType =
eprosima::fastrtps::xmlparser::XMLProfileManager::CreateDynamicPubSubType(topicName);
bool is_keyed = pIsKeyType->m_isGetKeyDefined;
eprosima::fastrtps::xmlparser::XMLProfileManager::DeleteDynamicPubSubType(pIsKeyType);

// Create Reader Handler with all this information and add it to readers
// Create it with specific deleter for reader and topic
Expand All @@ -198,7 +204,8 @@ void Participant::create_subscription(
datareader,
dyn_type,
listener_,
data_type_configuration),
data_type_configuration,
is_keyed),
ReaderHandlerDeleter(participant_, subscriber_)
);

Expand Down
8 changes: 4 additions & 4 deletions plugins/datastreamer_plugin/fastdds/ReaderHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ ReaderHandler::ReaderHandler(
eprosima::fastdds::dds::DataReader* datareader,
eprosima::fastrtps::types::DynamicType_ptr type,
FastDdsListener* listener,
const DataTypeConfiguration& data_type_configuration)
const DataTypeConfiguration& data_type_configuration,
const bool& is_Keyed)
: topic_(topic)
, reader_(datareader)
, type_(type)
, listener_(listener)
, stop_(false)
, is_keyed_(false)
, is_keyed_(is_Keyed)
{
// Create data so it is not required to create it each time and avoid reallocation if possible
data_ = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(type_);

// find out if the topic is keyed or not
is_keyed_ = type_->key_annotation();
auto refDesc = type_->get_descriptor();
if (true == is_keyed_)
{
DEBUG("\tTopic: " << topic->get_name() << " has key: " << std::to_string(is_keyed_));
Expand Down
3 changes: 2 additions & 1 deletion plugins/datastreamer_plugin/fastdds/ReaderHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ struct ReaderHandler : public eprosima::fastdds::dds::DataReaderListener
eprosima::fastdds::dds::DataReader* datareader,
eprosima::fastrtps::types::DynamicType_ptr type,
FastDdsListener* listener,
const DataTypeConfiguration& data_type_configuration);
const DataTypeConfiguration& data_type_configuration,
const bool& is_Keyed);


virtual ~ReaderHandler();
Expand Down

0 comments on commit 3ba855b

Please sign in to comment.