You are here: Part 2: Core Concepts > Receiving Data > DataReaders

DataReaders

To create a DataReader, you need a DomainParticipant, a Topic, and optionally, a Subscriber. You need at least one DataReader for each Topic whose DDS data samples you want to receive.

After you create a DataReader, you will be able to use the operations listed in . You are likely to use many of these operations from within your DataReader’s Listener, which is invoked when there are status changes or new DDS data samples. For more details on all operations, see the API reference HTML documentation. The DataReaderListener is described in Setting Up DataReaderListeners.

DataReaders are created by using operations on a DomainParticipant or a Subscriber, as described in Creating Subscribers Explicitly vs. Implicitly. If you use the DomainParticipant’s operations, the DataReader will belong to an implicit Subscriber that is automatically created by the middleware. If you use a Subscriber’s operations, the DataReader will belong to that Subscriber. So either way, the DataReader belongs to a Subscriber.

Note: Some operations cannot be used within a listener callback, see Restricted Operations in Listener Callbacks.

DataReader Operations

Purpose

Operation

Description

Reference

Configuring the
DataReader

enable

Enables the DataReader.

Enabling DDS Entities

equals

Compares two DataReader’s QoS structures for equality.

Comparing QoS Values

get_qos

Gets the QoS.

Setting DataReader QosPolicies

set_qos

Modifies the QoS.

set_qos_with_profile

Modifies the QoS based on a QoS profile.

get_listener

Gets the currently installed Listener.

Setting Up DataReaderListeners

set_listener

Replaces the Listener.

Accessing DDS Data
Samples with “Read”

(Use
FooData-Reader, see Accessing DDS Data Samples with Read or Take)

read

Reads (copies) a collection of DDS data samples from the DataReader.

Accessing DDS Data Samples with Read or Take

read_instance

Identical to read, but all DDS samples returned belong to a single instance, which you specify as a parameter.

read_instance and take_instance

read_instance_w_condition

Identical to read_instance, but all DDS samples returned belong to a single instance and satisfy a specific ReadCondition.

read_instance_w_condition and take_instance_w_condition

read_next_instance

Similar to read_instance, but the actual instance is not directly specified as a parameter. Instead, the DDS samples will all belong to instance ordered after the one previously read.

read_next_instance and take_next_instance

read_next_instance_w_
condition

Accesses a collection of DDS data samples of the next instance that match a specific set of ReadConditions, from the DataReader.

read_next_instance_w_condition and take_next_instance_w_condition

read_next_sample

Reads the next not-previously-accessed data value from the DataReader.

read_next_sample and take_next_sample

read_w_condition

Accesses a collection of DDS data samples from the DataReader that match specific ReadCondition criteria.

read_w_condition and take_w_condition

Accessing DDS Data
Samples with “Take”

(Use
FooData-Reader, see Accessing DDS Data Samples with Read or Take)

take

Like read, but the DDS samples are removed from the DataReader’s receive queue.

Accessing DDS Data Samples with Read or Take

take_instance

Identical to take, but all DDS samples returned belong to a single instance, which you specify as a parameter.

read_instance and take_instance

take_instance_w_condition

Identical to take_instance, but all DDS samples returned belong to a single instance and satisfy a specific ReadCondition.

read_instance_w_condition and take_instance_w_condition

take_next_instance

Like read_next_instance, but the DDS samples are removed from the DataReader’s receive queue.

read_next_instance and take_next_instance

take_next_instance_w_
condition

Accesses (and removes) a collection of DDS data samples of the next instance that match a specific set of ReadConditions, from the DataReader.

read_next_instance_w_condition and take_next_instance_w_condition

take_next_sample

Like read_next_sample, but the DDS samples are removed from the DataReader’s receive queue.

read_next_sample and take_next_sample

take_w_condition

Accesses (and removes) a collection of DDS data samples from the DataReader that match specific ReadCondition criteria.

read_w_condition and take_w_condition

Working with DDS Data Samples and FooData-Reader

(Use FooData-Reader, see Accessing DDS Data Samples with Read or Take)

narrow

A type-safe way to cast a pointer. This takes a DDSDataReader pointer and ‘narrows’ it to a ‘FooDataReader’ where ‘Foo’ is the related data type.

Using a Type-Specific DataReader (FooDataReader)

return_loan

Returns buffers loaned in a previous read or take call.

Loaning and Returning Data and SampleInfo Sequences

get_key_value

Gets the key for an instance handle.

Getting the Key Value for an Instance

lookup_instance

Gets the instance handle that corresponds to an instance key.

Looking Up an Instance Handle

Acknowledging DDS Samples

acknowledge_all

Acknowledge all previously accessed DDS samples.

Acknowledging DDS Samples

acknowledge_sample

Acknowledge a single DDS sample.

Checking Status

get_liveliness_changed_
status

Gets LIVELINESS_CHANGED_STATUS
status.

Statuses for DataReaders

get_requested_deadline_
missed_status

Gets REQUESTED_DEADLINE_
MISSED_STATUS status.

get_requested_
incompatible_qos_status

Gets REQUESTED_INCOMPATIBLE_
QOS_STATUS status.

get_sample_lost_status

Gets SAMPLE_LOST_STATUS status.

get_sample_rejected_
status

Gets SAMPLE_REJECTED_STATUS status.

get_subscription_matched_
status

Gets SUBSCRIPTION_MATCHED_STATUS status.

get_status_changes

Gets a list of statuses that changed since last time the application read the status or the listeners were called.

Getting Status and Status Changes

get_datareader_cache_
status

Gets DATA_READER_CACHE_STATUS status.

Checking DataReader Status and StatusConditions

Statuses for DataReaders

get_datareader_protocol_
status

Gets DATA_READER_PROTOCOL_
STATUS status.

get_matched_publication_
datareader_protocol_
status

Get the protocol status for this DataReader, per matched publication identified by the publication_handle.

Navigating Relationships

get_instance_handle

Returns the DDS_InstanceHandle_t associated with the Entity.

Getting an Entity’s Instance Handle

get_matched_publication_
data

Gets information on a publication with a matching Topic and compatible QoS.

Finding Matching Publications

get_matched_publications

Gets a list of publications that have a matching Topic and compatible QoS. These are the publications currently associated with the DataReader.

get_matched_publication_
participant_data

Gets information on a DomainParticipant of a matching publication.

Finding the Matching Publication’s ParticipantBuiltinTopicData

get_subscriber

Gets the Subscriber that created the DataReader.

Finding a DataReader’s Related Entities

get_topicdescription

Gets the Topic associated with the DataReader.

Working with
Conditions

create_querycondition

Creates a QueryCondition.

ReadConditions and QueryConditions

create_readcondition

Creates a ReadCondition.

delete_readcondition

Deletes a ReadCondition/QueryCondition attached to the DataReader.

delete_contained_entities

Deletes all the ReadConditions/QueryConditions that were created by means of the "create" operations on the DataReader.

Deleting Contained ReadConditions

get_statuscondition

Gets the StatusCondition associated with the Entity.

StatusConditions

Waiting for Historical Data

wait_for_historical_data

Waits until all "historical" (previously sent) data is received. Only valid for Reliable DataReaders with non-VOLATILE DURABILITY.

Waiting for Historical Data

© 2016 RTI