15.2.11.2. RTPSWriter

class eprosima::fastrtps::rtps::RTPSWriter : public eprosima::fastrtps::rtps::Endpoint, public eprosima::fastrtps::rtps::RTPSMessageSenderInterface

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.

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

void send_any_unsent_changes() = 0

This method triggers the send operation for unsent changes.

Return

number of messages sent

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 separatedly

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 durtation

const Duration_t &get_liveliness_announcement_period() const

A method to return the liveliness announcement period.

Return

The announcement period

bool destinations_have_changed() const override

Check if the destinations managed by this sender interface have changed.

Return

true if destinations have changed, false otherwise.

GuidPrefix_t destination_guid_prefix() const override

Get a GUID prefix representing all destinations.

Return

When all the destinations share the same prefix (i.e. belong to the same participant) that prefix is returned. When there are no destinations, or they belong to different participants, c_GuidPrefix_Unknown is returned.

const std::vector<GuidPrefix_t> &remote_participants() const override

Get the GUID prefix of all the destination participants.

Return

a const reference to a vector with the GUID prefix of all destination participants.

const std::vector<GUID_t> &remote_guids() const override

Get the GUID of all destinations.

Return

a const reference to a vector with the GUID of all destinations.

bool send(CDRMessage_t *message, std::chrono::steady_clock::time_point &max_blocking_time_point) const override

Send a message through this interface.

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

  • max_blocking_time_point: Future timepoint where blocking send should end.

bool is_datasharing_compatible() const

Return

Whether the writer is data sharing compatible or not

bool is_datasharing_payload_reusable(const Time_t &source_timestamp) const = 0

Return

whether a payload with the given source timestamp can be reused for a new change

Parameters
  • source_timestamp: the timestamp of the payload we want to recycle

Public Members

LivelinessLostStatus liveliness_lost_status_

Liveliness lost status of this writer.