DataReader
A DataReader is attached to exactly one Subscriber that acts as a factory.
Additionally, each DataReader is bound to a single Topic since its creation.
This Topic must exist prior to the creation of the DataReader, and must be bound to the data type that the DataReader wants to receive.
The effect of creating a new DataReader in a Subscriber for a specific Topic is to initiate a new subscription with the name and data type described by the Topic.
Once the DataReader is created, the application will be informed when changes in the data value are received from remote or local publications.
These changes can then be retrieved using the TypedDataReader::take_next_sample member functions of the DataReader.
Note
In Safe DDS, the DataReader read operations shall be done through a TypedDataReader methods.
Refer to Using the TypedDataReader for more information.
DataReaderQos
DatareaderQos controls the behavior of the DataReader.
Internally it contains the following Policy objects:
durabilityas DurabilityQosPolicyDefines the durability of the DataReader.
deadlineas DeadlineQosPolicyDefines the deadline for the DataReader.
livelinessas LivelinessQosPolicyDefines the liveliness of the DataReader.
reliabilityas ReliabilityQosPolicyDefines the reliability of the DataReader.
historyas HistoryQosPolicyDefines the history of the DataReader.
resource_limitsas ResourceLimitsQosPolicyDefines the resource limits of the DataReader.
wire_protocol_qosas DataReaderWireProtocolQosPolicyThe configuration of the wire protocol.
allocationsas DataReaderAllocationsQosPolicyDefines the memory configuration of the DataReader.
Note
Check Memory management to understand how memory is managed in Safe DDS.
Example
// Construct DataReaderQos with default values
DataReaderQos datareader_qos{};
// Set DurabilityQosPolicy
datareader_qos.durability().kind = DurabilityQosPolicyKind::TRANSIENT_DURABILITY_QOS;
// Set DeadlineQosPolicy
datareader_qos.deadline().period = {1, 0};
// Set LivelinessQosPolicy
datareader_qos.liveliness().kind = LivelinessQosPolicyKind::AUTOMATIC_LIVELINESS_QOS;
datareader_qos.liveliness().lease_duration = {1, 0};
// Set ReliabilityQosPolicy
datareader_qos.reliability().kind = ReliabilityQosPolicyKind::BEST_EFFORT_RELIABILITY_QOS;
// Set HistoryQosPolicy
datareader_qos.history().kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
datareader_qos.history().depth = 10;
// Set ResourceLimitsQosPolicy
datareader_qos.resource_limits().max_instances = 10;
datareader_qos.resource_limits().max_samples_per_instance = 3;
datareader_qos.resource_limits().max_samples = 1000;
// Set wire protocol configuration
datareader_qos.wire_protocol_qos().output_integrity =
protocol::OutputIntegrityCheck::OUTPUT_INTEGRITY_CHECK_ENABLED;
// Set DataReaderAllocationsQosPolicy memory configuration
datareader_qos.allocations().preallocated_instances = 10;