Skip to content

Commit

Permalink
return value type of CPublisher::Send changed to boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky committed Dec 13, 2024
1 parent 6d696be commit 4e37e22
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions ecal/core/include/ecal/ecal_publisher.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,32 @@ 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.
*
* @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.
*
* @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.
Expand Down
11 changes: 6 additions & 5 deletions ecal/core/src/pubsub/ecal_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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_));
}
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/pubsub/ecal_publisher_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4e37e22

Please sign in to comment.