Delete last element of DynamicData sequence member

1 post / 0 new
Offline
Last seen: 1 year 6 months ago
Joined: 04/04/2014
Posts: 27
Delete last element of DynamicData sequence member

Hello,

I think my problem is related to Dynamic data sequence. Delete element. Java and is that it's not possible to delete the last element from the sequence with bind_complex_member() and clear_all_members() call. I dynamically create the type with sequence member:

struct test_type {
   sequence<double,20> double_seq;
   //@ID 0
   boolean bool_1;
   //@ID 1
}; //@Extensibility EXTENSIBLE_EXTENSIBILITY

Then I set several values in the sequence:

data->bind_complex_member(seqData, "double_seq", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED);
seqData.clear_all_members();
seqData.set_double(NULL, 1, 1);
seqData.set_double(NULL, 2, 2);
data->unbind_complex_member(seqData);

Everything works as expected and sequence contains two elements. After that I try to delete all elements from sequence:

data->bind_complex_member(seqData, "double_seq", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED);
seqData.clear_all_members();
data->unbind_complex_member(seqData);

After clear_all_members call on the member, the DynamicData still remains the same with 2 elements in sequence. Interesting that clear_all_members clears something because after following code only 1 element is set:

data->bind_complex_member(seqData, "double_seq", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED);
seqData.clear_all_members();
seqData.print(stdout, 0);
seqData.set_double(NULL, 1, 1);
data->unbind_complex_member(seqData);
data.print(stdout, 0);

The output shows as expected that bound DynamicData seqData is empty, but data still contains sequence with 2 elements.

====seqData: 
[0]:  
====data:
double_seq:
     [0]: 1.000000
     [1]: 2.000000
bool_1: true

I found only 2 alternative ways to delete all elements from the sequence member - set empty sequence or use internal call to

DDS_DoubleSeq seq;
data->set_double_seq("double_seq", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED, seq);

DDS_DynamicData_set_primitive_array_or_seqI(data, "double_seq", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED, 0, NULL, DDS_BOOLEAN_TRUE, DS_TK_DOUBLE, "dummy_method");

The second method is preferable for me, because I'm working with DynamicData object from Python via ctypes and don't create sequences directly.

Is clear_all_members() supposed to work this way with bound sequence members? I think there is some problem, because bound DynamicData correctly shows no members.

Thanks!

Organization:
Keywords: