diff --git a/plugins/datastreamer_plugin/fastdds/Participant.cpp b/plugins/datastreamer_plugin/fastdds/Participant.cpp index 03077f8..b4db9ce 100644 --- a/plugins/datastreamer_plugin/fastdds/Participant.cpp +++ b/plugins/datastreamer_plugin/fastdds/Participant.cpp @@ -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 @@ -198,7 +204,8 @@ void Participant::create_subscription( datareader, dyn_type, listener_, - data_type_configuration), + data_type_configuration, + is_keyed), ReaderHandlerDeleter(participant_, subscriber_) ); diff --git a/plugins/datastreamer_plugin/fastdds/ReaderHandler.cpp b/plugins/datastreamer_plugin/fastdds/ReaderHandler.cpp index cc6633f..32e1a77 100644 --- a/plugins/datastreamer_plugin/fastdds/ReaderHandler.cpp +++ b/plugins/datastreamer_plugin/fastdds/ReaderHandler.cpp @@ -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_)); diff --git a/plugins/datastreamer_plugin/fastdds/ReaderHandler.hpp b/plugins/datastreamer_plugin/fastdds/ReaderHandler.hpp index 79d40e6..552d197 100644 --- a/plugins/datastreamer_plugin/fastdds/ReaderHandler.hpp +++ b/plugins/datastreamer_plugin/fastdds/ReaderHandler.hpp @@ -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();