Skip to content

Commit

Permalink
Refactor DDS CommonParticipant to handle InitializationException in c…
Browse files Browse the repository at this point in the history
…reate_writer and create_reader
  • Loading branch information
irenebm committed Sep 2, 2024
1 parent c43a6f7 commit cd09de4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain
* @brief Create a writer object
*
* Depending on the Topic QoS creates a Basic or Specific Writer.
* If it fails to create the writer it will return a blank one.
*/
DDSPIPE_PARTICIPANTS_DllAPI
std::shared_ptr<core::IWriter> create_writer(
Expand All @@ -103,6 +104,7 @@ class CommonParticipant : public core::IParticipant, public fastdds::dds::Domain
* @brief Create a reader object
*
* Depending on the Topic QoS creates a Basic or Specific Reader.
* If it fails to create the reader it will return a blank one.
*/
DDSPIPE_PARTICIPANTS_DllAPI
std::shared_ptr<core::IReader> create_reader(
Expand Down
31 changes: 28 additions & 3 deletions ddspipe_participants/src/cpp/participant/dds/CommonParticipant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,20 @@ std::shared_ptr<core::IWriter> CommonParticipant::create_writer(
return std::make_shared<BlankWriter>();
}

// Get the DDS Topic associated (create it if it does not exist)
fastdds::dds::Topic* fastdds_topic = topic_related_(dds_topic);
fastdds::dds::Topic* fastdds_topic;
try
{
// Get the DDS Topic associated (create it if it does not exist)
fastdds_topic = topic_related_(dds_topic);
}
catch (const utils::InitializationException& e)
{
EPROSIMA_LOG_WARNING(
DDSPIPE_DDS_PARTICIPANT,
e.what()
<< " Execution continue but this topic will not be published in Participant " << id() << ".");
return std::make_shared<BlankWriter>();
}

if (dds_topic.topic_qos.has_partitions() || dds_topic.topic_qos.has_ownership())
{
Expand Down Expand Up @@ -303,7 +315,20 @@ std::shared_ptr<core::IReader> CommonParticipant::create_reader(
}

// Get the DDS Topic associated (create it if it does not exist)
fastdds::dds::Topic* fastdds_topic = topic_related_(dds_topic);
fastdds::dds::Topic* fastdds_topic;
try
{
// Get the DDS Topic associated (create it if it does not exist)
fastdds_topic = topic_related_(dds_topic);
}
catch (const utils::InitializationException& e)
{
EPROSIMA_LOG_WARNING(
DDSPIPE_DDS_PARTICIPANT,
e.what()
<< ". Execution continue but this topic will not be subscribed in Participant " << id() << ".");
return std::make_shared<BlankReader>();
}

if (dds_topic.topic_qos.has_partitions() || dds_topic.topic_qos.has_ownership())
{
Expand Down

0 comments on commit cd09de4

Please sign in to comment.