10#ifndef NROS_CPP_PUBLISHER_HPP
11#define NROS_CPP_PUBLISHER_HPP
20#include "nros_cpp_ffi.h"
85 static_cast<void*
>(&
ctx)));
98 Loan(
Loan&&
o) : pub_(
o.pub_), buf_(
o.buf_), cap_(
o.cap_), token_(
o.token_) {
123 bool is_valid()
const {
return token_ !=
nullptr; }
154 if (token_ && pub_) {
173 void*
token =
nullptr;
189 initialized_ =
false;
196 if (
other.initialized_) {
198 ::memcpy(topic_name_,
other.topic_name_,
sizeof(topic_name_));
199 other.initialized_ =
false;
204 if (
this != &
other) {
207 initialized_ =
false;
209 if (
other.initialized_) {
211 ::memcpy(topic_name_,
other.topic_name_,
sizeof(topic_name_));
213 other.initialized_ =
false;
282 ffi_qos.liveliness_lease_ms =
qos.liveliness_lease_ms();
283 ffi_qos.avoid_ros_namespace_conventions =
qos.avoid_ros_namespace_conventions() ? 1 : 0;
295 out.initialized_ =
true;
Definition result.hpp:160
ErrorCode error() const
Definition result.hpp:183
bool ok() const
Definition result.hpp:176
Result create_publisher(Publisher< M > &out, const char *topic, const QoS &qos=QoS::default_profile())
Definition publisher.hpp:272
Definition publisher.hpp:95
Result commit(size_t actual_len)
Send actual_len bytes. Consumes the loan.
Definition publisher.hpp:126
Loan(Loan &&o)
Definition publisher.hpp:98
Loan(void *pub, uint8_t *buf, size_t cap, void *token)
Definition publisher.hpp:149
const uint8_t * data() const
Definition publisher.hpp:120
~Loan()
Definition publisher.hpp:116
Loan()
Definition publisher.hpp:97
Loan & operator=(const Loan &)=delete
size_t capacity() const
Definition publisher.hpp:121
Loan & operator=(Loan &&o)
Definition publisher.hpp:102
Result discard()
Abandon without sending. Consumes the loan.
Definition publisher.hpp:137
Loan(const Loan &)=delete
bool is_valid() const
Definition publisher.hpp:123
uint8_t * data()
Writable view of the loaned bytes.
Definition publisher.hpp:119
Definition publisher.hpp:46
Expected< Loan > loan(size_t requested_len)
Definition publisher.hpp:169
Result publish_streamed(size_t total_len, W &&writer)
Definition publisher.hpp:70
Publisher()
Definition publisher.hpp:221
Result publish_raw(const uint8_t *data, size_t len)
Publish raw CDR bytes.
Definition publisher.hpp:55
const char * get_topic_name() const
Get the topic name.
Definition publisher.hpp:180
Result on_liveliness_lost(nros_cpp_publisher_count_cb_t cb, void *user_context=nullptr)
Register a callback for liveliness-lost events on this publisher.
Definition publisher.hpp:228
Publisher(Publisher &&other)
Definition publisher.hpp:195
Result publish(const M &msg)
Definition publisher.hpp:52
~Publisher()
Destructor — releases publisher resources.
Definition publisher.hpp:186
Result on_offered_deadline_missed(uint32_t deadline_ms, nros_cpp_publisher_count_cb_t cb, void *user_context=nullptr)
Definition publisher.hpp:235
bool is_valid() const
Check if the publisher is initialized and valid.
Definition publisher.hpp:183
Result assert_liveliness()
Definition publisher.hpp:245
Publisher & operator=(Publisher &&other)
Definition publisher.hpp:203
static constexpr QoS default_profile()
Default profile: RELIABLE + VOLATILE + KEEP_LAST(10).
Definition qos.hpp:160
static constexpr Result success()
Named constructors.
Definition result.hpp:74
Inline storage-size macros for opaque entity buffers.
int nros_cpp_ret_t
Definition future.hpp:20
static constexpr size_t PUBLISHER_TOPIC_NAME_MAX
Definition publisher.hpp:26
bool ok()
Check if the nros session is initialized.
Definition node.hpp:717
nros::Node and global session helpers.
nros_cpp_qos_history_t
Definition qos.hpp:31
nros_cpp_qos_liveliness_t
Definition qos.hpp:35
nros_cpp_qos_durability_t
Definition qos.hpp:27
nros_cpp_qos_reliability_t
Definition qos.hpp:23
nros::Result, nros::ErrorCode, and the NROS_TRY macro.