.. _dds_layers_subscription_datareader: DataReader ========== A ``DataReader`` is attached to exactly one :ref:`dds_layers_subscription_subscriber` that acts as a factory. Additionally, each DataReader is bound to a single :ref:`dds_layers_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 :ref:`dds_layer_publisher_typedDataReader` for more information. .. _dds_layers_datareader_qos: DataReaderQos ------------- ``DatareaderQos`` controls the behavior of the DataReader. Internally it contains the following :ref:`dds_layers_infrastructure_policies` objects: * ``durability`` as :ref:`durabilityqospolicy` Defines the durability of the DataReader. * ``deadline`` as :ref:`deadlineqospolicy` Defines the deadline for the DataReader. * ``liveliness`` as :ref:`livelinessqospolicy` Defines the liveliness of the DataReader. * ``reliability`` as :ref:`reliabilityqospolicy` Defines the reliability of the DataReader. * ``history`` as :ref:`historyqospolicy` Defines the history of the DataReader. * ``resource_limits`` as :ref:`resourcelimitsqospolicy` Defines the resource limits of the DataReader. * ``wire_protocol_qos`` as :ref:`dds_layers_infrastructure_safedds_policies_datareaderwireprotocolconfigqospolicy` The configuration of the wire protocol. * ``allocations`` as :ref:`dds_layers_infrastructure_safedds_policies_datareaderallocationsqospolicy` Defines the memory configuration of the DataReader. .. include:: ../../../safety_manual/rules/RULE_DATAREADER_WIREPROTOCOLCONFIGQOS.inc .. include:: ../../../safety_manual/rules/RULE_PREALLOCMEMORYCONFIG.inc .. note:: Check :ref:`architecture_platform_memory_management` to understand how memory is managed in Safe DDS. Example ^^^^^^^ .. literalinclude:: ../../../code/policies_examples/main.cpp :language: c++ :dedent: 8 :start-after: // DDS_DATAREADER_QOS :end-before: //! DDS_DATAREADER_QOS