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 typessuch as arrays or sequencesis 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

Languages:

Comments

Is it just me, or should line 6 be

sequence<SimpleStruct,MAX_LEN> sequence_member;

instead of

sequence<MAX_LEN, SimpleStruct> sequence_member;

?

I haven't found any examples on how to handle TK_ALIAS.
Perhaps this example could be extended, e.g. by

typedef sequence<SimpleStruct, 2> SequenceType;

and then including another member in the struct,

SequenceType sequence_member2;