Dynamic Data: Accessing Sequence Members
Concept
Dynamic Data provides an easy way to access the members of a data sample. Such members can be primitive data types or complex data types such as arrays or sequences.
While the access to certain members is done by name, the access in multiple cardinality data types—such as arrays or sequences—is done by index. Primitive type sequences (e.g., DDS_Long
and DDS_Double
sequences) can be usually accessed using dedicated methods such as get_<type>_array()
and get_<type>_seq()
. However, that approach is not possible for non-primitive data (e.g., user defined types).
Using Dynamic Data you can access elements of arrays and sequences using a 1-based index access using the get_complex_member()
and bind_complex_member()
methods.
Example Description
This example shows how to access elements in array- and sequence-based Dynamic Data types. In the example we define the following types:
struct SimpleStruct { long a_member; }; struct TypeWithSequence { sequence<MAX_LEN,SimpleStruct> sequence_member; };
Note that the concepts shown in this example work for both arrays and primitive sequences.
Download Example
Browse Example
- c
- c++11
- c++98
- cs
- java
- README.md
Comments
TorGo
Tue, 08/09/2016 - 01:41
Permalink
sequence parameters swaped
Is it just me, or should line 6 be
sequence<SimpleStruct,
MAX_LEN>
sequence_member;instead of
sequence<
MAX_LEN, SimpleStruct>
sequence_member;?
okellogg
Mon, 11/13/2023 - 07:28
Permalink
Example for alias typedef
I haven't found any examples on how to handle TK_ALIAS.
Perhaps this example could be extended, e.g. by
and then including another member in the struct,