Skip to main content

dds_create_reader

Function dds_create_reader 

Source
pub unsafe extern "C" fn dds_create_reader(
    participant_or_subscriber: dds_entity_t,
    topic: dds_entity_t,
    qos: *const dds_qos_t,
    listener: *const dds_listener_t,
) -> dds_entity_t
Expand description

@brief Creates a new instance of a DDS reader. @ingroup reader @component reader

When a participant is used to create a reader for a normal topic, an implicit subscriber is created as the reader’s parent. This implicit subscriber is deleted automatically when its last child is deleted, which is when the created reader is deleted unless additional children were added to the implicit subscriber. It is also deleted as part of the recursive deletion of the participant.

The topic may be a normal topic handle or one of the built-in topic pseudo handles:

  • @ref DDS_BUILTIN_TOPIC_DCPSPARTICIPANT reads @ref dds_builtintopic_participant_t samples.
  • @ref DDS_BUILTIN_TOPIC_DCPSTOPIC reads @ref dds_builtintopic_topic_t samples.
  • @ref DDS_BUILTIN_TOPIC_DCPSPUBLICATION reads @ref dds_builtintopic_endpoint_t samples for writers.
  • @ref DDS_BUILTIN_TOPIC_DCPSSUBSCRIPTION reads @ref dds_builtintopic_endpoint_t samples for readers.

Creating a reader for a built-in topic uses the participant’s built-in subscriber. If a subscriber is provided, its participant is used to locate that built-in subscriber; the provided subscriber itself does not become the parent of the reader. The built-in subscriber is shared by built-in topic readers for that participant and is deleted when the participant is deleted, not when an individual built-in topic reader is deleted. The built-in topic handles are pseudo handles, not normal topic entities: @ref dds_get_topic on such a reader returns the same pseudo handle, and the internal topic entity cannot be used directly to create another reader.

Reader QoS for built-in topics must be compatible with the corresponding built-in topic writer and must not impose resource limits, because otherwise discovery data could be rejected. When @p qos is NULL, Cyclone DDS supplies a compatible default built-in topic QoS. The DCPSTopic built-in topic is only available when Cyclone DDS was built with topic discovery support; otherwise creating a reader for @ref DDS_BUILTIN_TOPIC_DCPSTOPIC returns @ref DDS_RETCODE_UNSUPPORTED.

@param[in] participant_or_subscriber The participant or subscriber on which the reader is being created. @param[in] topic The topic to read, or a built-in topic pseudo handle. @param[in] qos The QoS to set on the new reader (can be NULL). @param[in] listener Any listener functions associated with the new reader (can be NULL).

@returns A valid reader handle or an error code.

@retval >0 A valid reader handle. @retval DDS_RETCODE_ERROR An internal error occurred. @retval DDS_RETCODE_BAD_PARAMETER One of the parameters is invalid, or the participant and topic do not belong to the same domain participant. @retval DDS_RETCODE_ILLEGAL_OPERATION participant_or_subscriber is neither a participant nor a subscriber, or the operation is otherwise inappropriate for the supplied entity. @retval DDS_RETCODE_INCONSISTENT_POLICY The requested QoS is inconsistent, including a built-in topic reader QoS that is incompatible with the built-in topic writer or has finite resource limits. @retval DDS_RETCODE_UNSUPPORTED The requested built-in topic requires a feature that is not enabled in this build, such as topic discovery for @ref DDS_BUILTIN_TOPIC_DCPSTOPIC. @retval DDS_RETCODE_NOT_ALLOWED_BY_SECURITY The configured DDS Security access control plugin denied creation of the reader.