From 4e37e22835f8283d3d20182d60a0bb73764b65af Mon Sep 17 00:00:00 2001 From: rex-schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:34:13 +0100 Subject: [PATCH] return value type of CPublisher::Send changed to boolean --- ecal/core/include/ecal/ecal_publisher.h | 12 ++++++------ ecal/core/src/pubsub/ecal_publisher.cpp | 11 ++++++----- ecal/core/src/pubsub/ecal_publisher_impl.cpp | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ecal/core/include/ecal/ecal_publisher.h b/ecal/core/include/ecal/ecal_publisher.h index 88668d09e5..d086db3f80 100644 --- a/ecal/core/include/ecal/ecal_publisher.h +++ b/ecal/core/include/ecal/ecal_publisher.h @@ -122,10 +122,10 @@ namespace eCAL * @param len_ Length of buffer. * @param time_ Send time (-1 = use eCAL system time in us, default = -1). * - * @return Number of bytes sent. + * @return True if succeeded, false if not. **/ ECAL_API_EXPORTED_MEMBER - size_t Send(const void* buf_, size_t len_, long long time_ = DEFAULT_TIME_ARGUMENT); + bool Send(const void* buf_, size_t len_, long long time_ = DEFAULT_TIME_ARGUMENT); /** * @brief Send a message to all subscribers. @@ -133,10 +133,10 @@ namespace eCAL * @param payload_ Payload writer. * @param time_ Send time (-1 = use eCAL system time in us, default = -1). * - * @return Number of bytes sent. + * @return True if succeeded, false if not. **/ ECAL_API_EXPORTED_MEMBER - size_t Send(CPayloadWriter& payload_, long long time_ = DEFAULT_TIME_ARGUMENT); + bool Send(CPayloadWriter& payload_, long long time_ = DEFAULT_TIME_ARGUMENT); /** * @brief Send a message to all subscribers. @@ -144,10 +144,10 @@ namespace eCAL * @param payload_ Payload string. * @param time_ Send time (-1 = use eCAL system time in us, default = -1). * - * @return Number of bytes sent. + * @return True if succeeded, false if not. **/ ECAL_API_EXPORTED_MEMBER - size_t Send(const std::string& payload_, long long time_ = DEFAULT_TIME_ARGUMENT); + bool Send(const std::string& payload_, long long time_ = DEFAULT_TIME_ARGUMENT); /** * @brief Add callback function for publisher events. diff --git a/ecal/core/src/pubsub/ecal_publisher.cpp b/ecal/core/src/pubsub/ecal_publisher.cpp index 664bedeebf..ba1ee61175 100644 --- a/ecal/core/src/pubsub/ecal_publisher.cpp +++ b/ecal/core/src/pubsub/ecal_publisher.cpp @@ -74,13 +74,13 @@ namespace eCAL return *this; } - size_t CPublisher::Send(const void* const buf_, const size_t len_, const long long time_ /* = DEFAULT_TIME_ARGUMENT */) + bool CPublisher::Send(const void* const buf_, const size_t len_, const long long time_ /* = DEFAULT_TIME_ARGUMENT */) { CBufferPayloadWriter payload{ buf_, len_ }; return Send(payload, time_); } - size_t CPublisher::Send(CPayloadWriter& payload_, long long time_) + bool CPublisher::Send(CPayloadWriter& payload_, long long time_) { // in an optimization case the // publisher can send an empty package @@ -97,11 +97,12 @@ namespace eCAL const long long write_time = (time_ == DEFAULT_TIME_ARGUMENT) ? eCAL::Time::GetMicroSeconds() : time_; const size_t written_bytes = m_publisher_impl->Write(payload_, write_time, 0); - // return number of bytes written - return written_bytes; + // TODO: change CPublisherImpl::Write to return a bool + // return true if we have written something + return written_bytes > 0; } - size_t CPublisher::Send(const std::string& payload_, long long time_) + bool CPublisher::Send(const std::string& payload_, long long time_) { return(Send(payload_.data(), payload_.size(), time_)); } diff --git a/ecal/core/src/pubsub/ecal_publisher_impl.cpp b/ecal/core/src/pubsub/ecal_publisher_impl.cpp index 7cf9073e7d..fae641681e 100644 --- a/ecal/core/src/pubsub/ecal_publisher_impl.cpp +++ b/ecal/core/src/pubsub/ecal_publisher_impl.cpp @@ -106,7 +106,7 @@ namespace eCAL { #ifndef NDEBUG // log it - Logging::Log(log_level_debug1, m_attributes.topic_name + "::CDataWriter::Constructor"); + Logging::Log(log_level_debug2, m_attributes.topic_name + "::CDataWriter::Constructor"); #endif // build topic id