Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches

Class Subscriber, contains the public API that allows the user to control the reception of messages. More...

#include <Subscriber.h>

Public Member Functions

 Subscriber (SubscriberImpl *pimpl)
 Constructor from a SubscriberImpl pointer.
 
const rtps::GUID_t & getGuid ()
 Get the associated GUID.
 
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.
 
bool readNextData (void *sample, SampleInfo_t *info)
 Reads next unread sample from the Subscriber.
 
bool takeNextData (void *sample, SampleInfo_t *info)
 Takes next sample from the Subscriber.
 
bool get_first_untaken_info (SampleInfo_t *info)
 Returns information about the first untaken sample.
 
bool updateAttributes (const SubscriberAttributes &att)
 Update the Attributes of the subscriber;.
 
const SubscriberAttributesgetAttributes () const
 Get the Attributes of the Subscriber.
 
bool isInCleanState () const
 Returns there is a clean state with all Publishers.
 
uint64_t getUnreadCount () const
 Get the unread count.
 
uint64_t get_unread_count () const
 Get the unread count.
 
void get_requested_deadline_missed_status (RequestedDeadlineMissedStatus &status)
 Get the requested deadline missed status.
 
void get_liveliness_changed_status (LivelinessChangedStatus &status)
 Returns the liveliness changed status.
 
void get_listening_locators (rtps::LocatorList_t &locators) const
 Get the list of locators on which this subscriber is listening.
 

Friends

class SubscriberImpl
 

Detailed Description

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.

using namespace eprosima::pubsub;
using namespace eprosima::rtps;
Rparam.historyMaxSize = 15;
Rparam.topic.topicDataType = std::string("TestType");
Rparam.topic.topicName = std::string("Test_Topic");
Rparam.reliability.reliabilityKind = RELIABLE;
Locator_t loc;
loc.port = 10046;
Rparam.unicastLocatorList.push_back(loc); //Listen in the same port
Subscriber* sub = DomainRTPSParticipant::createSubscriber(p, Rparam);
Class SubscriberAttributes, used by the user to define the attributes of a Subscriber.
Definition SubscriberAttributes.h:39
rtps::LocatorList_t unicastLocatorList
Unicast locator list.
Definition SubscriberAttributes.h:52
TopicAttributes topic
Topic Attributes.
Definition SubscriberAttributes.h:43
Class Subscriber, contains the public API that allows the user to control the reception of messages.
Definition Subscriber.h:44
string_255 topicName
Topic Name.
Definition TopicAttributes.h:101
string_255 topicDataType
Topic Data Type.
Definition TopicAttributes.h:103

Constructor & Destructor Documentation

◆ Subscriber()

Subscriber ( SubscriberImpl pimpl)
inline

Constructor from a SubscriberImpl pointer.

Parameters
pimplActual implementation of the subscriber

Member Function Documentation

◆ get_first_untaken_info()

bool get_first_untaken_info ( SampleInfo_t info)

Returns information about the first untaken sample.

Parameters
[out]infoPointer 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.

◆ get_listening_locators()

void get_listening_locators ( rtps::LocatorList_t &  locators) const

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

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

◆ get_liveliness_changed_status()

void get_liveliness_changed_status ( LivelinessChangedStatus status)

Returns the liveliness changed status.

Parameters
statusLiveliness changed status

◆ get_requested_deadline_missed_status()

void get_requested_deadline_missed_status ( RequestedDeadlineMissedStatus status)

Get the requested deadline missed status.

Parameters
statusThe deadline missed status

◆ get_unread_count()

uint64_t get_unread_count ( ) const

Get the unread count.

Returns
Unread count

◆ getAttributes()

const SubscriberAttributes & getAttributes ( ) const

Get the Attributes of the Subscriber.

Returns
Attributes of the subscriber

◆ getGuid()

const rtps::GUID_t & getGuid ( )

Get the associated GUID.

Returns
Associated GUID

◆ getUnreadCount()

uint64_t getUnreadCount ( ) const
inline

Get the unread count.

Returns
Unread count

◆ isInCleanState()

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.

◆ readNextData()

bool readNextData ( void *  sample,
SampleInfo_t info 
)

Reads next unread sample from the Subscriber.

Parameters
samplePointer to the object where you want the sample stored.
infoPointer to a SampleInfo_t structure that informs you about your sample.
Returns
True if a sample was read.
Note
This method is blocked for a period of time. ReliabilityQosPolicy.max_blocking_time on SubscriberAttributes defines this period of time.

◆ takeNextData()

bool takeNextData ( void *  sample,
SampleInfo_t info 
)

Takes next sample from the Subscriber.

The sample is removed from the subscriber.

Parameters
samplePointer to the object where you want the sample stored.
infoPointer to a SampleInfo_t structure that informs you about your sample.
Returns
True if a sample was taken.
Note
This method is blocked for a period of time. ReliabilityQosPolicy.max_blocking_time on SubscriberAttributes defines this period of time.

◆ updateAttributes()

bool updateAttributes ( const SubscriberAttributes att)

Update the Attributes of the subscriber;.

Parameters
attReference to a SubscriberAttributes object to update the parameters;
Returns
True if correctly updated, false if ANY of the updated parameters cannot be updated

◆ wait_for_unread_samples()

bool wait_for_unread_samples ( const Duration_t &  timeout)

Blocks the current thread until an unread sample is available.

Parameters
timeoutMaximum time the function will be blocked if any sample is received.
Returns
true in case unread samples are available. In other case, false.

◆ waitForUnreadMessage()

void waitForUnreadMessage ( )
inline

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

Friends And Related Symbol Documentation

◆ SubscriberImpl

friend class SubscriberImpl
friend

The documentation for this class was generated from the following file: