Chapter 40 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 Table 40.1 DataReader Operations. 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 40.4 Setting Up DataReaderListeners.
DataReaders are created by using operations on a DomainParticipant or a Subscriber, as described in 39.1 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 15.8.8.1 Restricted Operations in Listener Callbacks.
Purpose |
Operation |
Description |
Reference |
Configuring the DataReader |
enable |
Enables the DataReader. |
|
equals |
Compares two DataReader’s QoS structures for equality. |
||
get_qos |
Gets the QoS. |
||
set_qos |
Modifies the QoS. |
||
set_qos_with_profile |
Modifies the QoS based on a QoS profile. |
||
get_listener |
Gets the currently installed Listener. |
||
set_listener |
Replaces the Listener. |
||
Accessing DDS Data (Use |
read |
Reads (copies) a collection of DDS data samples from the DataReader. |
|
read_instance |
Identical to read, but all DDS samples returned belong to a single instance, which you specify as a parameter. |
||
read_instance_w_condition |
Identical to read_instance, but all DDS samples returned belong to a single instance and satisfy a specific ReadCondition. |
41.3.7 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_w_ |
Accesses a collection of DDS data samples of the next instance that match a specific set of ReadConditions, from the DataReader. |
41.3.8 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_w_condition |
Accesses a collection of DDS data samples from the DataReader that match specific ReadCondition criteria. |
||
Accessing DDS Data (Use |
take |
Like read, but the DDS samples are removed from the DataReader’s receive queue. |
|
take_instance |
Identical to take, but all DDS samples returned belong to a single instance, which you specify as a parameter. |
||
take_instance_w_condition |
Identical to take_instance, but all DDS samples returned belong to a single instance and satisfy a specific ReadCondition. |
41.3.7 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. |
||
take_next_instance_w_ |
Accesses (and removes) a collection of DDS data samples of the next instance that match a specific set of ReadConditions, from the DataReader. |
41.3.8 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. |
||
take_w_condition |
Accesses (and removes) a collection of DDS data samples from the DataReader that match specific ReadCondition criteria. |
||
Working with DDS Data Samples and FooData-Reader (Use FooData-Reader, see 41.3 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. |
|
return_loan |
Returns buffers loaned in a previous read or take call. |
||
get_key_value |
Gets the key for an instance handle. |
||
lookup_instance |
Gets the instance handle that corresponds to an instance key. |
||
Acknowledging DDS Samples |
acknowledge_all |
Acknowledge all previously accessed DDS samples. |
|
acknowledge_sample |
Acknowledge a single DDS sample. |
||
Checking Status |
get_liveliness_changed_ |
Gets LIVELINESS_CHANGED_STATUS |
|
get_requested_deadline_ |
Gets REQUESTED_DEADLINE_ |
||
get_requested_ |
Gets REQUESTED_INCOMPATIBLE_ |
||
get_sample_lost_status |
Gets SAMPLE_LOST_STATUS status. |
||
get_sample_rejected_ |
Gets SAMPLE_REJECTED_STATUS status. |
||
get_subscription_matched_ |
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. |
||
get_datareader_cache_ |
Gets DATA_READER_CACHE_STATUS status. |
||
get_datareader_protocol_ |
Gets DATA_READER_PROTOCOL_ |
||
get_matched_publication_ |
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. |
|
get_matched_publication_ |
Gets information on a publication with a matching Topic and compatible QoS. |
||
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_ |
Gets information on a DomainParticipant of a matching publication. |
40.10.2 Finding the Matching Publication’s ParticipantBuiltinTopicData |
|
get_subscriber |
Gets the Subscriber that created the DataReader. |
||
get_topicdescription |
Gets the Topic associated with the DataReader. |
||
is_matched_publication_alive |
Enables you to query whether the matched DataWriter (using the instance handle returned by get_matched_publications) is alive. get_matched_publications returns all matching DataWriters, including those that are not alive. This operation enables you to see which matching DataWriters are alive. |
||
Working with |
create_querycondition |
Creates a QueryCondition. |
|
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. |
||
get_statuscondition |
Gets the StatusCondition associated with the Entity. |
||
create_readcondition_w_params |
Creates a ReadCondition with parameters. |
||
create_querycondition_w_params |
Creates a QueryCondition with parameters. |
||
Working with TopicQueries |
create_topic_query |
Creates a TopicQuery. The returned TopicQuery will haven been issued if the DataReader is enabled. Otherwise, the TopicQuery will be issued once the DataReader is enabled. |
|
delete_topic_query |
Deletes an active TopicQuery. After deleting a TopicQuery, new DataWriters won't discover it and existing DataWriters currently publishing cached samples may stop before delivering all of them. |
||
lookup_topic_query |
Retrieves the TopicQuery that corresponds to the input GUID. To get the GUID associated with a TopicQuery, use the TopicQuery's get_guid(). |
||
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. |