Skip to content

Commit 8b9bf8e

Browse files
Create topic writer
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
1 parent 2556e12 commit 8b9bf8e

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

ddsenabler_participants/include/ddsenabler_participants/EnablerParticipant.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,18 @@ class EnablerParticipant : public ddspipe::participants::SchemaParticipant
126126
RPC_PROTOCOL rpc_protocol,
127127
std::unique_lock<std::mutex>& lck);
128128

129+
bool create_topic_writer_nts_(
130+
const ddspipe::core::types::DdsTopic& topic,
131+
std::shared_ptr<eprosima::ddspipe::core::IReader>& reader,
132+
std::unique_lock<std::mutex>& lck);
133+
129134
bool create_topic_writer_nts_(
130135
const ddspipe::core::types::DdsTopic& topic,
131136
std::shared_ptr<eprosima::ddspipe::core::IReader>& reader,
132137
ddspipe::core::types::Endpoint& request_edp,
133138
std::unique_lock<std::mutex>& lck);
134139

140+
135141
bool create_service_request_writer_nts_(
136142
std::shared_ptr<ServiceDiscovered> service,
137143
std::unique_lock<std::mutex>& lck);

ddsenabler_participants/src/cpp/EnablerParticipant.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ std::shared_ptr<IReader> EnablerParticipant::create_reader(
142142
return reader;
143143
}
144144

145+
bool EnablerParticipant::create_topic_writer_nts_(
146+
const DdsTopic& topic,
147+
std::shared_ptr<IReader>& reader,
148+
std::unique_lock<std::mutex>& lck)
149+
{
150+
ddspipe::core::types::Endpoint request_edp;
151+
return create_topic_writer_nts_(topic, reader, request_edp, lck);
152+
}
153+
145154
bool EnablerParticipant::create_topic_writer_nts_(
146155
const DdsTopic& topic,
147156
std::shared_ptr<IReader>& reader,
@@ -194,8 +203,13 @@ bool EnablerParticipant::publish(
194203
return false;
195204
}
196205

197-
ddspipe::core::types::Endpoint _;
198-
create_topic_writer_nts_(topic, i_reader, _, lck);
206+
if (!create_topic_writer_nts_(topic, i_reader, lck))
207+
{
208+
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
209+
"Failed to publish data in topic " << topic_name << " : writer creation failed.");
210+
return false;
211+
}
212+
199213
type_name = topic.type_name;
200214

201215
// (Optionally) wait for writer created in DDS participant to match with external readers, to avoid losing this
@@ -778,11 +792,9 @@ bool EnablerParticipant::query_action_nts_(
778792
auto feedback_reader = lookup_reader_nts_(feedback_topic_name);
779793
if (!feedback_reader)
780794
{
781-
ddspipe::core::types::Endpoint _;
782795
create_topic_writer_nts_(
783796
action.feedback,
784797
feedback_reader,
785-
_,
786798
lck);
787799
}
788800
}
@@ -804,11 +816,9 @@ bool EnablerParticipant::query_action_nts_(
804816
auto status_reader = lookup_reader_nts_(action.status.m_topic_name);
805817
if (!status_reader)
806818
{
807-
ddspipe::core::types::Endpoint _;
808819
create_topic_writer_nts_(
809820
action.status,
810821
status_reader,
811-
_,
812822
lck);
813823
}
814824
}

0 commit comments

Comments
 (0)