Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21329] All DataWriter::write overload shall return RerturnCode_t type #5049

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/cpp/configuration/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ bool PublisherApp::publish()
if (!is_stopped())
{
configuration_.index(configuration_.index() + 1);
ret = writer_->write(&configuration_);
ret = (RETCODE_OK == writer_->write(&configuration_));
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/content_filter/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ bool PublisherApp::publish()
if (!is_stopped())
{
hello_.index(hello_.index() + 1);
ret = writer_->write(&hello_);
ret = (RETCODE_OK == writer_->write(&hello_));
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/custom_payload_pool/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool PublisherApp::publish()
if (!is_stopped())
{
hello_.index(hello_.index() + 1);
ret = writer_->write(&hello_);
ret = (RETCODE_OK == writer_->write(&hello_));
}
return ret;
}
Expand Down
3 changes: 2 additions & 1 deletion examples/cpp/dds/RequestReplyExample/CalculatorClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ class CalculatorClient
request.x(x);
request.y(y);

if (request_writer_->write(static_cast<void*>(&request), listener_.write_params))
if (eprosima::fastdds::dds::RETCODE_OK ==
request_writer_->write(static_cast<void*>(&request), listener_.write_params))
{
std::unique_lock<std::mutex> lock(listener_.reception_mutex);
listener_.reception_cv.wait(lock, [&]()
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/delivery_mechanisms/PubSubApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ bool PubSubApp::publish()
DeliveryMechanisms* delivery_mechanisms_ = static_cast<DeliveryMechanisms*>(sample_);
delivery_mechanisms_->index() = ++index_of_last_sample_sent_;
memcpy(delivery_mechanisms_->message().data(), "Delivery mechanisms", sizeof("Delivery mechanisms"));
ret = writer_->write(sample_);
ret = (RETCODE_OK == writer_->write(sample_));
std::cout << "Sample: '" << delivery_mechanisms_->message().data() << "' with index: '"
<< delivery_mechanisms_->index() << "' SENT" << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/delivery_mechanisms/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ bool PublisherApp::publish()
DeliveryMechanisms* delivery_mechanisms_ = static_cast<DeliveryMechanisms*>(sample_);
delivery_mechanisms_->index() = ++index_of_last_sample_sent_;
memcpy(delivery_mechanisms_->message().data(), "Delivery mechanisms", sizeof("Delivery mechanisms"));
ret = writer_->write(sample_);
ret = (RETCODE_OK == writer_->write(sample_));
std::cout << "Sample: '" << delivery_mechanisms_->message().data() << "' with index: '"
<< delivery_mechanisms_->index() << "' SENT" << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/discovery_server/ClientPublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ bool ClientPublisherApp::publish()
if (!is_stopped())
{
hello_.index(hello_.index() + 1);
ret = writer_->write(&hello_);
ret = (RETCODE_OK == writer_->write(&hello_));
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/hello_world/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ bool PublisherApp::publish()
if (!is_stopped())
{
hello_.index(hello_.index() + 1);
ret = writer_->write(&hello_);
ret = (RETCODE_OK == writer_->write(&hello_));
}
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/xtypes/PublisherApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ bool PublisherApp::publish()
set_uint32_value(hello_, "index", index);

// Publish the sample
ret = writer_->write(&hello_);
ret = (RETCODE_OK == writer_->write(&hello_));
}
return ret;
}
Expand Down
8 changes: 4 additions & 4 deletions include/fastdds/dds/publisher/DataWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,19 @@ class DataWriter : public DomainEntity
* Write data to the topic.
*
* @param data Pointer to the data
* @return True if correct, false otherwise
* @return RETCODE_OK if the data is correctly sent or a ReturnCode related to the specific error otherwise.
*/
FASTDDS_EXPORTED_API bool write(
FASTDDS_EXPORTED_API ReturnCode_t write(
const void* const data);

/**
* Write data with params to the topic.
*
* @param data Pointer to the data
* @param params Extra write parameters.
* @return True if correct, false otherwise
* @return RETCODE_OK if the data is correctly sent or a ReturnCode related to the specific error otherwise.
*/
FASTDDS_EXPORTED_API bool write(
FASTDDS_EXPORTED_API ReturnCode_t write(
const void* const data,
fastdds::rtps::WriteParams& params);

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/fastdds/publisher/DataWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ ReturnCode_t DataWriter::discard_loan(
return impl_->discard_loan(sample);
}

bool DataWriter::write(
ReturnCode_t DataWriter::write(
const void* const data)
{
return impl_->write(data);
}

bool DataWriter::write(
ReturnCode_t DataWriter::write(
const void* const data,
fastdds::rtps::WriteParams& params)
{
Expand Down
12 changes: 6 additions & 6 deletions src/cpp/fastdds/publisher/DataWriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,29 +634,29 @@ ReturnCode_t DataWriterImpl::discard_loan(
return RETCODE_OK;
}

bool DataWriterImpl::write(
ReturnCode_t DataWriterImpl::write(
const void* const data)
{
if (writer_ == nullptr)
{
return false;
return RETCODE_NOT_ENABLED;
}

EPROSIMA_LOG_INFO(DATA_WRITER, "Writing new data");
return RETCODE_OK == create_new_change(ALIVE, data);
return create_new_change(ALIVE, data);
}

bool DataWriterImpl::write(
ReturnCode_t DataWriterImpl::write(
const void* const data,
fastdds::rtps::WriteParams& params)
{
if (writer_ == nullptr)
{
return false;
return RETCODE_NOT_ENABLED;
}

EPROSIMA_LOG_INFO(DATA_WRITER, "Writing new data with WriteParams");
return RETCODE_OK == create_new_change_with_params(ALIVE, data, params);
return create_new_change_with_params(ALIVE, data, params);
}

ReturnCode_t DataWriterImpl::check_write_preconditions(
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/fastdds/publisher/DataWriterImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ class DataWriterImpl : protected rtps::IReaderDataFilter
*
* @param data Pointer to the data.
*
* @return true if data is correctly delivered to the lower layers, false otherwise.
* @return any of the standard return codes.
*/
bool write(
ReturnCode_t write(
const void* const data);

/**
Expand All @@ -175,9 +175,9 @@ class DataWriterImpl : protected rtps::IReaderDataFilter
* @param data Pointer to the data.
* @param params Extra write parameters.
*
* @return true if data is correctly delivered to the lower layers, false otherwise.
* @return any of the standard return codes.
*/
bool write(
ReturnCode_t write(
const void* const data,
fastdds::rtps::WriteParams& params);

Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/PubSubParticipant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ class PubSubParticipant
type& msg,
unsigned int index = 0)
{
return std::get<2>(publishers_[index])->write((void*)&msg);
return (eprosima::fastdds::dds::RETCODE_OK == std::get<2>(publishers_[index])->write((void*)&msg));
}

void assert_liveliness_participant()
Expand Down
4 changes: 2 additions & 2 deletions test/blackbox/api/dds-pim/PubSubWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ class PubSubWriter

while (it != msgs.end())
{
if (datawriter_->write((void*)&(*it)))
if (eprosima::fastdds::dds::RETCODE_OK == datawriter_->write((void*)&(*it)))
{
default_send_print<type>(*it);
it = msgs.erase(it);
Expand Down Expand Up @@ -553,7 +553,7 @@ class PubSubWriter
type& msg)
{
default_send_print(msg);
return datawriter_->write((void*)&msg);
return (eprosima::fastdds::dds::RETCODE_OK == datawriter_->write((void*)&msg));
}

eprosima::fastdds::dds::ReturnCode_t send_sample(
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/PubSubWriterReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class PubSubWriterReader

while (it != msgs.end())
{
if (datawriter_->write((void*)&(*it)))
if (eprosima::fastdds::dds::RETCODE_OK == datawriter_->write((void*)&(*it)))
{
for (auto& tuple : entities_extra_)
{
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/ReqRepHelloWorldReplier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void ReqRepHelloWorldReplier::newNumber(
hello.index(number);
hello.message("GoodBye");
wparams.related_sample_identity(sample_identity);
ASSERT_EQ(reply_datawriter_->write((void*)&hello, wparams), true);
ASSERT_EQ(reply_datawriter_->write((void*)&hello, wparams), eprosima::fastdds::dds::RETCODE_OK);
}

void ReqRepHelloWorldReplier::wait_discovery()
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/ReqRepHelloWorldRequester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void ReqRepHelloWorldRequester::send(
current_number_ = number;
}

ASSERT_EQ(request_datawriter_->write((void*)&hello, wparams), true);
ASSERT_EQ(request_datawriter_->write((void*)&hello, wparams), eprosima::fastdds::dds::RETCODE_OK);
related_sample_identity_ = wparams.sample_identity();
ASSERT_NE(related_sample_identity_.sequence_number(), eprosima::fastdds::rtps::SequenceNumber_t());
}
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/TCPReqRepHelloWorldReplier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void TCPReqRepHelloWorldReplier::newNumber(
hello.index(number);
hello.message("GoodBye");
wparams.related_sample_identity(sample_identity);
ASSERT_EQ(reply_datawriter_->write((void*)&hello, wparams), true);
ASSERT_EQ(reply_datawriter_->write((void*)&hello, wparams), RETCODE_OK);
}

void TCPReqRepHelloWorldReplier::wait_discovery(
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/TCPReqRepHelloWorldRequester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void TCPReqRepHelloWorldRequester::send(
current_number_ = number;
}

ASSERT_EQ(request_datawriter_->write((void*)&hello, wparams), true);
ASSERT_EQ(request_datawriter_->write((void*)&hello, wparams), RETCODE_OK);
related_sample_identity_ = wparams.sample_identity();
ASSERT_NE(related_sample_identity_.sequence_number(), SequenceNumber_t());
}
4 changes: 2 additions & 2 deletions test/blackbox/common/DDSBlackboxTestsBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,8 @@ TEST(DDSBasic, PidRelatedSampleIdentity)
write_params.related_sample_identity() = related_sample_identity_;

// Publish the new value, deduce the instance handle
bool write_ret = native_writer.write((void*)&data, write_params);
ASSERT_EQ(true, write_ret);
ReturnCode_t write_ret = native_writer.write((void*)&data, write_params);
ASSERT_EQ(RETCODE_OK, write_ret);

DataReader& native_reader = reliable_reader.get_native_reader();

Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/common/DDSBlackboxTestsDataReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ TEST(DDSDataReader, ConsistentReliabilityWhenIntraprocess)
auto writer = publisher->create_datawriter( topic, writer_qos );

auto data = HelloWorld{};
ASSERT_TRUE(writer->write( &data ));
ASSERT_EQ(writer->write( &data ), eprosima::fastdds::dds::RETCODE_OK);

std::this_thread::sleep_for(std::chrono::milliseconds(200));

Expand Down
4 changes: 2 additions & 2 deletions test/blackbox/common/DDSBlackboxTestsMonitorService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class MonitorServiceParticipant
{
for (auto& writer : writers_)
{
if (writer->write((void*)&(*it)))
if (RETCODE_OK == writer->write((void*)&(*it)))
{
default_send_print<HelloWorld>(*it);
it = msgs.erase(it);
Expand All @@ -276,7 +276,7 @@ class MonitorServiceParticipant
{
if (!writers_.empty())
{
return writers_.back()->write(&sample);
return (RETCODE_OK == writers_.back()->write(&sample));
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions test/performance/latency/LatencyTestPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ bool LatencyTestPublisher::test(
times_.clear();
TestCommandType command;
command.m_command = READY;
if (!command_writer_->write(&command))
if (RETCODE_OK != command_writer_->write(&command))
{
EPROSIMA_LOG_ERROR(LatencyTest, "Publisher cannot publish READY command");
return false;
Expand Down Expand Up @@ -852,7 +852,7 @@ bool LatencyTestPublisher::test(
start_time_ = std::chrono::steady_clock::now();

// Data publishing
if (!data_writer_->write(data))
if (RETCODE_OK != data_writer_->write(data))
{
// return the loan
if (data_loans_)
Expand Down
8 changes: 4 additions & 4 deletions test/performance/latency/LatencyTestSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ void LatencyTestSubscriber::LatencyDataReaderListener::on_data_available(
std::chrono::duration<uint32_t, std::nano> bounce_time(end_time - start_time);
reinterpret_cast<LatencyType*>(echoed_loan)->bounce = bounce_time.count();

if (!sub->data_writer_->write(echoed_loan))
if (RETCODE_OK != sub->data_writer_->write(echoed_loan))
{
EPROSIMA_LOG_ERROR(LatencyTest, "Problem echoing Publisher test data with loan");
sub->data_writer_->discard_loan(echoed_loan);
Expand Down Expand Up @@ -582,7 +582,7 @@ void LatencyTestSubscriber::LatencyDataReaderListener::on_data_available(
reinterpret_cast<LatencyType*>(data)->bounce = 0;
}

if (!sub->data_writer_->write(data))
if (RETCODE_OK != sub->data_writer_->write(data))
{
EPROSIMA_LOG_INFO(LatencyTest, "Problem echoing Publisher test data");
}
Expand Down Expand Up @@ -707,7 +707,7 @@ bool LatencyTestSubscriber::test(
received_ = 0;
TestCommandType command;
command.m_command = BEGIN;
if (!command_writer_->write(&command))
if (RETCODE_OK != command_writer_->write(&command))
{
EPROSIMA_LOG_ERROR(LatencyTest, "Subscriber fail to publish the BEGIN command");
return false;
Expand Down Expand Up @@ -752,7 +752,7 @@ bool LatencyTestSubscriber::test(
}

command.m_command = END;
if (!command_writer_->write(&command))
if (RETCODE_OK != command_writer_->write(&command))
{
EPROSIMA_LOG_ERROR(LatencyTest, "Subscriber fail to publish the END command");
return false;
Expand Down
2 changes: 1 addition & 1 deletion test/performance/throughput/ThroughputPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ bool ThroughputPublisher::test(
// initialize and send the sample
static_cast<ThroughputType*>(data)->seqnum = ++seqnum;

if (!data_writer_->write(data))
if (RETCODE_OK != data_writer_->write(data))
{
data_writer_->discard_loan(data);
}
Expand Down
2 changes: 1 addition & 1 deletion test/performance/video/VideoTestPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ GstFlowReturn VideoTestPublisher::new_sample(

if (rand() % 100 > sub->m_dropRate)
{
if (!sub->mp_data_dw->write((void*)sub->mp_video_out))
if (RETCODE_OK != sub->mp_data_dw->write((void*)sub->mp_video_out))
{
std::cout << "VideoPublication::run -> Cannot write video" << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion test/profiling/allocations/AllocTestPublisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ bool AllocTestPublisher::publish()
if (is_matched())
{
data_.index(data_.index() + 1);
ret = writer_->write(&data_);
ret = (RETCODE_OK == writer_->write(&data_));
}
return ret;
}
Loading
Loading