15.2.11.2. RTPSWriter

class eprosima::fastrtps::rtps::RTPSWriter : public eprosima::fastrtps::rtps::Endpoint, public eprosima::fastdds::statistics::StatisticsWriterImpl

Class RTPSWriter, manages the sending of data to the readers. Is always associated with a HistoryCache.

Subclassed by eprosima::fastrtps::rtps::StatefulWriter, eprosima::fastrtps::rtps::StatelessWriter

Public Functions

template<typename T>
CacheChange_t *new_change(T &data, ChangeKind_t changeKind, InstanceHandle_t handle = c_InstanceHandle_Unknown)

Create a new change based with the provided changeKind.

Return

Pointer to the CacheChange or nullptr if incorrect.

Parameters
  • data: Data of the change.

  • changeKind: The type of change.

  • handle: InstanceHandle to assign.

bool release_change(CacheChange_t *change)

Release a change when it is not being used anymore.

Return

whether the operation succeeded or not

Pre

  • change is not nullptr

  • change points to a cache change obtained from a call to this->new_change

Post

memory pointed to by change is not accessed

Parameters
  • change: Pointer to the cache change to be released.

bool matched_reader_add(const ReaderProxyData &data) = 0

Add a matched reader.

Return

True if added.

Parameters

bool matched_reader_remove(const GUID_t &reader_guid) = 0

Remove a matched reader.

Return

True if removed.

Parameters
  • reader_guid: GUID of the reader to remove.

bool matched_reader_is_matched(const GUID_t &reader_guid) = 0

Tells us if a specific Reader is matched against this writer.

Return

True if it was matched.

Parameters
  • reader_guid: GUID of the reader to check.

void reader_data_filter(fastdds::rtps::IReaderDataFilter *filter) = 0

Set a content filter to perform content filtering on this writer.

This method sets a content filter that will be used to check whether a cache change is relevant for a reader or not.

Parameters
  • filter: The content filter to use on this writer. May be nullptr to remove the content filter (i.e. treat all samples as relevant).

const fastdds::rtps::IReaderDataFilter *reader_data_filter() const = 0

Get the content filter used to perform content filtering on this writer.

Return

The content filter used on this writer.

bool is_acked_by_all(const CacheChange_t*) const

Check if a specific change has been acknowledged by all Readers. Is only useful in reliable Writer. In BE Writers returns false when pending to be sent.

Return

True if acknowledged by all.

bool wait_for_all_acked(const Duration_t&)

Waits until all changes were acknowledged or max_wait.

Return

True if all were acknowledged.

void updateAttributes(const WriterAttributes &att) = 0

Update the Attributes of the Writer.

Parameters
  • att: New attributes

SequenceNumber_t get_seq_num_min()

Get Min Seq Num in History.

Return

Minimum sequence number in history

SequenceNumber_t get_seq_num_max()

Get Max Seq Num in History.

Return

Maximum sequence number in history

uint32_t getTypeMaxSerialized()

Get maximum size of the serialized type

Return

Maximum size of the serialized type

uint32_t getMaxDataSize()

Get maximum size of the data.

uint32_t calculateMaxDataSize(uint32_t length)

Calculates the maximum size of the data.

WriterListener *getListener()

Get listener

Return

Listener

bool isAsync() const

Get the publication mode

Return

publication mode

bool remove_older_changes(unsigned int max = 0)

Remove an specified max number of changes

Return

at least one change has been removed

Parameters
  • max: Maximum number of changes to remove.

bool try_remove_change(const std::chrono::steady_clock::time_point &max_blocking_time_point, std::unique_lock<RecursiveTimedMutex> &lock) = 0

Tries to remove a change waiting a maximum of the provided microseconds.

Return

at least one change has been removed

Parameters
  • max_blocking_time_point: Maximum time to wait for.

  • lock: Lock of the Change list.

bool wait_for_acknowledgement(const SequenceNumber_t &seq, const std::chrono::steady_clock::time_point &max_blocking_time_point, std::unique_lock<RecursiveTimedMutex> &lock) = 0

Waits till a change has been acknowledged.

Return

true when change was acknowledged, false when timeout is reached.

Parameters
  • seq: Sequence number to wait for acknowledgement.

  • max_blocking_time_point: Maximum time to wait for.

  • lock: Lock of the Change list.

RTPSParticipantImpl *getRTPSParticipant() const

Get RTPS participant

Return

RTPS participant

void set_separate_sending(bool enable)

Enable or disable sending data to readers separately NOTE: This will only work for synchronous writers

Parameters
  • enable: If separate sending should be enabled

bool get_separate_sending() const

Inform if data is sent to readers separately

Return

true if separate sending is enabled

bool process_acknack(const GUID_t &writer_guid, const GUID_t &reader_guid, uint32_t ack_count, const SequenceNumberSet_t &sn_set, bool final_flag, bool &result)

Process an incoming ACKNACK submessage.

Return

true when the submessage was destinated to this writer, false otherwise.

Parameters
  • [in] writer_guid: GUID of the writer the submessage is directed to.

  • [in] reader_guid: GUID of the reader originating the submessage.

  • [in] ack_count: Count field of the submessage.

  • [in] sn_set: Sequence number bitmap field of the submessage.

  • [in] final_flag: Final flag field of the submessage.

  • [out] result: true if the writer could process the submessage. Only valid when returned value is true.

bool process_nack_frag(const GUID_t &writer_guid, const GUID_t &reader_guid, uint32_t ack_count, const SequenceNumber_t &seq_num, const FragmentNumberSet_t fragments_state, bool &result)

Process an incoming NACKFRAG submessage.

Return

true when the submessage was destinated to this writer, false otherwise.

Parameters
  • [in] writer_guid: GUID of the writer the submessage is directed to.

  • [in] reader_guid: GUID of the reader originating the submessage.

  • [in] ack_count: Count field of the submessage.

  • [in] seq_num: Sequence number field of the submessage.

  • [in] fragments_state: Fragment number bitmap field of the submessage.

  • [out] result: true if the writer could process the submessage. Only valid when returned value is true.

const LivelinessQosPolicyKind &get_liveliness_kind() const

A method to retrieve the liveliness kind.

Return

Liveliness kind

const Duration_t &get_liveliness_lease_duration() const

A method to retrieve the liveliness lease duration.

Return

Lease duration

const Duration_t &get_liveliness_announcement_period() const

A method to return the liveliness announcement period.

Return

The announcement period

bool is_datasharing_compatible() const

Return

Whether the writer is data sharing compatible or not

DeliveryRetCode deliver_sample_nts(CacheChange_t *cache_change, RTPSMessageGroup &group, LocatorSelectorSender &locator_selector, const std::chrono::time_point<std::chrono::steady_clock> &max_blocking_time) = 0

Tells writer the sample can be sent to the network.

This function should be used by a fastdds::rtps::FlowController.

Return

Return code.

Note

Must be non-thread safe.

Parameters
  • cache_change: Pointer to the CacheChange_t that represents the sample which can be sent.

  • group: RTPSMessageGroup reference uses for generating the RTPS message.

  • locator_selector: RTPSMessageSenderInterface reference uses for selecting locators. The reference has to be a member of this RTPSWriter object.

  • max_blocking_time: Future timepoint where blocking send should end.

bool send_nts(CDRMessage_t *message, const LocatorSelectorSender &locator_selector, std::chrono::steady_clock::time_point &max_blocking_time_point) const

Send a message through this interface.

Parameters
  • message: Pointer to the buffer with the message already serialized.

  • locator_selector: RTPSMessageSenderInterface reference uses for selecting locators. The reference has to be a member of this RTPSWriter object.

  • max_blocking_time_point: Future timepoint where blocking send should end.

Public Members

LivelinessLostStatus liveliness_lost_status_

Liveliness lost status of this writer.