18.2.9.2. RTPSReader

class RTPSReader : public eprosima::fastrtps::rtps::Endpoint, public eprosima::fastdds::statistics::StatisticsReaderImpl

Class RTPSReader, manages the reception of data from its matched writers.

Subclassed by eprosima::fastrtps::rtps::StatefulReader, eprosima::fastrtps::rtps::StatelessReader

Public Functions

virtual bool matched_writer_add(const WriterProxyData &wdata) = 0

Add a matched writer represented by its attributes.

Parameters

wdata – Attributes of the writer to add.

Returns

True if correctly added.

virtual bool matched_writer_remove(const GUID_t &writer_guid, bool removed_by_lease = false) = 0

Remove a writer represented by its attributes from the matched writers.

Parameters
  • writer_guid – GUID of the writer to remove.

  • removed_by_lease – Whether the writer is being unmatched due to a participant drop.

Returns

True if correctly removed.

virtual bool matched_writer_is_matched(const GUID_t &writer_guid) = 0

Tells us if a specific Writer is matched against this reader.

Parameters

writer_guid – GUID of the writer to check.

Returns

True if it is matched.

virtual bool processDataMsg(CacheChange_t *change) = 0

Processes a new DATA message. Previously the message must have been accepted by function acceptMsgDirectedTo.

Parameters

change – Pointer to the CacheChange_t.

Returns

true if the reader accepts messages from the.

virtual bool processDataFragMsg(CacheChange_t *change, uint32_t sampleSize, uint32_t fragmentStartingNum, uint16_t fragmentsInSubmessage) = 0

Processes a new DATA FRAG message.

Parameters
  • change – Pointer to the CacheChange_t.

  • sampleSize – Size of the complete, assembled message.

  • fragmentStartingNum – Starting number of this particular message.

  • fragmentsInSubmessage – Number of fragments on this particular message.

Returns

true if the reader accepts message.

virtual bool processHeartbeatMsg(const GUID_t &writerGUID, uint32_t hbCount, const SequenceNumber_t &firstSN, const SequenceNumber_t &lastSN, bool finalFlag, bool livelinessFlag, fastdds::rtps::VendorId_t origin_vendor_id = c_VendorId_Unknown) = 0

Processes a new HEARTBEAT message.

Parameters
  • writerGUID

  • hbCount

  • firstSN

  • lastSN

  • finalFlag

  • livelinessFlag

  • origin_vendor_id

Returns

true if the reader accepts messages from the.

virtual bool processGapMsg(const GUID_t &writerGUID, const SequenceNumber_t &gapStart, const SequenceNumberSet_t &gapList, fastdds::rtps::VendorId_t origin_vendor_id = c_VendorId_Unknown) = 0

Processes a new GAP message.

Parameters
  • writerGUID

  • gapStart

  • gapList

  • origin_vendor_id

Returns

true if the reader accepts messages from the.

virtual bool change_removed_by_history(CacheChange_t *change, WriterProxy *prox = nullptr) = 0

Method to indicate the reader that some change has been removed due to HistoryQos requirements.

Parameters
  • change – Pointer to the CacheChange_t.

  • prox – Pointer to the WriterProxy.

Returns

True if correctly removed.

ReaderListener *getListener() const

Get the associated listener, secondary attached Listener in case it is of compound type

Returns

Pointer to the associated reader listener.

bool setListener(ReaderListener *target)

Switch the ReaderListener kind for the Reader. If the RTPSReader does not belong to the built-in protocols it switches out the old one. If it belongs to the built-in protocols, it sets the new ReaderListener callbacks to be called after the built-in ReaderListener ones.

Parameters

target – Pointed to ReaderLister to attach

Returns

True is correctly set.

bool reserveCache(CacheChange_t **change, uint32_t dataCdrSerializedSize)

Reserve a CacheChange_t.

Parameters
  • change – Pointer to pointer to the Cache.

  • dataCdrSerializedSize – Size of the Cache.

Returns

True if correctly reserved.

void releaseCache(CacheChange_t *change)

Release a cacheChange.

virtual bool nextUnreadCache(CacheChange_t **change, WriterProxy **wp) = 0

Read the next unread CacheChange_t from the history

Parameters
  • change – Pointer to pointer of CacheChange_t

  • wp – Pointer to pointer to the WriterProxy

Returns

True if read.

virtual bool nextUntakenCache(CacheChange_t **change, WriterProxy **wp) = 0

Get the next CacheChange_t from the history to take.

Parameters
  • change – Pointer to pointer of CacheChange_t.

  • wp – Pointer to pointer to the WriterProxy.

Returns

True if read.

inline bool expectsInlineQos()
Returns

True if the reader expects Inline QOS.

inline ReaderHistory *getHistory()

Returns a pointer to the associated History.

inline eprosima::fastdds::rtps::IReaderDataFilter *get_content_filter() const
Returns

The content filter associated to this reader.

inline void set_content_filter(eprosima::fastdds::rtps::IReaderDataFilter *filter)

Set the content filter associated to this reader.

Parameters

filter – Pointer to the content filter to associate to this reader.

virtual bool isInCleanState() = 0

Returns there is a clean state with all Writers.

It occurs when the Reader received all samples sent by Writers. In other words, its WriterProxies are up to date.

Returns

There is a clean state with all Writers.

virtual void assert_writer_liveliness(const GUID_t &writer) = 0

Assert the liveliness of a matched writer.

Parameters

writer – GUID of the writer to assert.

virtual bool begin_sample_access_nts(CacheChange_t *change, WriterProxy *&wp, bool &is_future_change) = 0

Called just before a change is going to be deserialized.

Parameters
  • change[in] Pointer to the change being accessed.

  • wp[out] Writer proxy the change belongs to.

  • is_future_change[out] Whether the change is in the future (i.e. there are earlier unreceived changes from the same writer).

Returns

Whether the change is still valid or not.

virtual void end_sample_access_nts(CacheChange_t *change, WriterProxy *&wp, bool mark_as_read) = 0

Called after the change has been deserialized.

Parameters
  • change[in] Pointer to the change being accessed.

  • wp[in] Writer proxy the change belongs to.

  • mark_as_read[in] Whether the change should be marked as read or not.

virtual void change_read_by_user(CacheChange_t *change, WriterProxy *writer, bool mark_as_read = true) = 0

Called when the user has retrieved a change from the history.

Parameters
  • change – Pointer to the change to ACK

  • writer – Writer proxy of the change.

  • mark_as_read – Whether the change should be marked as read or not

bool is_sample_valid(const void *data, const GUID_t &writer, const SequenceNumber_t &sn) const

Checks whether the sample is still valid or is corrupted.

Parameters
  • data – Pointer to the sample data to check. If it does not belong to the payload pool passed to the reader on construction, it yields undefined behavior.

  • writer – GUID of the writer that sent data.

  • sn – Sequence number related to data.

Returns

true if the sample is valid

Public Members

LivelinessChangedStatus liveliness_changed_status_

The liveliness changed status struct as defined in the DDS.