Class Publisher

Class Documentation

class Publisher

Class Publisher, used to send data to associated subscribers.

Public Functions

Publisher(PublisherImpl *pimpl)

Constructor from a PublisherImpl pointer

Parameters

pimpl – Actual implementation of the publisher

bool write(void *sample)

Writes a sample of the topic.

Calling example:


Note

This method is blocked for a period of time. ReliabilityQosPolicy.max_blocking_time on PublisherAttributes defines this period of time.

Parameters

sample – Pointer to the sample.

Returns

true when operation works successfully.

bool write(void *sample, rtps::WriteParams &wparams)

Writes a sample of the topic with additional options.

Calling example:


Note

This method is blocked for a period of time. ReliabilityQosPolicy.max_blocking_time on PublisherAttributes defines this period of time.

Parameters
  • sample – Pointer to the sample.

  • wparams – Extra write parameters.

Returns

true when operation works successfully.

fastrtps::rtps::InstanceHandle_t register_instance(void *instance)

Informs that the application will be modifying a particular instance. It gives and opportunity to the middleware to pre-configure itself to improve performance.

Parameters

instance[in] Sample used to get the instance’s key.

Returns

Handle containing the instance’s key. This handle could be used in successive write or dispose operations. In case of error, HANDLE_NIL will be returned.

bool dispose(void *data, const rtps::InstanceHandle_t &handle)

Requests the middleware to delete the instance. Applications are made aware of the deletion through the DataReader objects.

Parameters
  • data[in] Sample used to deduce instance’s key in case of handle parameter is HANDLE_NIL.

  • handle[in] Instance’s key to be unregistered.

Returns

Returns the operation’s result. If the operation finishes successfully, true is returned.

bool unregister_instance(void *instance, const rtps::InstanceHandle_t &handle)

This operation reserves the action of register_instance. Informs the middleware that the DataWriter is not intending to modify any more of that data instance. Also indicates that the middleware can locally remove all information regarding that instance.

Parameters
  • instance[in] Sample used to deduce instance’s key in case of handle parameter is HANDLE_NIL.

  • handle[in] Instance’s key to be unregistered.

Returns

Returns the operation’s result. If the operation finishes successfully, true is returned.

bool removeAllChange(size_t *removed = nullptr)

Remove all the Changes in the associated RTPSWriter.

Parameters

removed[out] Number of elements removed

Returns

True if all elements were removed.

bool wait_for_all_acked(const Duration_t &max_wait)

Waits until all changes were acknowledged or max_wait.

Parameters

max_wait – Maximum time to wait until all changes are acknowledged.

Returns

True if all were acknowledged.

const rtps::GUID_t &getGuid()

Get the GUID_t of the associated RTPSWriter.

Returns

GUID_t.

const PublisherAttributes &getAttributes() const

Get the Attributes of the Publisher.

Returns

Attributes of the publisher

bool updateAttributes(const PublisherAttributes &att)

Update the Attributes of the publisher.

Parameters

att – Reference to a PublisherAttributes object to update the parameters.

Returns

True if correctly updated, false if ANY of the updated parameters cannot be updated.

void get_offered_deadline_missed_status(OfferedDeadlineMissedStatus &status)

Returns the offered deadline missed status.

Parameters

status – missed status struct

void assert_liveliness()

Asserts liveliness.

void get_liveliness_lost_status(LivelinessLostStatus &status)

Returns the liveliness lost status.

Parameters

status – Liveliness lost status

void get_sending_locators(rtps::LocatorList_t &locators) const

Get the list of locators from which this publisher may send data.

Parameters

locators[out] LocatorList_t where the list of locators will be stored.