Function dds_take

Function Documentation

dds_return_t dds_take(dds_entity_t reader_or_condition, void **buf, dds_sample_info_t *si, size_t bufsz, uint32_t maxs)

Access the collection of data values (of same type) and sample info from the data reader, readcondition or querycondition.

Data value once read is removed from the Data Reader cannot to ‘read’ or ‘taken’ again. Return value provides information about number of samples read, which will be <= maxs. Based on the count, the buffer will contain data to be read only when valid_data bit in sample info structure is set. The buffer required for data values, could be allocated explicitly or can use the memory from data reader to prevent copy. In the latter case, buffer and sample_info should be returned back, once it is no longer using the Data.

Parameters
  • reader_or_condition[in] Reader, readcondition or querycondition entity.

  • buf[out] An array of pointers to samples into which data is read (pointers can be NULL).

  • si[out] Pointer to an array of dds_sample_info_t returned for each data value.

  • bufsz[in] The size of buffer provided.

  • maxs[in] Maximum number of samples to read.

Return values
  • >=0 – Number of samples read.

  • DDS_RETCODE_ERROR – An internal error has occurred.

  • DDS_RETCODE_BAD_PARAMETER – One of the given arguments is not valid.

  • DDS_RETCODE_ILLEGAL_OPERATION – The operation is invoked on an inappropriate object.

  • DDS_RETCODE_ALREADY_DELETED – The entity has already been deleted.

Returns

A dds_return_t with the number of samples read or an error code.