Class Subscriber

Class Documentation

class Subscriber

Class Subscriber, contains the public API that allows the user to control the reception of messages. This class should not be instantiated directly. DomainRTPSParticipant class should be used to correctly create this element.


Public Functions

inline Subscriber(SubscriberImpl *pimpl)

Constructor from a SubscriberImpl pointer

Parameters

pimpl – Actual implementation of the subscriber

const rtps::GUID_t &getGuid()

Get the associated GUID

Returns

Associated GUID

inline void waitForUnreadMessage()

Method to block the current thread until an unread message is available

bool wait_for_unread_samples(const Duration_t &timeout)

Blocks the current thread until an unread sample is available.

Parameters

timeout – Maximum time the function will be blocked if any sample is received.

Returns

true in case unread samples are available. In other case, false.

bool readNextData(void *sample, SampleInfo_t *info)

Reads next unread sample from the Subscriber.

Note

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

Parameters
  • sample – Pointer to the object where you want the sample stored.

  • info – Pointer to a SampleInfo_t structure that informs you about your sample.

Returns

True if a sample was read.

bool takeNextData(void *sample, SampleInfo_t *info)

Takes next sample from the Subscriber. The sample is removed from the subscriber.

Note

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

Parameters
  • sample – Pointer to the object where you want the sample stored.

  • info – Pointer to a SampleInfo_t structure that informs you about your sample.

Returns

True if a sample was taken.

bool get_first_untaken_info(SampleInfo_t *info)

Returns information about the first untaken sample.

Parameters

info[out] Pointer to a SampleInfo_t structure to store first untaken sample information.

Returns

true if sample info was returned. false if there is no sample to take.

bool updateAttributes(const SubscriberAttributes &att)

Update the Attributes of the subscriber;

Parameters

att – Reference to a SubscriberAttributes object to update the parameters;

Returns

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

const SubscriberAttributes &getAttributes() const

Get the Attributes of the Subscriber.

Returns

Attributes of the subscriber

bool isInCleanState() const

Returns there is a clean state with all Publishers. It occurs when the Subscriber received all samples sent by Publishers. In other words, its WriterProxies are up to date.

Returns

There is a clean state with all Publishers.

inline uint64_t getUnreadCount() const

Get the unread count.

Returns

Unread count

uint64_t get_unread_count() const

Get the unread count.

Returns

Unread count

void get_requested_deadline_missed_status(RequestedDeadlineMissedStatus &status)

Get the requested deadline missed status.

Parameters

status – The deadline missed status

void get_liveliness_changed_status(LivelinessChangedStatus &status)

Returns the liveliness changed status.

Parameters

status – Liveliness changed status

void get_listening_locators(rtps::LocatorList_t &locators) const

Get the list of locators on which this subscriber is listening.

Parameters

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