This commit is contained in:
2025-09-24 10:53:28 +08:00
commit f8e4df77fb
856 changed files with 140098 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
/*
* Copyright(c) 2006 to 2022 ZettaScale Technology and others
* Copyright(c) 2021 Apex.AI, Inc
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef _DDS_BASIC_TYPES_H_
#define _DDS_BASIC_TYPES_H_
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
/**
* @brief Handle to an entity
* @ingroup entity
*
* A valid entity handle will always have a positive integer value.
* Should the value be negative, it is one of the DDS_RETCODE_*
* error codes.
*/
typedef int32_t dds_entity_t;
/**
* @anchor DDS_MIN_PSEUDO_HANDLE
* @ingroup internal
* @brief Pseudo Handle origin
*
* Some handles in CycloneDDS are 'fake', most importantly the builtin topic handles.
* These handles are derived from this constant.
*/
#define DDS_MIN_PSEUDO_HANDLE ((dds_entity_t)0x7fff0000)
/**
* @anchor DDS_CYCLONEDDS_HANDLE
* @ingroup internal
* @brief Special handle representing the entity corresponding to the CycloneDDS library itself
*/
#define DDS_CYCLONEDDS_HANDLE ((dds_entity_t)(DDS_MIN_PSEUDO_HANDLE + 256))
#endif /*_DDS_PUBLIC_TYPES_H_*/

View File

@@ -0,0 +1,149 @@
/*
* Copyright(c) 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef DDS_DATA_ALLOCATOR_H
#define DDS_DATA_ALLOCATOR_H
/**
* @defgroup data_allocator (Data Allocator)
* @ingroup dds
* A quick-and-dirty provisional interface
*/
#include "dds/dds.h"
#include "dds/ddsrt/attributes.h"
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
// macOS' mutexes require quite a lot of space, but it is not quite enough
// to make this system-dependent
#define DDS_DATA_ALLOCATOR_MAX_SIZE (12 * sizeof (void *))
/**
* @ingroup data_allocator
* @brief Data Allocator structure
* Contains internal details about the data allocator for a given entity
*/
typedef struct dds_data_allocator {
dds_entity_t entity; /**< to which entity this allocator is attached */
union {
unsigned char bytes[DDS_DATA_ALLOCATOR_MAX_SIZE]; /**< internal details */
void *align_ptr; /**< internal details */
uint64_t align_u64; /**< internal details */
} opaque; /**< internal details */
} dds_data_allocator_t;
/**
* @ingroup data_allocator
* @brief Initialize an object for performing allocations/frees in the context of a reader/writer
*
* The operation will fall back to standard heap allocation if nothing better is available.
*
* @param[in] entity the handle of the entity
* @param[out] data_allocator opaque allocator object to initialize
*
* @returns success or a generic error indication
*
* @retval DDS_RETCODE_OK
* the allocator object was successfully initialized
* @retval DDS_RETCODE_BAD_PARAMETER
* entity is invalid, data_allocator is a null pointer
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* Cyclone DDS is not initialized
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* operation not supported on this entity
*/
DDS_EXPORT dds_return_t dds_data_allocator_init (dds_entity_t entity, dds_data_allocator_t *data_allocator);
/**
* @ingroup data_allocator
* @brief Initialize an object for performing standard allocations/frees on the heap
*
* @param[out] data_allocator opaque allocator object to initialize
*
* @returns success or a generic error indication
*
* @retval DDS_RETCODE_OK
* the allocator object was successfully initialized
* @retval DDS_RETCODE_BAD_PARAMETER
* entity is invalid, data_allocator is a null pointer
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* Cyclone DDS is not initialized
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* operation not supported on this entity
*/
DDS_EXPORT dds_return_t dds_data_allocator_init_heap (dds_data_allocator_t *data_allocator);
/**
* @ingroup data_allocator
* @brief Finalize a previously initialized allocator object
*
* @param[in,out] data_allocator object to finalize
*
* @returns success or an error indication
*
* @retval DDS_RETCODE_OK
* the data was successfully finalized
* @retval DDS_RETCODE_BAD_PARAMETER
* data_allocator does not reference a valid entity
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* Cyclone DDS is not initialized
*/
DDS_EXPORT dds_return_t dds_data_allocator_fini (dds_data_allocator_t *data_allocator);
/**
* @ingroup data_allocator
* @brief Allocate memory using the given allocator
*
* @param[in,out] data_allocator initialized allocator object
* @param[in] size minimum number of bytes to allocate with suitable alignment
*
* @returns a pointer to unaliased, uninitialized memory of at least the requested size, or NULL
*/
DDS_EXPORT void *dds_data_allocator_alloc (dds_data_allocator_t *data_allocator, size_t size)
ddsrt_attribute_warn_unused_result ddsrt_attribute_malloc;
/**
* @ingroup data_allocator
* @brief Release memory using the given allocator
*
* @param[in,out] data_allocator initialized allocator object
* @param[in] ptr memory to free
*
* @returns success or an error indication
*
* @retval DDS_RETCODE_OK
* the memory was successfully released
* @retval DDS_RETCODE_BAD_PARAMETER
* data_allocator does not reference a valid entity
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* dds_data_allocator already finalized
*/
DDS_EXPORT dds_return_t dds_data_allocator_free (dds_data_allocator_t *data_allocator, void *ptr);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/// @note This function declaration is deprecated here and has been moved to
/// dds_loan_api.h.
DDS_EXPORT bool dds_is_loan_available(const dds_entity_t entity);
/// @note This function declaration is deprecated here and has been moved to
/// dds_loan_api.h.
DDS_EXPORT bool is_loan_available(const dds_entity_t entity);
#endif
#if defined (__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,56 @@
/*
* Copyright(c) 2006 to 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/*
* WARNING This file is only needed for the work around for https://github.com/eclipse-cyclonedds/cyclonedds/issues/74
* Do not include this file in an application! Once issue #74 is solved this header file should be removed.
*/
#ifndef DDS_INTERNAL_API_H
#define DDS_INTERNAL_API_H
#if defined (__cplusplus)
extern "C" {
#endif
/**
* @anchor DDS_READ_WITHOUT_LOCK
* @ingroup internal
* @brief Constant to use with dds_read() or dds_take() when using dds_reader_lock_samples()
*/
#define DDS_READ_WITHOUT_LOCK (0xFFFFFFED)
/**
* @ingroup internal
* @brief Returns number of samples in read cache and locks the reader cache,
* to make sure that the samples content doesn't change.
*
* Because the cache is locked, you should be able to read/take without having to
* lock first. This is done by passing the @ref DDS_READ_WITHOUT_LOCK value to the
* read/take call as maxs. Then the read/take will not lock but still unlock.
*
* CycloneDDS doesn't support a read/take that just returns all
* available samples issue #74. As a work around to support LENGTH_UNLIMITED in C++.
* dds_reader_lock_samples() and @ref DDS_READ_WITHOUT_LOCK are needed.
*
* @param[in] reader Reader to lock the cache of.
*
* @returns the number of samples in the reader cache.
*/
DDS_EXPORT uint32_t
dds_reader_lock_samples (dds_entity_t reader);
#if defined (__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,95 @@
/*
* Copyright(c) 2021 ZettaScale Technology
* Copyright(c) 2021 Apex.AI, Inc
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// API extension
// defines functions needed for loaning and shared memory usage
#ifndef _DDS_LOAN_API_H_
#define _DDS_LOAN_API_H_
#include "dds/ddsc/dds_basic_types.h"
#include "dds/ddsrt/retcode.h"
#include "dds/export.h"
#if defined(__cplusplus)
extern "C" {
#endif
/**
* @ingroup loan
* @brief Check if a Loan is available to reader/writer
* The loan is available if the shared memory is enabled and all the constraints
* to enable shared memory are met and the type is fixed
* @note dds_loan_sample can be used if and only if
* dds_is_loan_available returns true.
*
* @param[in] entity the handle of the entity
*
* @returns loan available or not
*/
DDS_EXPORT bool dds_is_loan_available(const dds_entity_t entity);
/**
* @ingroup loan
* @brief Check if a shared memory is available to reader/writer.
*
* @note dds_loan_shared_memory_buffer can be used if and only if
* dds_is_shared_memory_available returns true.
*
* @param[in] entity the handle of the entity
*
* @returns true if shared memory is available, false otherwise
*/
DDS_EXPORT bool dds_is_shared_memory_available(const dds_entity_t entity);
DDS_DEPRECATED_EXPORT bool is_loan_available(const dds_entity_t entity);
/**
* @ingroup loan
* @brief Loan a shared memory buffer of a specific size from the writer.
*
* @note Currently this function is to be used with dds_writecdr by adding the
* loaned buffer to serdata as iox_chunk.
* @note The function can only be used if dds_is_shared_memory_available is
* true for the writer.
*
* @param[in] writer the writer to loan the buffer from
* @param[in] size the requested buffer size
* @param[out] buffer the loaned buffer
*
* @returns DDS_RETCODE_OK if successful, DDS_RETCODE_ERROR otherwise
*/
DDS_EXPORT dds_return_t dds_loan_shared_memory_buffer(dds_entity_t writer,
size_t size,
void **buffer);
/**
* @ingroup loan
* @brief Loan a sample from the writer.
*
* @note This function is to be used with dds_write to publish the loaned
* sample.
* @note The function can only be used if dds_is_loan_available is
* true for the writer.
*
* @param[in] writer the writer to loan the buffer from
* @param[out] sample the loaned sample
*
* @returns DDS_RETCODE_OK if successful, DDS_RETCODE_ERROR otherwise
*/
DDS_EXPORT dds_return_t dds_loan_sample(dds_entity_t writer, void **sample);
#if defined(__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,626 @@
/*
* Copyright(c) 2021 to 2022 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef DDS_OPCODES_H
#define DDS_OPCODES_H
#include "dds/ddsrt/align.h"
#include "dds/ddsrt/static_assert.h"
#if defined (__cplusplus)
extern "C" {
#endif
/**
* @defgroup serialization (Serialization)
* @ingroup dds
*
* Opcodes for (de)serialization of types generated by idlc. Isolated in a
* separate header to share with idlc without the need to pull in the entire
* Eclipse Cyclone DDS C language binding.
*
* One opcode is a uint32 and depending on which code it is can contain several uint32 arguments.
*/
/**
* @anchor DDS_OP_MASK
* @ingroup serialization
* @brief Mask for the OP
*/
#define DDS_OP_MASK 0xff000000
/**
* @anchor DDS_OP_TYPE_FLAGS_MASK
* @ingroup serialization
* @brief Mask for the OP type flags
*/
#define DDS_OP_TYPE_FLAGS_MASK 0x00800000
/**
* @anchor DDS_OP_TYPE_MASK
* @ingroup serialization
* @brief Mask for the OP type
*/
#define DDS_OP_TYPE_MASK 0x007f0000
/**
* @anchor DDS_OP_SUBTYPE_MASK
* @ingroup serialization
* @brief Mask for the OP subtype
*/
#define DDS_OP_SUBTYPE_MASK 0x0000ff00
/**
* @anchor DDS_OP_JMP_MASK
* @ingroup serialization
* @brief Mask for the OP jump
*/
#define DDS_OP_JMP_MASK 0x0000ffff
/**
* @anchor DDS_OP_FLAGS_MASK
* @ingroup serialization
* @brief Mask for the OP flags
*/
#define DDS_OP_FLAGS_MASK 0x000000ff
/**
* @anchor DDS_JEQ_TYPE_FLAGS_MASK
* @ingroup serialization
* @brief Mask for the JEQ type flags
*/
#define DDS_JEQ_TYPE_FLAGS_MASK 0x00800000
/**
* @anchor DDS_JEQ_TYPE_MASK
* @ingroup serialization
* @brief Mask for the JEQ type
*/
#define DDS_JEQ_TYPE_MASK 0x007f0000
/**
* @anchor DDS_PLM_FLAGS_MASK
* @ingroup serialization
* @brief Mask for the PLM flags
*/
#define DDS_PLM_FLAGS_MASK 0x00ff0000
/**
* @anchor DDS_KOF_OFFSET_MASK
* @ingroup serialization
* @brief Mask for the KOF offset
*/
#define DDS_KOF_OFFSET_MASK 0x0000ffff
/**
* @anchor DDS_OP
* @ingroup serialization
* @brief Extract the DDS OP from a uint32 as a \ref dds_stream_opcode
*/
#define DDS_OP(o) ((enum dds_stream_opcode) ((o) & DDS_OP_MASK))
/**
* @anchor DDS_OP_TYPE
* @ingroup serialization
* @brief Extract the DDS OP_TYPE from a uint32 as a \ref dds_stream_typecode
*/
#define DDS_OP_TYPE(o) ((enum dds_stream_typecode) (((o) & DDS_OP_TYPE_MASK) >> 16))
/**
* @anchor DDS_OP_TYPE_FLAGS
* @ingroup serialization
* @brief Extract the DDS OP_TYPE_FLAGS from a uint32
* DOC_TODO: possible values?
*/
#define DDS_OP_TYPE_FLAGS(o) ((o) & DDS_OP_TYPE_FLAGS_MASK)
/**
* @anchor DDS_OP_SUBTYPE
* @ingroup serialization
* @brief Extract the DDS OP_SUBTYPE from a uint32 as a \ref dds_stream_typecode
* Used for collections, the OP_TYPE is array/sequence
*/
#define DDS_OP_SUBTYPE(o) ((enum dds_stream_typecode) (((o) & DDS_OP_SUBTYPE_MASK) >> 8))
/**
* @anchor DDS_OP_FLAGS
* @ingroup serialization
* @brief Extract the DDS OP_FLAGS from a uint32
* DOC_TODO: possible values?
*/
#define DDS_OP_FLAGS(o) ((o) & DDS_OP_FLAGS_MASK)
/**
* @anchor DDS_OP_ADR_JSR
* @ingroup serialization
* @brief Extract the ADR JSR from a uint32
* DOC_TODO: meaning?
*/
#define DDS_OP_ADR_JSR(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
/**
* @anchor DDS_OP_ADR_PLM
* @ingroup serialization
* @brief Extract the ADR PLM from a uint32
* DOC_TODO: meaning?
*/
#define DDS_OP_ADR_PLM(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
/**
* @anchor DDS_OP_LENGTH
* @ingroup serialization
* @brief Extract the LENGTH from a uint32
* DOC_TODO: meaning?
*/
#define DDS_OP_LENGTH(o) ((uint16_t) ((o) & DDS_OP_JMP_MASK))
/**
* @anchor DDS_OP_JUMP
* @ingroup serialization
* @brief Extract the JUMP from a uint32
* DOC_TODO: meaning?
*/
#define DDS_OP_JUMP(o) ((int16_t) ((o) & DDS_OP_JMP_MASK))
/**
* @anchor DDS_OP_ADR_JMP
* @ingroup serialization
* @brief Extract the ADR_JMP from a uint32
* DOC_TODO: meaning?
*/
#define DDS_OP_ADR_JMP(o) ((o) >> 16)
/**
* @anchor DDS_JEQ_TYPE
* @ingroup serialization
* @brief Extract the JEQ_TYPE from a uint32 as a \ref dds_stream_typecode
* DOC_TODO: meaning?
*/
#define DDS_JEQ_TYPE(o) ((enum dds_stream_typecode) (((o) & DDS_JEQ_TYPE_MASK) >> 16))
/**
* @anchor DDS_JEQ_TYPE_FLAGS
* @ingroup serialization
* @brief Extract the JEQ_TYPE_FLAGS from a uint32
* DOC_TODO: meaning?
*/
#define DDS_JEQ_TYPE_FLAGS(o) ((o) & DDS_JEQ_TYPE_FLAGS_MASK)
/**
* @anchor DDS_PLM_FLAGS
* @ingroup serialization
* @brief Extract the PLM_FLAGS from a uint32 as a \ref dds_stream_typecode
* DOC_TODO: meaning?
*/
#define DDS_PLM_FLAGS(o) ((enum dds_stream_typecode) (((o) & DDS_PLM_FLAGS_MASK) >> 16))
/**
* @ingroup serialization
* @brief Topic encoding instruction types
*/
enum dds_stream_opcode {
/** return from subroutine, exits top-level
[RTS, 0, 0, 0] */
DDS_OP_RTS = 0x00 << 24,
/** data field
[ADR, nBY, 0, f] [offset]
[ADR, BLN, 0, f] [offset]
[ADR, ENU, 0, f] [offset] [max]
[ADR, BMK, 0, f] [offset] [bits-high] [bits-low]
[ADR, STR, 0, f] [offset]
[ADR, BST, 0, f] [offset] [max-size]
[ADR, SEQ, nBY, f] [offset]
[ADR, SEQ, BLN, f] [offset]
[ADR, SEQ, ENU, f] [offset] [max]
[ADR, SEQ, BMK, f] [offset] [bits-high] [bits-low]
[ADR, SEQ, STR, f] [offset]
[ADR, SEQ, BST, f] [offset] [max-size]
[ADR, SEQ, s, f] [offset] [elem-size] [next-insn, elem-insn]
where s = {SEQ,ARR,UNI,STU,BSQ}
[ADR, SEQ, EXT, f] *** not supported
[ADR, BSQ, nBY, f] [offset] [sbound]
[ADR, BSQ, BLN, f] [offset] [sbound]
[ADR, BSQ, ENU, f] [offset] [sbound] [max]
[ADR, BSQ, BMK, f] [offset] [sbound] [bits-high] [bits-low]
[ADR, BSQ, STR, f] [offset] [sbound]
[ADR, BSQ, BST, f] [offset] [sbound] [max-size]
[ADR, BSQ, s, f] [offset] [sbound] [elem-size] [next-insn, elem-insn]
where s = {SEQ,ARR,UNI,STU,BSQ}
[ADR, BSQ, EXT, f] *** not supported
[ADR, ARR, nBY, f] [offset] [alen]
[ADR, ARR, BLN, f] [offset] [alen]
[ADR, ARR, ENU, f] [offset] [alen] [max]
[ADR, ARR, BMK, f] [offset] [alen] [bits-high] [bits-low]
[ADR, ARR, STR, f] [offset] [alen]
[ADR, ARR, BST, f] [offset] [alen] [0] [max-size]
[ADR, ARR, s, f] [offset] [alen] [next-insn, elem-insn] [elem-size]
where s = {SEQ,ARR,UNI,STU,BSQ}
[ADR, ARR, EXT, f] *** not supported
[ADR, UNI, d, z] [offset] [alen] [next-insn, cases]
[ADR, UNI, ENU, z] [offset] [alen] [next-insn, cases] [max]
[ADR, UNI, EXT, f] *** not supported
where
d = discriminant type of {1BY,2BY,4BY,BLN}
z = default present/not present (DDS_OP_FLAG_DEF)
offset = discriminant offset
max = max enum value
followed by alen case labels: in JEQ format
[ADR, e | EXT, 0, f] [offset] [next-insn, elem-insn] [elem-size iff "external" flag e is set, or flag f has DDS_OP_FLAG_OPT]
[ADR, STU, 0, f] *** not supported
where
s = subtype
e = external: stored as external data (pointer) (DDS_OP_FLAG_EXT)
f = flags:
- key/not key (DDS_OP_FLAG_KEY)
- base type member, used with EXT type (DDS_OP_FLAG_BASE)
- optional (DDS_OP_FLAG_OPT)
- must-understand (DDS_OP_FLAG_MU)
- storage size, only for ENU and BMK (n << DDS_OP_FLAG_SZ_SHIFT)
[offset] = field offset from start of element in memory
[elem-size] = element size in memory (elem-size is only included in case 'external' flag is set)
[max-size] = string bound + 1
[max] = max enum value
[bits-..] = identified bits in the bitmask, split into high and low 32 bits
[alen] = array length, number of cases
[sbound] = bounded sequence maximum number of elements
[next-insn] = (unsigned 16 bits) offset to instruction for next field, from start of insn
[elem-insn] = (unsigned 16 bits) offset to first instruction for element, from start of insn
[cases] = (unsigned 16 bits) offset to first case label, from start of insn
*/
DDS_OP_ADR = 0x01 << 24,
/** jump-to-subroutine (e.g. used for recursive types and appendable unions)
[JSR, 0, e]
where
e = (signed 16 bits) offset to first instruction in subroutine, from start of insn
instruction sequence must end in RTS, execution resumes at instruction
following JSR */
DDS_OP_JSR = 0x02 << 24,
/** jump-if-equal, used for union cases:
[JEQ, nBY, 0] [disc] [offset]
[JEQ, BLN, 0] [disc] [offset]
[JEQ, STR, 0] [disc] [offset]
[JEQ, s, i] [disc] [offset]
[JEQ4, e | nBY, 0] [disc] [offset] 0
[JEQ4, e | STR, 0] [disc] [offset] 0
[JEQ4, e | ENU, f] [disc] [offset] [max]
[JEQ4, EXT, 0] *** not supported, use STU/UNI for external defined types
[JEQ4, e | s, i] [disc] [offset] [elem-size iff "external" flag e is set, else 0]
where
e = external: stored as external data (pointer) (DDS_OP_FLAG_EXT)
s = subtype other than {nBY,STR} for JEQ and {nBY,STR,ENU,EXT} for JEQ4
(note that BMK cannot be inline, because it needs 2 additional instructions
for the bits that are identified in the bitmask type)
i = (unsigned 16 bits) offset to first instruction for case, from start of insn
instruction sequence must end in RTS, at which point executes continues
at the next field's instruction as specified by the union
f = size flags for ENU instruction
Note that the JEQ instruction is deprecated and replaced by the JEQ4 instruction. The
IDL compiler only generates JEQ4 for union cases, the JEQ instruction is included here
for backwards compatibility (topic descriptors generated with a previous version of IDLC)
*/
DDS_OP_JEQ = 0x03 << 24,
/** XCDR2 delimited CDR (inserts DHEADER before type)
[DLC, 0, 0]
*/
DDS_OP_DLC = 0x04 << 24,
/** XCDR2 parameter list CDR (inserts DHEADER before type and EMHEADER before each member)
[PLC, 0, 0]
followed by a list of JEQ instructions
*/
DDS_OP_PLC = 0x05 << 24,
/**
[PLM, f, elem-insn] [member id]
for members of aggregated mutable types (pl-cdr):
where
f = flags:
- jump to base type (DDS_OP_FLAG_BASE)
[elem-insn] = (unsigned 16 bits) offset to instruction for element, from start of insn
when FLAG_BASE is set, this is the offset of the PLM list of the base type
[member id] = id for this member (0 in case FLAG_BASE is set)
*/
DDS_OP_PLM = 0x06 << 24,
/** Key offset list
[KOF, 0, n] [offset-1] ... [offset-n]
where
n = number of key offsets in following ops
offset = Offset of the key field relative to the previous offset, repeated n times when key is
in a nested struct. In case of inheritance of mutable structs, a single offset of
the key member relative to the first op of the top-level type (index 0).
*/
DDS_OP_KOF = 0x07 << 24,
/** see comment for JEQ/JEQ4 above */
DDS_OP_JEQ4 = 0x08 << 24
};
/**
* @ingroup serialization
* @brief datatypes as recognized by serialization VM.
*/
enum dds_stream_typecode {
DDS_OP_VAL_1BY = 0x01, /**< one byte simple type (char, octet) */
DDS_OP_VAL_2BY = 0x02, /**< two byte simple type ((unsigned) short) */
DDS_OP_VAL_4BY = 0x03, /**< four byte simple type ((unsigned) long, float) */
DDS_OP_VAL_8BY = 0x04, /**< eight byte simple type ((unsigned) long long, double) */
DDS_OP_VAL_STR = 0x05, /**< string */
DDS_OP_VAL_BST = 0x06, /**< bounded string */
DDS_OP_VAL_SEQ = 0x07, /**< sequence */
DDS_OP_VAL_ARR = 0x08, /**< array */
DDS_OP_VAL_UNI = 0x09, /**< union */
DDS_OP_VAL_STU = 0x0a, /**< struct */
DDS_OP_VAL_BSQ = 0x0b, /**< bounded sequence */
DDS_OP_VAL_ENU = 0x0c, /**< enumerated value (long) */
DDS_OP_VAL_EXT = 0x0d, /**< field with external definition */
DDS_OP_VAL_BLN = 0x0e, /**< boolean */
DDS_OP_VAL_BMK = 0x0f /**< bitmask */
};
/**
* @ingroup serialization
* @brief primary type code for DDS_OP_ADR, DDS_OP_JEQ
* Convinience pre-bitshifted values.
*/
enum dds_stream_typecode_primary {
DDS_OP_TYPE_1BY = DDS_OP_VAL_1BY << 16, /**< one byte simple type (char, octet) */
DDS_OP_TYPE_2BY = DDS_OP_VAL_2BY << 16, /**< two byte simple type ((unsigned) short) */
DDS_OP_TYPE_4BY = DDS_OP_VAL_4BY << 16, /**< four byte simple type ((unsigned) long, float) */
DDS_OP_TYPE_8BY = DDS_OP_VAL_8BY << 16, /**< eight byte simple type ((unsigned) long long, double) */
DDS_OP_TYPE_STR = DDS_OP_VAL_STR << 16, /**< string */
DDS_OP_TYPE_BST = DDS_OP_VAL_BST << 16, /**< bounded string */
DDS_OP_TYPE_SEQ = DDS_OP_VAL_SEQ << 16, /**< sequence */
DDS_OP_TYPE_ARR = DDS_OP_VAL_ARR << 16, /**< array */
DDS_OP_TYPE_UNI = DDS_OP_VAL_UNI << 16, /**< union */
DDS_OP_TYPE_STU = DDS_OP_VAL_STU << 16, /**< struct */
DDS_OP_TYPE_BSQ = DDS_OP_VAL_BSQ << 16, /**< bounded sequence */
DDS_OP_TYPE_ENU = DDS_OP_VAL_ENU << 16, /**< enumerated value (long) */
DDS_OP_TYPE_EXT = DDS_OP_VAL_EXT << 16, /**< field with external definition */
DDS_OP_TYPE_BLN = DDS_OP_VAL_BLN << 16, /**< boolean */
DDS_OP_TYPE_BMK = DDS_OP_VAL_BMK << 16 /**< bitmask */
};
/**
* @anchor DDS_OP_FLAG_EXT
* @ingroup serialization
* @brief This flag indicates that the type has external data
* (i.e. a mapped to a pointer type), which can be the case because of (1) the \@external annotation
* in idl or (2) the \@optional annotation (optional fields are also mapped to pointer types as described
* in the XTypes spec). This flag is stored in the most-significant bit of the 'type' part of the
* serializer instruction.
*/
#define DDS_OP_FLAG_EXT (1u << 23)
/**
* @ingroup serialization
* @brief sub-type code
* - encodes element type for DDS_OP_TYPE_{SEQ,ARR},
* - discriminant type for DDS_OP_TYPE_UNI
* Convinience pre-bitshifted values.
*/
enum dds_stream_typecode_subtype {
DDS_OP_SUBTYPE_1BY = DDS_OP_VAL_1BY << 8, /**< one byte simple type (char, octet) */
DDS_OP_SUBTYPE_2BY = DDS_OP_VAL_2BY << 8, /**< two byte simple type ((unsigned) short) */
DDS_OP_SUBTYPE_4BY = DDS_OP_VAL_4BY << 8, /**< four byte simple type ((unsigned) long, float) */
DDS_OP_SUBTYPE_8BY = DDS_OP_VAL_8BY << 8, /**< eight byte simple type ((unsigned) long long, double) */
DDS_OP_SUBTYPE_STR = DDS_OP_VAL_STR << 8, /**< string */
DDS_OP_SUBTYPE_BST = DDS_OP_VAL_BST << 8, /**< bounded string */
DDS_OP_SUBTYPE_SEQ = DDS_OP_VAL_SEQ << 8, /**< sequence */
DDS_OP_SUBTYPE_ARR = DDS_OP_VAL_ARR << 8, /**< array */
DDS_OP_SUBTYPE_UNI = DDS_OP_VAL_UNI << 8, /**< union */
DDS_OP_SUBTYPE_STU = DDS_OP_VAL_STU << 8, /**< struct */
DDS_OP_SUBTYPE_BSQ = DDS_OP_VAL_BSQ << 8, /**< bounded sequence */
DDS_OP_SUBTYPE_ENU = DDS_OP_VAL_ENU << 8, /**< enumerated value (long) */
DDS_OP_SUBTYPE_BLN = DDS_OP_VAL_BLN << 8, /**< boolean */
DDS_OP_SUBTYPE_BMK = DDS_OP_VAL_BMK << 8 /**< bitmask */
};
/**
* @anchor DDS_OP_FLAG_KEY
* @ingroup serialization
* @brief mark field as key
* applicable to {1,2,4,8}BY, STR, BST, ARR-of-{1,2,4,8}BY.
* Note that when defining keys in nested types, the key flag should be set
* on both the field(s) in the subtype and on the enclosing STU/EXT field.
*/
#define DDS_OP_FLAG_KEY (1u << 0)
/**
* @anchor DDS_OP_FLAG_DEF
* @ingroup serialization
* @brief For a union:
* -# the discriminator may be a key field;
* -# there may be a default value;
* -# and the discriminator can be an integral type (or enumerated - here treated as equivalent).
* What it can't be is a floating-point type. So DEF and FP need never be set at the same time.
* There are only a few flag bits, so saving one is not such a bad idea.
*
* union has a default case (for DDS_OP_ADR | DDS_OP_TYPE_UNI)
*/
#define DDS_OP_FLAG_DEF (1u << 1)
/**
* @anchor DDS_OP_FLAG_FP
* @ingroup serialization
* @brief floating-point,
* applicable to {4,8}BY and arrays, sequences of them
*/
#define DDS_OP_FLAG_FP (1u << 1)
/**
* @anchor DDS_OP_FLAG_SGN
* @ingroup serialization
* @brief signed,
* applicable to {1,2,4,8}BY and arrays, sequences of them
*/
#define DDS_OP_FLAG_SGN (1u << 2)
/**
* @anchor DDS_OP_FLAG_MU
* @ingroup serialization
* @brief must-understand flag,
* as defined by the XTypes spec.
*/
#define DDS_OP_FLAG_MU (1u << 3)
/**
* @anchor DDS_OP_FLAG_BASE
* @ingroup serialization
* @brief jump to base type,
* used with PLM in mutable types and for the TYPE_EXT 'parent' member
* in final and appendable types
*/
#define DDS_OP_FLAG_BASE (1u << 4)
/**
* @anchor DDS_OP_FLAG_OPT
* @ingroup serialization
* @brief optional flag,
* used with struct members. For non-string types, an optional member
* also gets the FLAG_EXT, see above.
*/
#define DDS_OP_FLAG_OPT (1u << 5)
/**
* @anchor DDS_OP_FLAG_SZ_SHIFT
* @ingroup serialization
* @brief Enum and bitmask storage size (shift amount)
*/
#define DDS_OP_FLAG_SZ_SHIFT (6)
/**
* @anchor DDS_OP_FLAG_SZ_MASK
* @ingroup serialization
* @brief Enum and bitmask storage size
* -# 00 = 1 byte,
* -# 01 = 2 bytes,
* -# 10 = 4 bytes,
* -# 11 = 8 bytes (bitmask only)
*/
#define DDS_OP_FLAG_SZ_MASK (3u << DDS_OP_FLAG_SZ_SHIFT)
/**
* @anchor DDS_OP_FLAGS_SZ
* @ingroup serialization
* @brief Extract the Enum and Bitmask storage size from flags
*/
#define DDS_OP_FLAGS_SZ(f) (1u << (((f) & DDS_OP_FLAG_SZ_MASK) >> DDS_OP_FLAG_SZ_SHIFT))
/**
* @anchor DDS_OP_TYPE_SZ
* @ingroup serialization
* @brief Extract the Enum and Bitmask storage size from an uint32
*/
#define DDS_OP_TYPE_SZ(o) DDS_OP_FLAGS_SZ(DDS_OP_FLAGS(o))
/**
* @defgroup topic_flags (Topic flags)
* @ingroup serialization
* There are several flags that can be added to dds_topic_descriptor_t by the IDL compiler.
*/
/**
* @anchor DDS_TOPIC_NO_OPTIMIZE
* @ingroup topic_flags
* @brief Don't optimize the opcodes to quick memcpy's.
* If a topic includes only plain types and directly nested structs,
* it can be that a simple copy+optional byteswap can produce the right
* C memory layout straight from CDR. If this flag is added it means that
* there is pointer 'magic' involved in decoding the type and no shortcuts should be taken.
* @deprecated Optimizability is determined runtime when creating the sertype_default
* for the type, this flag is not used.
*/
#define DDS_TOPIC_NO_OPTIMIZE (1u << 0)
/**
* @anchor DDS_TOPIC_FIXED_KEY
* @ingroup topic_flags
* @brief The XCDRV1 serialized key fits in 16 bytes.
* If statically determined that a key always fits in 16 bytes
* the spec specifies that the key of a sample is the resulting CDR.
* If it is longer we must use MD5 to hash the resultant key CDR.
*/
#define DDS_TOPIC_FIXED_KEY (1u << 1)
/**
* @anchor DDS_TOPIC_CONTAINS_UNION
* @ingroup topic_flags
* @brief at arbitrary deep nesting the topic type contains at least one union.
*/
#define DDS_TOPIC_CONTAINS_UNION (1u << 2)
// (1u << 3) unused, was used for DDS_TOPIC_DISABLE_TYPECHECK
/**
* @anchor DDS_TOPIC_FIXED_SIZE
* @ingroup topic_flags
* @brief The size in memory of a sample of this topic type is fully fixed.
*/
#define DDS_TOPIC_FIXED_SIZE (1u << 4)
/**
* @anchor DDS_TOPIC_FIXED_KEY_XCDR2
* @ingroup topic_flags
* @brief The XCDRV2 serialized key fits in 16 bytes.
* If statically determined that a key always fits in 16 bytes
* the spec specifies that the key of a sample is the resulting CDR.
* If it is longer we must use MD5 to hash the resultant key CDR.
*
* This is separate from the XCDRV1 version because it can differ due
* to the change in alignment of 8byte types.
*/
#define DDS_TOPIC_FIXED_KEY_XCDR2 (1u << 5)
/**
* @anchor DDS_TOPIC_XTYPES_METADATA
* @ingroup topic_flags
* @brief Set if XTypes meta-data is present for this topic
*/
#define DDS_TOPIC_XTYPES_METADATA (1u << 6)
/**
* @anchor DDS_TOPIC_RESTRICT_DATA_REPRESENTATION
* @ingroup topic_flags
* @brief Set if data representation restrictions for the top-level type are present in the topic descriptor
*/
#define DDS_TOPIC_RESTRICT_DATA_REPRESENTATION (1u << 7)
/**
* @anchor DDS_FIXED_KEY_MAX_SIZE
* @ingroup topic_flags
* @brief Max size of fixed key
*/
#define DDS_FIXED_KEY_MAX_SIZE (16)
#if defined(__cplusplus)
}
#endif
#endif /* DDS_OPCODES_H */

View File

@@ -0,0 +1,156 @@
/*
* Copyright(c) 2006 to 2019 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/* TODO: do we really need to expose this as an API? */
/** @file
*
* @brief DDS C Allocation API
*
* This header file defines the public API of allocation convenience functions
* in the Eclipse Cyclone DDS C language binding.
*/
#ifndef DDS_ALLOC_H
#define DDS_ALLOC_H
#include <stddef.h>
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
struct dds_topic_descriptor;
struct dds_sequence;
/**
* @anchor DDS_FREE_KEY_BIT
* @ingroup alloc
* @brief Instruction to free all keyfields in sample
*/
#define DDS_FREE_KEY_BIT 0x01
/**
* @anchor DDS_FREE_CONTENTS_BIT
* @ingroup alloc
* @brief Instruction to free all non-keyfields in sample
*/
#define DDS_FREE_CONTENTS_BIT 0x02
/**
* @anchor DDS_FREE_ALL_BIT
* @ingroup alloc
* @brief Instruction to free outer sample
*/
#define DDS_FREE_ALL_BIT 0x04
/**
* @brief Freeing operation type
* @ingroup alloc
* What part of a sample to free
*/
typedef enum
{
DDS_FREE_ALL = DDS_FREE_KEY_BIT | DDS_FREE_CONTENTS_BIT | DDS_FREE_ALL_BIT, /**< free full sample */
DDS_FREE_CONTENTS = DDS_FREE_KEY_BIT | DDS_FREE_CONTENTS_BIT, /**< free all sample contents, but leave sample pointer intact */
DDS_FREE_KEY = DDS_FREE_KEY_BIT /**< free only the keyfields in a sample */
}
dds_free_op_t;
/**
* @brief DDS Allocator
* @ingroup alloc
* C-Style allocator API
*/
typedef struct dds_allocator
{
void * (*malloc) (size_t size); /**< behave like C malloc */
void * (*realloc) (void *ptr, size_t size); /**< behave like C realloc, may be null */
void (*free) (void *ptr); /**< behave like C free */
}
dds_allocator_t;
/**
* @brief Perform an alloc() with the default allocator.
*
* @param[in] size number of bytes
* @returns new pointer or NULL if out of memory
*/
DDS_EXPORT void * dds_alloc (size_t size);
/**
* @brief Perform a realloc() with the default allocator.
*
* @param[in] ptr previously alloc()'ed pointer
* @param[in] size new size
* @return new pointer or NULL if out of memory
*/
DDS_EXPORT void * dds_realloc (void * ptr, size_t size);
/**
* @brief Perform a realloc() with the default allocator. Zero out memory.
*
* @param[in] ptr previously alloc()'ed pointer
* @param[in] size new size
* @return new pointer or NULL if out of memory
*/
DDS_EXPORT void * dds_realloc_zero (void * ptr, size_t size);
/**
* @brief Perform a free() on a memory fragment allocated with the default allocator.
*
* @param[in] ptr previously alloc()'ed pointer
*/
DDS_EXPORT void dds_free (void * ptr);
#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef void * (*dds_alloc_fn_t) (size_t);
typedef void * (*dds_realloc_fn_t) (void *, size_t);
typedef void (*dds_free_fn_t) (void *);
#endif // DOXYGEN_SHOULD_SKIP_THIS
/**
* @brief Allocated a string with size, accounting for the null terminator.
*
* @param[in] size number of characters
* @returns newly allocated string or NULL if out of memory
*/
DDS_EXPORT char * dds_string_alloc (size_t size);
/**
* @brief Duplicate a null-terminated string
*
* @param[in] str string to duplicate
* @returns newly allocated duplicate string, or NULL if out of memory
*/
DDS_EXPORT char * dds_string_dup (const char * str);
/**
* @brief Free a string, equivalent to dds_free
*
* @param[in] str string to free
*/
DDS_EXPORT void dds_string_free (char * str);
/**
* @brief Free (parts of) a sample according to the \ref dds_free_op_t
*
* @param[in] sample sample to free
* @param[in] desc topic descriptor of the type this sample was created from.
* @param[in] op Which parts of the sample to free.
*/
DDS_EXPORT void dds_sample_free (void * sample, const struct dds_topic_descriptor * desc, dds_free_op_t op);
#if defined (__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,56 @@
/*
* Copyright(c) 2006 to 2019 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/** @file
*
* @brief DDS C Error API
*
* This header file defines the public API of error values and convenience
* functions in the CycloneDDS C language binding.
*/
#ifndef DDS_ERROR_H
#define DDS_ERROR_H
#include "dds/export.h"
#include "dds/ddsrt/log.h"
#include "dds/ddsrt/retcode.h"
#if defined (__cplusplus)
extern "C" {
#endif
/* ** DEPRECATED ** */
#ifndef DOXYGEN_SHOULD_SKIP_THIS
/* Error masks for returned status values */
#define DDS_ERR_NR_MASK 0x000000ff
#define DDS_ERR_LINE_MASK 0x003fff00
#define DDS_ERR_FILE_ID_MASK 0x7fc00000
/* Error code handling functions */
/** Macro to extract error number */
#define dds_err_nr(e) (e)
/** Macro to extract line number */
#define dds_err_line(e) (0)
/** Macro to extract file identifier */
#define dds_err_file_id(e) (0)
#endif // DOXYGEN_SHOULD_SKIP_THIS
#if defined (__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,350 @@
/*
* Copyright(c) 2006 to 2022 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/* TODO: do we really need to expose all of this as an API? maybe some, but all? */
/** @file
*
* @brief DDS C Implementation API
*
* This header file defines the public API for all kinds of things in the
* Eclipse Cyclone DDS C language binding.
*/
#ifndef DDS_IMPL_H
#define DDS_IMPL_H
#include <stdint.h>
#include <stdbool.h>
#include "dds/export.h"
#include "dds/features.h"
#include "dds/ddsrt/align.h"
#include "dds/ddsc/dds_public_alloc.h"
#include "dds/ddsc/dds_opcodes.h"
#if defined (__cplusplus)
extern "C" {
#endif
/**
* @defgroup implementation (Public Implementation Details)
* @ingroup dds
* Miscellaneous types and functions that are required to be public, since they are
* in the output of the IDL compiler, but are not intended for direct use.
*/
/**
* @ingroup implementation
* @brief Datastructure of a Sequence type
* Container for a sequence of bytes. The general model of this type is also used in IDL output,
* where the uint8_t * _buffer is replaced by the appropriate subtype of what is contained.
*/
typedef struct dds_sequence
{
uint32_t _maximum; /**< Allocated space in _buffer */
uint32_t _length; /**< Used space in _buffer */
uint8_t * _buffer; /**< Sequence of bytes */
bool _release; /**< Whether a CycloneDDS _free method should free the contained buffer.
if you put in your own allocated _buffer set this to false to avoid
CycloneDDS calling free() on it. */
}
dds_sequence_t;
/**
* @ingroup implementation
* @brief Key Descriptor
* Used to describe a named key field in a type with the offset from the start of a struct.
*/
typedef struct dds_key_descriptor
{
const char * m_name; /**< name of keyfield */
uint32_t m_offset; /**< offset from pointer */
uint32_t m_idx; /**< m_idx'th key of type */
}
dds_key_descriptor_t;
/**
* @defgroup topic_definition (Topic Definition)
* @ingroup implementation
* Topic definitions are output by the IDL compiler and have an
* implementation-private definition. The only thing exposed on the
* API is a pointer to the "dds_topic_descriptor_t" struct type.
*/
/**
* @ingroup topic_definition
* @brief Simple sized byte container to hold serialized type info
* Holds XTypes information (TypeInformation, TypeMapping) for a
* type
*/
struct dds_type_meta_ser
{
unsigned char * data; /**< data pointer */
uint32_t sz; /**< data size */
};
/**
* @anchor DDS_DATA_REPRESENTATION_XCDR1
* @ingroup topic_definition
* @brief Data representation XCDR1
* Type can be represented using XCDR1
*/
#define DDS_DATA_REPRESENTATION_XCDR1 0
/**
* @anchor DDS_DATA_REPRESENTATION_XML
* @ingroup topic_definition
* @brief Data representation XML
* Type can be represented using XML
*/
#define DDS_DATA_REPRESENTATION_XML 1
/**
* @anchor DDS_DATA_REPRESENTATION_XCDR2
* @ingroup topic_definition
* @brief Data representation XCDR2
* Type can be represented using XCDR2
*/
#define DDS_DATA_REPRESENTATION_XCDR2 2
/**
* @anchor DDS_DATA_REPRESENTATION_FLAG_XCDR1
* @ingroup topic_definition
* @brief Data representation XCDR1 flag
* Type can be represented using XCDR1, preshifted
*/
#define DDS_DATA_REPRESENTATION_FLAG_XCDR1 (1u << DDS_DATA_REPRESENTATION_XCDR1)
/**
* @anchor DDS_DATA_REPRESENTATION_FLAG_XML
* @ingroup topic_definition
* @brief Data representation XML flag
* Type can be represented using XML, preshifted
*/
#define DDS_DATA_REPRESENTATION_FLAG_XML (1u << DDS_DATA_REPRESENTATION_XML)
/**
* @anchor DDS_DATA_REPRESENTATION_FLAG_XCDR2
* @ingroup topic_definition
* @brief Data representation XCDR2 flag
* Type can be represented using XCDR2, preshifted
*/
#define DDS_DATA_REPRESENTATION_FLAG_XCDR2 (1u << DDS_DATA_REPRESENTATION_XCDR2)
/**
* @anchor DDS_DATA_REPRESENTATION_RESTRICT_DEFAULT
* @ingroup topic_definition
* @brief Default datarepresentation flag, XCDR1 and XCDR2 flags
*/
#define DDS_DATA_REPRESENTATION_RESTRICT_DEFAULT (DDS_DATA_REPRESENTATION_FLAG_XCDR1 | DDS_DATA_REPRESENTATION_FLAG_XCDR2)
/**
* @brief Topic Descriptor
* @ingroup topic_definition
* @warning Unstable/Private API
* Contains all meta information about a type, usually produced by the IDL compiler
* Since this type is not intended for public consumption it can change without warning.
*/
typedef struct dds_topic_descriptor
{
const uint32_t m_size; /**< Size of topic type */
const uint32_t m_align; /**< Alignment of topic type */
const uint32_t m_flagset; /**< Flags */
const uint32_t m_nkeys; /**< Number of keys (can be 0) */
const char * m_typename; /**< Type name */
const dds_key_descriptor_t * m_keys; /**< Key descriptors (NULL iff m_nkeys 0) */
const uint32_t m_nops; /**< Number of ops in m_ops */
const uint32_t * m_ops; /**< Marshalling meta data */
const char * m_meta; /**< XML topic description meta data */
struct dds_type_meta_ser type_information; /**< XCDR2 serialized TypeInformation, only present if flag DDS_TOPIC_XTYPES_METADATA is set */
struct dds_type_meta_ser type_mapping; /**< XCDR2 serialized TypeMapping: maps type-id to type object and minimal to complete type id,
only present if flag DDS_TOPIC_XTYPES_METADATA is set */
const uint32_t restrict_data_representation; /**< restrictions on the data representations allowed for the top-level type for this topic,
only present if flag DDS_TOPIC_RESTRICT_DATA_REPRESENTATION */
}
dds_topic_descriptor_t;
/**
* @defgroup reading_masks (Reading Masks)
* @ingroup conditions
* Masks for read condition, read, take: there is only one mask here,
* which combines the sample, view and instance states.
*/
/**
* @anchor DDS_READ_SAMPLE_STATE
* @ingroup reading_masks
* @brief Samples that were already returned once by a read/take operation
*/
#define DDS_READ_SAMPLE_STATE 1u
/**
* @anchor DDS_NOT_READ_SAMPLE_STATE
* @ingroup reading_masks
* @brief Samples that have not been returned by a read/take operation yet
*/
#define DDS_NOT_READ_SAMPLE_STATE 2u
/**
* @anchor DDS_ANY_SAMPLE_STATE
* @ingroup reading_masks
* @brief Samples \ref DDS_READ_SAMPLE_STATE or \ref DDS_NOT_READ_SAMPLE_STATE
*/
#define DDS_ANY_SAMPLE_STATE (1u | 2u)
/**
* @anchor DDS_NEW_VIEW_STATE
* @ingroup reading_masks
* @brief Samples that belong to a new instance (unique key value)
*/
#define DDS_NEW_VIEW_STATE 4u
/**
* @anchor DDS_NOT_NEW_VIEW_STATE
* @ingroup reading_masks
* @brief Samples that belong to an existing instance (previously received key value)
*/
#define DDS_NOT_NEW_VIEW_STATE 8u
/**
* @anchor DDS_ANY_VIEW_STATE
* @ingroup reading_masks
* @brief Samples \ref DDS_NEW_VIEW_STATE or \ref DDS_NOT_NEW_VIEW_STATE
*/
#define DDS_ANY_VIEW_STATE (4u | 8u)
/**
* @anchor DDS_ALIVE_INSTANCE_STATE
* @ingroup reading_masks
* @brief Samples that belong to a write
*/
#define DDS_ALIVE_INSTANCE_STATE 16u
/**
* @anchor DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE
* @ingroup reading_masks
* @brief Samples that belong to a (write)dispose
*/
#define DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE 32u
/**
* @anchor DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE
* @ingroup reading_masks
* @brief Samples that belong a writer that is gone
*/
#define DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE 64u
/**
* @anchor DDS_ANY_INSTANCE_STATE
* @ingroup reading_masks
* @brief Samples \ref DDS_ALIVE_INSTANCE_STATE, \ref DDS_NOT_ALIVE_DISPOSED_INSTANCE_STATE or \ref DDS_NOT_ALIVE_NO_WRITERS_INSTANCE_STATE
*/
#define DDS_ANY_INSTANCE_STATE (16u | 32u | 64u)
/**
* @anchor DDS_ANY_STATE
* @ingroup reading_masks
* @brief Any and all samples
* Equivalen to \ref DDS_ANY_SAMPLE_STATE | \ref DDS_ANY_VIEW_STATE | \ref DDS_ANY_INSTANCE_STATE
*/
#define DDS_ANY_STATE (DDS_ANY_SAMPLE_STATE | DDS_ANY_VIEW_STATE | DDS_ANY_INSTANCE_STATE)
/**
* @anchor DDS_DOMAIN_DEFAULT
* @ingroup domain
* @brief Select the default domain
*/
#define DDS_DOMAIN_DEFAULT ((uint32_t) 0xffffffffu)
#ifndef DOXYGEN_SHOULD_SKIP_THIS
#define DDS_HANDLE_NIL 0
#define DDS_ENTITY_NIL 0
#endif
/**
* @brief DDS Entity Kind constants
* @ingroup internal
* @warning Unstable/Private API
* Used throughout the library to indicate what entity is what.
*/
typedef enum dds_entity_kind
{
DDS_KIND_DONTCARE, /**< Retrieving any entity */
DDS_KIND_TOPIC, /**< Topic entity */
DDS_KIND_PARTICIPANT, /**< Domain Participant entity */
DDS_KIND_READER, /**< Reader entity */
DDS_KIND_WRITER, /**< Writer entity */
DDS_KIND_SUBSCRIBER, /**< Subscriber entity */
DDS_KIND_PUBLISHER, /**< Publisher entity */
DDS_KIND_COND_READ, /**< ReadCondition entity */
DDS_KIND_COND_QUERY, /**< QueryCondition entity */
DDS_KIND_COND_GUARD, /**< GuardCondition entity */
DDS_KIND_WAITSET, /**< WaitSet entity */
DDS_KIND_DOMAIN, /**< Domain entity */
DDS_KIND_CYCLONEDDS /**< CycloneDDS library entity */
} dds_entity_kind_t;
/**
* @anchor DDS_KIND_MAX
* @ingroup internal
* @brief Max entity kind, used for loops.
*/
#define DDS_KIND_MAX DDS_KIND_CYCLONEDDS
/**
* @ingroup internal
* @warning Private API
* @brief Instance handles are uint64_t behind the scenes
*/
typedef uint64_t dds_instance_handle_t;
/**
* @ingroup domain
* @brief Domain IDs are 32 bit unsigned integers.
*/
typedef uint32_t dds_domainid_t;
/**
* @ingroup topic
* @brief Scope for dds_find_topic()
*/
typedef enum dds_find_scope
{
DDS_FIND_SCOPE_GLOBAL, /**< locate the topic anywhere CycloneDDS knows about */
DDS_FIND_SCOPE_LOCAL_DOMAIN, /**< locate the topic locally within domain boundaries */
DDS_FIND_SCOPE_PARTICIPANT /**< locate the topic within the current participant */
}
dds_find_scope_t;
/**
* @ingroup builtintopic
* @brief Type identifier kind for getting endpoint type identifier
*/
typedef enum dds_typeid_kind
{
DDS_TYPEID_MINIMAL, /**< XTypes Minimal Type ID */
DDS_TYPEID_COMPLETE /**< XTypes Complete Type ID */
}
dds_typeid_kind_t;
/**
* @brief Enable or disable write batching.
* Overrides default configuration setting for write batching (Internal/WriteBatch).
*
* @param[in] enable Enables or disables write batching for all writers.
*/
DDS_EXPORT void dds_write_set_batch (bool enable);
#if defined (__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,813 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/**
* @defgroup listener (Listener API)
* @ingroup dds
*
* This defines the public API of listeners in the
* Eclipse Cyclone DDS C language binding.
*/
#ifndef _DDS_PUBLIC_LISTENER_H_
#define _DDS_PUBLIC_LISTENER_H_
#include "dds/export.h"
#include "dds/ddsc/dds_public_impl.h"
#include "dds/ddsc/dds_public_status.h"
#if defined (__cplusplus)
extern "C" {
#endif
/* Listener callbacks */
typedef void (*dds_on_inconsistent_topic_fn) (dds_entity_t topic, const dds_inconsistent_topic_status_t status, void* arg);
typedef void (*dds_on_liveliness_lost_fn) (dds_entity_t writer, const dds_liveliness_lost_status_t status, void* arg);
typedef void (*dds_on_offered_deadline_missed_fn) (dds_entity_t writer, const dds_offered_deadline_missed_status_t status, void* arg);
typedef void (*dds_on_offered_incompatible_qos_fn) (dds_entity_t writer, const dds_offered_incompatible_qos_status_t status, void* arg);
typedef void (*dds_on_data_on_readers_fn) (dds_entity_t subscriber, void* arg);
typedef void (*dds_on_sample_lost_fn) (dds_entity_t reader, const dds_sample_lost_status_t status, void* arg);
typedef void (*dds_on_data_available_fn) (dds_entity_t reader, void* arg);
typedef void (*dds_on_sample_rejected_fn) (dds_entity_t reader, const dds_sample_rejected_status_t status, void* arg);
typedef void (*dds_on_liveliness_changed_fn) (dds_entity_t reader, const dds_liveliness_changed_status_t status, void* arg);
typedef void (*dds_on_requested_deadline_missed_fn) (dds_entity_t reader, const dds_requested_deadline_missed_status_t status, void* arg);
typedef void (*dds_on_requested_incompatible_qos_fn) (dds_entity_t reader, const dds_requested_incompatible_qos_status_t status, void* arg);
typedef void (*dds_on_publication_matched_fn) (dds_entity_t writer, const dds_publication_matched_status_t status, void* arg);
typedef void (*dds_on_subscription_matched_fn) (dds_entity_t reader, const dds_subscription_matched_status_t status, void* arg);
/**
* @anchor DDS_LUNSET
* @ingroup internal
* @brief Default initial value (nullptr) for listener functions.
*/
#define DDS_LUNSET 0
/**
* @brief DDS Listener struct (opaque)
* @ingroup listener
*/
struct dds_listener;
/**
* @brief DDS Listener type (opaque)
* @ingroup listener
*/
typedef struct dds_listener dds_listener_t;
/**
* @ingroup listener
* @brief Allocate memory and initializes to default values (@ref DDS_LUNSET) of a listener
*
* @param[in] arg optional pointer that will be passed on to the listener callbacks
*
* @returns Returns a pointer to the allocated memory for dds_listener_t structure.
*/
DDS_EXPORT dds_listener_t* dds_create_listener(void* arg);
/**
* @ingroup deprecated
* @deprecated use \ref dds_create_listener instead.
* Allocate memory and initializes to default values (@ref DDS_LUNSET) of a listener
*
* @param[in] arg optional pointer that will be passed on to the listener callbacks
*
* @return Returns a pointer to the allocated memory for dds_listener_t structure.
*/
DDS_DEPRECATED_EXPORT dds_listener_t* dds_listener_create (void* arg);
/**
* @ingroup listener
* @brief Delete the memory allocated to listener structure
*
* @param[in] listener pointer to the listener struct to delete
*/
DDS_EXPORT void dds_delete_listener (dds_listener_t * __restrict listener);
DDS_DEPRECATED_EXPORT void dds_listener_delete (dds_listener_t * __restrict listener);
/**
* @ingroup listener
* @brief Reset the listener structure contents to @ref DDS_LUNSET
*
* @param[in,out] listener pointer to the listener struct to reset
*/
DDS_EXPORT void dds_reset_listener (dds_listener_t * __restrict listener);
DDS_DEPRECATED_EXPORT void dds_listener_reset (dds_listener_t * __restrict listener);
/**
* @ingroup listener
* @brief Copy the listener callbacks from source to destination
*
* @param[in,out] dst The pointer to the destination listener structure, where the content is to copied
* @param[in] src The pointer to the source listener structure to be copied
*/
DDS_EXPORT void dds_copy_listener (dds_listener_t * __restrict dst, const dds_listener_t * __restrict src);
DDS_DEPRECATED_EXPORT void dds_listener_copy (dds_listener_t * __restrict dst, const dds_listener_t * __restrict src);
/**
* @ingroup listener
* @brief Copy the listener callbacks from source to destination, unless already set
*
* Any listener callbacks already set in @p dst (including NULL) are skipped, only
* those set to DDS_LUNSET are copied from @p src.
*
* @param[in,out] dst The pointer to the destination listener structure, where the content is merged
* @param[in] src The pointer to the source listener structure to be copied
*/
DDS_EXPORT void dds_merge_listener (dds_listener_t * __restrict dst, const dds_listener_t * __restrict src);
DDS_DEPRECATED_EXPORT void dds_listener_merge (dds_listener_t * __restrict dst, const dds_listener_t * __restrict src);
/************************************************************************************************
* Setters
************************************************************************************************/
/**
* @defgroup listener_setters (Setters)
* @ingroup listener
*/
/**
* @ingroup listener_setters
* @brief Set the data_available callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_data_available_arg (dds_listener_t * __restrict listener, dds_on_data_available_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the data_on_readers callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_data_on_readers_arg (dds_listener_t * __restrict listener, dds_on_data_on_readers_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the inconsistent_topic callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_inconsistent_topic_arg (dds_listener_t * __restrict listener, dds_on_inconsistent_topic_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the liveliness_changed callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_liveliness_changed_arg (dds_listener_t * __restrict listener, dds_on_liveliness_changed_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the liveliness_lost callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_liveliness_lost_arg (dds_listener_t * __restrict listener, dds_on_liveliness_lost_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the offered_deadline_missed callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_offered_deadline_missed_arg (dds_listener_t * __restrict listener, dds_on_offered_deadline_missed_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the offered_incompatible_qos callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_offered_incompatible_qos_arg (dds_listener_t * __restrict listener, dds_on_offered_incompatible_qos_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the publication_matched callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_publication_matched_arg (dds_listener_t * __restrict listener, dds_on_publication_matched_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the requested_deadline_missed callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_requested_deadline_missed_arg (dds_listener_t * __restrict listener, dds_on_requested_deadline_missed_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the requested_incompatible_qos callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_requested_incompatible_qos_arg (dds_listener_t * __restrict listener, dds_on_requested_incompatible_qos_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the sample_lost callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_sample_lost_arg (dds_listener_t * __restrict listener, dds_on_sample_lost_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the sample_rejected callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_sample_rejected_arg (dds_listener_t * __restrict listener, dds_on_sample_rejected_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the subscription_matched callback and argument in the listener structure.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
* @param[in] arg callback argument that is passed uninterpreted to the callback function
* @param[in] reset_on_invoke whether or not the status should be cleared when the listener callback is invoked
*
* @retval DDS_RETCODE_OK success
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lset_subscription_matched_arg (dds_listener_t * __restrict listener, dds_on_subscription_matched_fn callback, void *arg, bool reset_on_invoke);
/**
* @ingroup listener_setters
* @brief Set the inconsistent_topic callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_inconsistent_topic_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_inconsistent_topic (dds_listener_t * __restrict listener, dds_on_inconsistent_topic_fn callback);
/**
* @ingroup listener_setters
* @brief Set the liveliness_lost callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_liveliness_lost_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_liveliness_lost (dds_listener_t * __restrict listener, dds_on_liveliness_lost_fn callback);
/**
* @ingroup listener_setters
* @brief Set the offered_deadline_missed callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_offered_deadline_missed_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_offered_deadline_missed (dds_listener_t * __restrict listener, dds_on_offered_deadline_missed_fn callback);
/**
* @ingroup listener_setters
* @brief Set the offered_incompatible_qos callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_offered_incompatible_qos_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_offered_incompatible_qos (dds_listener_t * __restrict listener, dds_on_offered_incompatible_qos_fn callback);
/**
* @ingroup listener_setters
* @brief Set the data_on_readers callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_data_on_readers_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_data_on_readers (dds_listener_t * __restrict listener, dds_on_data_on_readers_fn callback);
/**
* @ingroup listener_setters
* @brief Set the sample_lost callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_sample_lost_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_sample_lost (dds_listener_t * __restrict listener, dds_on_sample_lost_fn callback);
/**
* @ingroup listener_setters
* @brief Set the data_available callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_data_available_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_data_available (dds_listener_t * __restrict listener, dds_on_data_available_fn callback);
/**
* @ingroup listener_setters
* @brief Set the sample_rejected callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_sample_rejected_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_sample_rejected (dds_listener_t * __restrict listener, dds_on_sample_rejected_fn callback);
/**
* @ingroup listener_setters
* @brief Set the liveliness_changed callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_liveliness_changed_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_liveliness_changed (dds_listener_t * __restrict listener, dds_on_liveliness_changed_fn callback);
/**
* @ingroup listener_setters
* @brief Set the requested_deadline_missed callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_requested_deadline_missed_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_requested_deadline_missed (dds_listener_t * __restrict listener, dds_on_requested_deadline_missed_fn callback);
/**
* @ingroup listener_setters
* @brief Set the requested_incompatible_qos callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_requested_incompatible_qos_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_requested_incompatible_qos (dds_listener_t * __restrict listener, dds_on_requested_incompatible_qos_fn callback);
/**
* @ingroup listener_setters
* @brief Set the publication_matched callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_publication_matched_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_publication_matched (dds_listener_t * __restrict listener, dds_on_publication_matched_fn callback);
/**
* @ingroup listener_setters
* @brief Set the subscription_matched callback in the listener structure.
*
* Equivalent to calling @ref dds_lset_subscription_matched_arg with arg set to the argument passed in
* dds_create_listener() and reset_on_invoke to true, and throwing away the result.
*
* @param[in,out] listener listener structure to update
* @param[in] callback the callback to set or a null pointer
*/
DDS_EXPORT void dds_lset_subscription_matched (dds_listener_t * __restrict listener, dds_on_subscription_matched_fn callback);
/************************************************************************************************
* Getters
************************************************************************************************/
/**
* @defgroup listener_getters (Getters)
* @ingroup listener
*/
/**
* @ingroup listener_getters
* @brief Get the data_available callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_data_available_arg (const dds_listener_t * __restrict listener, dds_on_data_available_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the data_on_readers callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_data_on_readers_arg (const dds_listener_t * __restrict listener, dds_on_data_on_readers_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the inconsistent_topic callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_inconsistent_topic_arg (const dds_listener_t * __restrict listener, dds_on_inconsistent_topic_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the liveliness_changed callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_liveliness_changed_arg (const dds_listener_t * __restrict listener, dds_on_liveliness_changed_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the liveliness_lost callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_liveliness_lost_arg (const dds_listener_t * __restrict listener, dds_on_liveliness_lost_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the offered_deadline_missed callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_offered_deadline_missed_arg (const dds_listener_t * __restrict listener, dds_on_offered_deadline_missed_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the offered_incompatible_qos callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_offered_incompatible_qos_arg (const dds_listener_t * __restrict listener, dds_on_offered_incompatible_qos_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the publication_matched callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_publication_matched_arg (const dds_listener_t * __restrict listener, dds_on_publication_matched_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the subscription_matched callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_requested_deadline_missed_arg (const dds_listener_t * __restrict listener, dds_on_requested_deadline_missed_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the requested_incompatible_qos callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_requested_incompatible_qos_arg (const dds_listener_t * __restrict listener, dds_on_requested_incompatible_qos_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the sample_lost callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_sample_lost_arg (const dds_listener_t * __restrict listener, dds_on_sample_lost_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the sample_rejected callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_sample_rejected_arg (const dds_listener_t * __restrict listener, dds_on_sample_rejected_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the subscription_matched callback from the listener structure.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
* @param[out] arg Callback argument pointer; may be a null pointer
* @param[out] reset_on_invoke Whether the status is reset by listener invocation; may be a null pointer
*
* @retval DDS_RETCODE_OK if successful
* @retval DDS_RETCODE_BAD_PARAMETER listener is a null pointer
*/
DDS_EXPORT dds_return_t dds_lget_subscription_matched_arg (const dds_listener_t * __restrict listener, dds_on_subscription_matched_fn *callback, void **arg, bool *reset_on_invoke);
/**
* @ingroup listener_getters
* @brief Get the inconsistent_topic callback from the listener structure
*
* Equivalent to calling @ref dds_lget_inconsistent_topic_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_inconsistent_topic (const dds_listener_t * __restrict listener, dds_on_inconsistent_topic_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the liveliness_lost callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_liveliness_lost_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_liveliness_lost (const dds_listener_t * __restrict listener, dds_on_liveliness_lost_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the offered_deadline_missed callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_offered_deadline_missed_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_offered_deadline_missed (const dds_listener_t * __restrict listener, dds_on_offered_deadline_missed_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the offered_incompatible_qos callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_offered_incompatible_qos_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_offered_incompatible_qos (const dds_listener_t * __restrict listener, dds_on_offered_incompatible_qos_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the data_on_readers callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_data_on_readers_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_data_on_readers (const dds_listener_t * __restrict listener, dds_on_data_on_readers_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the sample_lost callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_sample_lost_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_sample_lost (const dds_listener_t *__restrict listener, dds_on_sample_lost_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the data_available callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_data_available_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_data_available (const dds_listener_t *__restrict listener, dds_on_data_available_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the sample_rejected callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_sample_rejected_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_sample_rejected (const dds_listener_t *__restrict listener, dds_on_sample_rejected_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the liveliness_changed callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_liveliness_changed_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_liveliness_changed (const dds_listener_t * __restrict listener, dds_on_liveliness_changed_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the requested_deadline_missed callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_requested_deadline_missed_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_requested_deadline_missed (const dds_listener_t * __restrict listener, dds_on_requested_deadline_missed_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the requested_incompatible_qos callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_requested_incompatible_qos_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_requested_incompatible_qos (const dds_listener_t * __restrict listener, dds_on_requested_incompatible_qos_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the publication_matched callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_publication_matched_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_publication_matched (const dds_listener_t * __restrict listener, dds_on_publication_matched_fn *callback);
/**
* @ingroup listener_getters
* @brief Get the subscription_matched callback from the listener structure.
*
* Equivalent to calling @ref dds_lget_subscription_matched_arg with arg and reset_on_invoke set to a null pointer and throwing away the result.
*
* @param[in] listener The pointer to the listener structure, where the callback will be retrieved from
* @param[out] callback Callback function; may be a null pointer
*/
DDS_EXPORT void dds_lget_subscription_matched (const dds_listener_t * __restrict listener, dds_on_subscription_matched_fn *callback);
#if defined (__cplusplus)
}
#endif
#endif /*_DDS_PUBLIC_LISTENER_H_*/

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,184 @@
/*
* Copyright(c) 2006 to 2022 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef DDS_QOSDEFS_H
#define DDS_QOSDEFS_H
#include <stdint.h>
#if defined (__cplusplus)
extern "C" {
#endif
/**
* @anchor DDS_LENGTH_UNLIMITED
* @ingroup qos
* @brief Used for indicating unlimited length in dds_qset_resource_limits()
*/
#define DDS_LENGTH_UNLIMITED -1
/**
* @brief Qos Policy IDs
* @ingroup internal
* Used internally to mark the QoS policy type
*/
typedef enum dds_qos_policy_id {
DDS_INVALID_QOS_POLICY_ID, /**< Invalid Policy */
DDS_USERDATA_QOS_POLICY_ID, /**< Userdata policy dds_qset_userdata() */
DDS_DURABILITY_QOS_POLICY_ID, /**< Durability policy dds_qset_durability() */
DDS_PRESENTATION_QOS_POLICY_ID, /**< Presentation policy dds_qset_presentation() */
DDS_DEADLINE_QOS_POLICY_ID, /**< Deadline policy dds_qset_deadline() */
DDS_LATENCYBUDGET_QOS_POLICY_ID, /**< LatencyBudget policy dds_qset_latency_budget() */
DDS_OWNERSHIP_QOS_POLICY_ID, /**< Ownership policy dds_qset_ownership() */
DDS_OWNERSHIPSTRENGTH_QOS_POLICY_ID, /**< OwnershipStrength policy dds_qset_ownership_strength() */
DDS_LIVELINESS_QOS_POLICY_ID, /**< Liveliness policy dds_qset_liveliness() */
DDS_TIMEBASEDFILTER_QOS_POLICY_ID, /**< TimeBasedFilter policy dds_qset_time_based_filter() */
DDS_PARTITION_QOS_POLICY_ID, /**< Partition policy dds_qset_partition() */
DDS_RELIABILITY_QOS_POLICY_ID, /**< Reliability policy dds_qset_reliability() */
DDS_DESTINATIONORDER_QOS_POLICY_ID, /**< DestinationOrder policy dds_qset_destination_order() */
DDS_HISTORY_QOS_POLICY_ID, /**< History policy dds_qset_history() */
DDS_RESOURCELIMITS_QOS_POLICY_ID, /**< ResourceLimits policy dds_qset_resource_limits() */
DDS_ENTITYFACTORY_QOS_POLICY_ID, /**< EntityFactory policy */
DDS_WRITERDATALIFECYCLE_QOS_POLICY_ID, /**< WriterDataLifecycle policy dds_qset_writer_data_lifecycle() */
DDS_READERDATALIFECYCLE_QOS_POLICY_ID, /**< ReaderDataLifecycle policy dds_qset_reader_data_lifecycle() */
DDS_TOPICDATA_QOS_POLICY_ID, /**< Topicdata policy dds_qset_topicdata() */
DDS_GROUPDATA_QOS_POLICY_ID, /**< Groupdata policy dds_qset_groupdata() */
DDS_TRANSPORTPRIORITY_QOS_POLICY_ID, /**< TransportPriority policy dds_qset_transport_priority() */
DDS_LIFESPAN_QOS_POLICY_ID, /**< Livespan policy dds_qset_lifespan() */
DDS_DURABILITYSERVICE_QOS_POLICY_ID, /**< DurabilityService policy dds_qset_durability_service() */
DDS_PROPERTY_QOS_POLICY_ID, /**< Property policy dds_qset_property() */
DDS_TYPE_CONSISTENCY_ENFORCEMENT_QOS_POLICY_ID, /**< TypeConsistencyEnforcement policy dds_qset_type_consistency_enforcements() */
DDS_DATA_REPRESENTATION_QOS_POLICY_ID /**< DataRepresentation policy dds_qset_data_representation() */
} dds_qos_policy_id_t;
/**
* @brief QoS datatype
* @ingroup qos
* QoS structure is opaque
*/
typedef struct dds_qos dds_qos_t;
/**
* @brief Durability QoS: Applies to Topic, DataReader, DataWriter
* @ingroup qos
*/
typedef enum dds_durability_kind
{
DDS_DURABILITY_VOLATILE, /**< Volatile durability */
DDS_DURABILITY_TRANSIENT_LOCAL, /**< Transient Local durability */
DDS_DURABILITY_TRANSIENT, /**< Transient durability */
DDS_DURABILITY_PERSISTENT /**< Persistent durability */
}
dds_durability_kind_t;
/**
* @brief History QoS: Applies to Topic, DataReader, DataWriter
* @ingroup qos
*/
typedef enum dds_history_kind
{
DDS_HISTORY_KEEP_LAST, /**< Keep Last history */
DDS_HISTORY_KEEP_ALL /**< Keep All history */
}
dds_history_kind_t;
/**
* @brief Ownership QoS: Applies to Topic, DataReader, DataWriter
* @ingroup qos
*/
typedef enum dds_ownership_kind
{
DDS_OWNERSHIP_SHARED, /**< Shared Ownership */
DDS_OWNERSHIP_EXCLUSIVE /**< Exclusive Ownership */
}
dds_ownership_kind_t;
/**
* @brief Liveliness QoS: Applies to Topic, DataReader, DataWriter
* @ingroup qos
*/
typedef enum dds_liveliness_kind
{
DDS_LIVELINESS_AUTOMATIC, /**< Automatic liveliness */
DDS_LIVELINESS_MANUAL_BY_PARTICIPANT, /**< Manual by Participant liveliness */
DDS_LIVELINESS_MANUAL_BY_TOPIC /**< Manual by Topic liveliness */
}
dds_liveliness_kind_t;
/**
* @brief Reliability QoS: Applies to Topic, DataReader, DataWriter
* @ingroup qos
*/
typedef enum dds_reliability_kind
{
DDS_RELIABILITY_BEST_EFFORT, /**< Best Effort reliability */
DDS_RELIABILITY_RELIABLE /**< Reliable reliability */
}
dds_reliability_kind_t;
/**
* @brief DestinationOrder QoS: Applies to Topic, DataReader, DataWriter
* @ingroup qos
*/
typedef enum dds_destination_order_kind
{
DDS_DESTINATIONORDER_BY_RECEPTION_TIMESTAMP, /**< order by reception timestamp */
DDS_DESTINATIONORDER_BY_SOURCE_TIMESTAMP /**< order by source timestamp */
}
dds_destination_order_kind_t;
/**
* @brief Presentation QoS: Applies to Publisher, Subscriber
* @ingroup qos
*/
typedef enum dds_presentation_access_scope_kind
{
DDS_PRESENTATION_INSTANCE, /**< presentation scope per instance */
DDS_PRESENTATION_TOPIC, /**< presentation scope per topic */
DDS_PRESENTATION_GROUP /**< presentation scope per group */
}
dds_presentation_access_scope_kind_t;
/**
* @brief Ignore-local QoS: Applies to DataReader, DataWriter
* @ingroup qos
*/
typedef enum dds_ignorelocal_kind
{
DDS_IGNORELOCAL_NONE, /**< Don't ignore local data */
DDS_IGNORELOCAL_PARTICIPANT, /**< Ignore local data from same participant */
DDS_IGNORELOCAL_PROCESS /**< Ignore local data from same process */
}
dds_ignorelocal_kind_t;
/**
* @brief Type-consistency QoS: Applies to DataReader, DataWriter
* @ingroup qos
*/
typedef enum dds_type_consistency_kind
{
DDS_TYPE_CONSISTENCY_DISALLOW_TYPE_COERCION, /**< Do not allow type coercion */
DDS_TYPE_CONSISTENCY_ALLOW_TYPE_COERCION /**< Allow type coercion */
}
dds_type_consistency_kind_t;
/**
* @brief Data Representation QoS: Applies to Topic, DataReader, DataWriter
* @ingroup qos
*/
typedef int16_t dds_data_representation_id_t;
#if defined (__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,512 @@
/*
* Copyright(c) 2006 to 2019 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
/**
* @defgroup dcps_status (DDS C Communication Status API)
* @ingroup dds
* This defines the public API of the Communication Status in the
* Eclipse Cyclone DDS C language binding. Listeners are implemented
* as structs containing callback functions that take listener status types
* as arguments.
*/
#ifndef DDS_STATUS_H
#define DDS_STATUS_H
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
/**
* @ingroup dcps_status
* @brief DCPS_Status_OfferedDeadlineMissed
* DOC_TODO
*/
typedef struct dds_offered_deadline_missed_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
dds_instance_handle_t last_instance_handle; /**< DOC_TODO */
}
dds_offered_deadline_missed_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_OfferedIncompatibleQoS
* DOC_TODO
*/
typedef struct dds_offered_incompatible_qos_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
uint32_t last_policy_id; /**< DOC_TODO */
}
dds_offered_incompatible_qos_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_PublicationMatched
* DOC_TODO
*/
typedef struct dds_publication_matched_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
uint32_t current_count; /**< DOC_TODO */
int32_t current_count_change; /**< DOC_TODO */
dds_instance_handle_t last_subscription_handle; /**< DOC_TODO */
}
dds_publication_matched_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_LivelinessLost
* DOC_TODO
*/
typedef struct dds_liveliness_lost_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
}
dds_liveliness_lost_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_SubscriptionMatched
* DOC_TODO
*/
typedef struct dds_subscription_matched_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
uint32_t current_count; /**< DOC_TODO */
int32_t current_count_change; /**< DOC_TODO */
dds_instance_handle_t last_publication_handle; /**< DOC_TODO */
}
dds_subscription_matched_status_t;
/**
* @ingroup dcps_status
* @brief Rejected Status
* DOC_TODO
*/
typedef enum
{
DDS_NOT_REJECTED, /**< DOC_TODO */
DDS_REJECTED_BY_INSTANCES_LIMIT, /**< DOC_TODO */
DDS_REJECTED_BY_SAMPLES_LIMIT, /**< DOC_TODO */
DDS_REJECTED_BY_SAMPLES_PER_INSTANCE_LIMIT /**< DOC_TODO */
}
dds_sample_rejected_status_kind;
/**
* @ingroup dcps_status
* @brief DCPS_Status_SampleRejected
* DOC_TODO
*/
typedef struct dds_sample_rejected_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
dds_sample_rejected_status_kind last_reason; /**< DOC_TODO */
dds_instance_handle_t last_instance_handle; /**< DOC_TODO */
}
dds_sample_rejected_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_LivelinessChanged
* DOC_TODO
*/
typedef struct dds_liveliness_changed_status
{
uint32_t alive_count; /**< DOC_TODO */
uint32_t not_alive_count; /**< DOC_TODO */
int32_t alive_count_change; /**< DOC_TODO */
int32_t not_alive_count_change; /**< DOC_TODO */
dds_instance_handle_t last_publication_handle; /**< DOC_TODO */
}
dds_liveliness_changed_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_RequestedDeadlineMissed
* DOC_TODO
*/
typedef struct dds_requested_deadline_missed_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
dds_instance_handle_t last_instance_handle; /**< DOC_TODO */
}
dds_requested_deadline_missed_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_RequestedIncompatibleQoS
* DOC_TODO
*/
typedef struct dds_requested_incompatible_qos_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
uint32_t last_policy_id; /**< DOC_TODO */
}
dds_requested_incompatible_qos_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_SampleLost
* DOC_TODO
*/
typedef struct dds_sample_lost_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
}
dds_sample_lost_status_t;
/**
* @ingroup dcps_status
* @brief DCPS_Status_InconsistentTopic
* DOC_TODO
*/
typedef struct dds_inconsistent_topic_status
{
uint32_t total_count; /**< DOC_TODO */
int32_t total_count_change; /**< DOC_TODO */
}
dds_inconsistent_topic_status_t;
/**
* @defgroup dcps_status_getters (DCPS Status Getters)
* @ingroup dcps_status
* get_<status> APIs return the status of an entity and resets the status
*/
/**
* @ingroup dcps_status_getters
* @brief Get INCONSISTENT_TOPIC status
*
* This operation gets the status value corresponding to INCONSISTENT_TOPIC
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] topic The entity to get the status
* @param[out] status The pointer to @ref dds_inconsistent_topic_status_t to get the status
*
* @returns 0 - Success
* @returns <0 - Failure
*
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_inconsistent_topic_status (
dds_entity_t topic,
dds_inconsistent_topic_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get PUBLICATION_MATCHED status
*
* This operation gets the status value corresponding to PUBLICATION_MATCHED
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] writer The entity to get the status
* @param[out] status The pointer to @ref dds_publication_matched_status_t to get the status
*
* @returns 0 - Success
* @returns <0 - Failure
*
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_publication_matched_status (
dds_entity_t writer,
dds_publication_matched_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get LIVELINESS_LOST status
*
* This operation gets the status value corresponding to LIVELINESS_LOST
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] writer The entity to get the status
* @param[out] status The pointer to @ref dds_liveliness_lost_status_t to get the status
*
* @returns 0 - Success
* @returns <0 - Failure
*
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_liveliness_lost_status (
dds_entity_t writer,
dds_liveliness_lost_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get OFFERED_DEADLINE_MISSED status
*
* This operation gets the status value corresponding to OFFERED_DEADLINE_MISSED
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] writer The entity to get the status
* @param[out] status The pointer to @ref dds_offered_deadline_missed_status_t to get the status
*
* @returns 0 - Success
* @returns <0 - Failure
*
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_offered_deadline_missed_status(
dds_entity_t writer,
dds_offered_deadline_missed_status_t *status);
/**
* @ingroup dcps_status_getters
* @brief Get OFFERED_INCOMPATIBLE_QOS status
*
* This operation gets the status value corresponding to OFFERED_INCOMPATIBLE_QOS
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] writer The writer entity to get the status
* @param[out] status The pointer to @ref dds_offered_incompatible_qos_status_t to get the status
*
* @returns 0 - Success
* @returns <0 - Failure
*
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_offered_incompatible_qos_status (
dds_entity_t writer,
dds_offered_incompatible_qos_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get SUBSCRIPTION_MATCHED status
*
* This operation gets the status value corresponding to SUBSCRIPTION_MATCHED
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] reader The reader entity to get the status
* @param[out] status The pointer to @ref dds_subscription_matched_status_t to get the status
*
* @returns 0 - Success
* @returns <0 - Failure
*
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_subscription_matched_status (
dds_entity_t reader,
dds_subscription_matched_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get LIVELINESS_CHANGED status
*
* This operation gets the status value corresponding to LIVELINESS_CHANGED
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] reader The entity to get the status
* @param[out] status The pointer to @ref dds_liveliness_changed_status_t to get the status
*
* @returns 0 - Success
* @returns <0 - Failure
*
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_liveliness_changed_status (
dds_entity_t reader,
dds_liveliness_changed_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get SAMPLE_REJECTED status
*
* This operation gets the status value corresponding to SAMPLE_REJECTED
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] reader The entity to get the status
* @param[out] status The pointer to @ref dds_sample_rejected_status_t to get the status
*
* @returns 0 - Success
* @returns <0 - Failure
*
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_sample_rejected_status (
dds_entity_t reader,
dds_sample_rejected_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get SAMPLE_LOST status
*
* This operation gets the status value corresponding to SAMPLE_LOST
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] reader The entity to get the status
* @param[out] status The pointer to @ref dds_sample_lost_status_t to get the status
*
* @returns A dds_return_t indicating success or failure
*
* @retval DDS_RETCODE_OK
* Success
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_sample_lost_status (
dds_entity_t reader,
dds_sample_lost_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get REQUESTED_DEADLINE_MISSED status
*
* This operation gets the status value corresponding to REQUESTED_DEADLINE_MISSED
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] reader The entity to get the status
* @param[out] status The pointer to @ref dds_requested_deadline_missed_status_t to get the status
*
* @returns A dds_return_t indicating success or failure
*
* @retval DDS_RETCODE_OK
* Success
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_requested_deadline_missed_status (
dds_entity_t reader,
dds_requested_deadline_missed_status_t * status);
/**
* @ingroup dcps_status_getters
* @brief Get REQUESTED_INCOMPATIBLE_QOS status
*
* This operation gets the status value corresponding to REQUESTED_INCOMPATIBLE_QOS
* and reset the status. The value can be obtained, only if the status is enabled for an entity.
* NULL value for status is allowed and it will reset the trigger value when status is enabled.
*
* @param[in] reader The entity to get the status
* @param[out] status The pointer to @ref dds_requested_incompatible_qos_status_t to get the status
*
* @returns A dds_return_t indicating success or failure
*
* @retval DDS_RETCODE_OK
* Success
* @retval DDS_RETCODE_ERROR
* An internal error has occurred.
* @retval DDS_RETCODE_BAD_PARAMETER
* One of the given arguments is not valid.
* @retval DDS_RETCODE_ILLEGAL_OPERATION
* The operation is invoked on an inappropriate object.
* @retval DDS_RETCODE_ALREADY_DELETED
* The entity has already been deleted.
*/
DDS_EXPORT dds_return_t
dds_get_requested_incompatible_qos_status (
dds_entity_t reader,
dds_requested_incompatible_qos_status_t * status);
#if defined (__cplusplus)
}
#endif
#endif

View File

@@ -0,0 +1,109 @@
/*
* Copyright(c) 2006 to 2021 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef _DDS_RHC_H_
#define _DDS_RHC_H_
#include "dds/ddsrt/static_assert.h"
#include "dds/ddsi/ddsi_rhc.h"
#ifndef DOXYGEN_SHOULD_SKIP_THIS /** DOC_TODO we should document the rhc */
#define NO_STATE_MASK_SET (DDS_ANY_STATE + 1)
#if defined (__cplusplus)
extern "C" {
#endif
struct dds_rhc;
struct dds_readcond;
struct dds_reader;
struct ddsi_tkmap;
typedef dds_return_t (*dds_rhc_associate_t) (struct dds_rhc *rhc, struct dds_reader *reader, const struct ddsi_sertype *type, struct ddsi_tkmap *tkmap);
typedef int32_t (*dds_rhc_read_take_t) (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond);
typedef int32_t (*dds_rhc_read_take_cdr_t) (struct dds_rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t sample_states, uint32_t view_states, uint32_t instance_states, dds_instance_handle_t handle);
typedef bool (*dds_rhc_add_readcondition_t) (struct dds_rhc *rhc, struct dds_readcond *cond);
typedef void (*dds_rhc_remove_readcondition_t) (struct dds_rhc *rhc, struct dds_readcond *cond);
typedef uint32_t (*dds_rhc_lock_samples_t) (struct dds_rhc *rhc);
struct dds_rhc_ops {
/* A copy of DDSI rhc ops comes first so we can use either interface without
additional indirections */
struct ddsi_rhc_ops rhc_ops;
dds_rhc_read_take_t read;
dds_rhc_read_take_t take;
dds_rhc_read_take_cdr_t readcdr;
dds_rhc_read_take_cdr_t takecdr;
dds_rhc_add_readcondition_t add_readcondition;
dds_rhc_remove_readcondition_t remove_readcondition;
dds_rhc_lock_samples_t lock_samples;
dds_rhc_associate_t associate;
};
struct dds_rhc {
union {
const struct dds_rhc_ops *ops;
struct ddsi_rhc rhc;
} common;
};
DDSRT_STATIC_ASSERT (offsetof (struct dds_rhc, common.ops) == offsetof (struct ddsi_rhc, ops));
DDS_INLINE_EXPORT inline dds_return_t dds_rhc_associate (struct dds_rhc *rhc, struct dds_reader *reader, const struct ddsi_sertype *type, struct ddsi_tkmap *tkmap) {
return rhc->common.ops->associate (rhc, reader, type, tkmap);
}
DDS_INLINE_EXPORT inline bool dds_rhc_store (struct dds_rhc * __restrict rhc, const struct ddsi_writer_info * __restrict wrinfo, struct ddsi_serdata * __restrict sample, struct ddsi_tkmap_instance * __restrict tk) {
return rhc->common.ops->rhc_ops.store (&rhc->common.rhc, wrinfo, sample, tk);
}
DDS_INLINE_EXPORT inline void dds_rhc_unregister_wr (struct dds_rhc * __restrict rhc, const struct ddsi_writer_info * __restrict wrinfo) {
rhc->common.ops->rhc_ops.unregister_wr (&rhc->common.rhc, wrinfo);
}
DDS_INLINE_EXPORT inline void dds_rhc_relinquish_ownership (struct dds_rhc * __restrict rhc, const uint64_t wr_iid) {
rhc->common.ops->rhc_ops.relinquish_ownership (&rhc->common.rhc, wr_iid);
}
DDS_INLINE_EXPORT inline void dds_rhc_set_qos (struct dds_rhc *rhc, const struct dds_qos *qos) {
rhc->common.ops->rhc_ops.set_qos (&rhc->common.rhc, qos);
}
DDS_INLINE_EXPORT inline void dds_rhc_free (struct dds_rhc *rhc) {
rhc->common.ops->rhc_ops.free (&rhc->common.rhc);
}
DDS_INLINE_EXPORT inline int32_t dds_rhc_read (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond) {
return (rhc->common.ops->read) (rhc, lock, values, info_seq, max_samples, mask, handle, cond);
}
DDS_INLINE_EXPORT inline int32_t dds_rhc_take (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond) {
return rhc->common.ops->take (rhc, lock, values, info_seq, max_samples, mask, handle, cond);
}
DDS_INLINE_EXPORT inline int32_t dds_rhc_readcdr (struct dds_rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t sample_states, uint32_t view_states, uint32_t instance_states, dds_instance_handle_t handle) {
return rhc->common.ops->readcdr (rhc, lock, values, info_seq, max_samples, sample_states, view_states, instance_states, handle);
}
DDS_INLINE_EXPORT inline int32_t dds_rhc_takecdr (struct dds_rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t sample_states, uint32_t view_states, uint32_t instance_states, dds_instance_handle_t handle) {
return rhc->common.ops->takecdr (rhc, lock, values, info_seq, max_samples, sample_states, view_states, instance_states, handle);
}
DDS_INLINE_EXPORT inline bool dds_rhc_add_readcondition (struct dds_rhc *rhc, struct dds_readcond *cond) {
return rhc->common.ops->add_readcondition (rhc, cond);
}
DDS_INLINE_EXPORT inline void dds_rhc_remove_readcondition (struct dds_rhc *rhc, struct dds_readcond *cond) {
rhc->common.ops->remove_readcondition (rhc, cond);
}
DDS_INLINE_EXPORT inline uint32_t dds_rhc_lock_samples (struct dds_rhc *rhc) {
return rhc->common.ops->lock_samples (rhc);
}
DDS_EXPORT void dds_reader_data_available_cb (struct dds_reader *rd);
#if defined (__cplusplus)
}
#endif
#endif
#endif

View File

@@ -0,0 +1,133 @@
/*
* Copyright(c) 2020 ZettaScale Technology and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
* v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
#ifndef DDS_STATISTICS_H
#define DDS_STATISTICS_H
/**
* @defgroup statistics (DDS Statistics)
* @ingroup dds
* @warning Unstable API
*
* A quick-and-dirty provisional interface
*/
#include "dds/dds.h"
#include "dds/ddsrt/attributes.h"
#include "dds/export.h"
#if defined (__cplusplus)
extern "C" {
#endif
/**
* @brief Kind of statistical value
* @ingroup statistics
*/
enum dds_stat_kind {
DDS_STAT_KIND_UINT32, /**< value is a 32-bit unsigned integer */
DDS_STAT_KIND_UINT64, /**< value is a 64-bit unsigned integer */
DDS_STAT_KIND_LENGTHTIME /**< value is integral(length(t) dt) */
};
/**
* @brief KeyValue statistics entry
* @ingroup statistics
*/
struct dds_stat_keyvalue {
const char *name; /**< name, memory owned by library */
enum dds_stat_kind kind; /**< value type */
union {
uint32_t u32; /**< used if kind == DDS_STAT_KIND_UINT32 */
uint64_t u64; /**< used if kind == DDS_STAT_KIND_UINT64 */
uint64_t lengthtime; /**< used if kind == DDS_STAT_KIND_LENGTHTIME */
} u; /**< value */
};
/**
* @brief Statistics container
* @ingroup statistics
*/
struct dds_statistics {
dds_entity_t entity; /**< handle of entity to which this set of values applies */
uint64_t opaque; /**< internal data */
dds_time_t time; /**< time stamp of latest call to dds_refresh_statistics() */
size_t count; /**< number of key-value pairs */
struct dds_stat_keyvalue kv[]; /**< data */
};
/**
* @brief Allocate a new statistics object for entity
* @ingroup statistics
*
* This allocates and populates a newly allocated `struct dds_statistics` for the
* specified entity.
*
* @param[in] entity the handle of the entity
*
* @returns a newly allocated and populated statistics structure or NULL if entity is
* invalid or doesn't support any statistics.
*/
DDS_EXPORT struct dds_statistics *dds_create_statistics (dds_entity_t entity);
/**
* @brief Update a previously created statistics structure with current values
* @ingroup statistics
*
* Only the time stamp and the values (and "opaque") may change. The set of keys and the
* types of the values do not change.
*
* @param[in,out] stat statistics structure to update the values of
*
* @returns success or an error indication
*
* @retval DDS_RETCODE_OK
* the data was successfully updated
* @retval DDS_RETCODE_BAD_PARAMETER
* stats is a null pointer or the referenced entity no longer exists
* @retval DDS_RETCODE_PRECONDITION_NOT_MET
* library was deinitialized
*/
DDS_EXPORT dds_return_t dds_refresh_statistics (struct dds_statistics *stat);
/**
* @brief Free a previously created statistics object
* @ingroup statistics
*
* This frees the statistics object. Passing a null pointer is a no-op. The operation
* succeeds also if the referenced entity no longer exists.
*
* @param[in] stat statistics object to free
*/
DDS_EXPORT void dds_delete_statistics (struct dds_statistics *stat);
/**
* @brief Lookup a specific value by name
* @ingroup statistics
*
* This looks up the specified name in the list of keys in `stat` and returns the address
* of the key-value pair if present, a null pointer if not. If `stat` is a null pointer,
* it returns a null pointer.
*
* @param[in] stat statistics object to lookup a name in (or NULL)
* @param[in] name name to look for
*
* @returns The address of the key-value pair inside `stat`, or NULL if `stat` is NULL or
* `name` does not match a key in `stat.
*/
DDS_EXPORT const struct dds_stat_keyvalue *dds_lookup_statistic (const struct dds_statistics *stat, const char *name)
ddsrt_nonnull ((2));
#if defined (__cplusplus)
}
#endif
#endif