IDL stuct inheritance and DynamicData

2 posts / 0 new
Last post
Offline
Last seen: 4 years 1 month ago
Joined: 04/29/2016
Posts: 9
IDL stuct inheritance and DynamicData

I am having problems finding the keys an inherited struct when using DynamicData. I am getting an error output from Connext in the "background" (the return code is ok) when calling is_member_key on some (not all) elements of an inherited struct.
If the key is defined in the base, then is_member_key never finds the key at all. Am I doing something wrong or is this a bug (I am using Connect 5.1)?

Here is a small example to illustrate the problem.
I am using rtiddsgen to generate an xml definition from the IDL.

 

[IDL]
module M_Testing {
    struct Test_A {
        long        x;//@key
        long        y;
    };
    struct Test_B : Test_A {
        long        z;
    };
};


[CPP]
DDS_StringSeq paths;
DDS_ExceptionCode_t ex;
DDS_TypeCode* tc = DDS_TypeCodeFactory::get_instance()->create_tc_from_xml_file( "M_Testing.xml", "M_Testing::Test_B", paths, 1000, 1000, ex );
DDS_DynamicData data( tc, DDS_DYNAMIC_DATA_PROPERTY_DEFAULT );

data.set_long( "x", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED, 1 );
data.set_long( "y", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED, 2 );
data.set_long( "z", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED, 3 );

DDS_Boolean isKey = DDS_BOOLEAN_FALSE;
DDS_ReturnCode_t res = data.is_member_key( isKey, "x", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED );
if ( res != DDS_RETCODE_OK ) {
    std::cout << "is_member_key(x) failed, res=" << res << std::endl;
    return 0;
}
if ( isKey == DDS_BOOLEAN_TRUE ) {
    std::cout << "x is a key" << std::endl;
} else {
    std::cout << "x is NOT a key" << std::endl;
}

isKey = DDS_BOOLEAN_FALSE;
res = data.is_member_key( isKey, "y", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED );
if ( res != DDS_RETCODE_OK ) {
    std::cout << "is_member_key(y) failed, res=" << res << std::endl;
    return 0;
}
if ( isKey == DDS_BOOLEAN_TRUE ) {
    std::cout << "y is a key" << std::endl;
} else {
    std::cout << "y is NOT a key" << std::endl;
}

isKey = DDS_BOOLEAN_FALSE;
res = data.is_member_key( isKey, "z", DDS_DYNAMIC_DATA_MEMBER_ID_UNSPECIFIED );
if ( res != DDS_RETCODE_OK ) {
    std::cout << "is_member_key(z) failed, res=" << res << std::endl;
    return 0;
}
if ( isKey == DDS_BOOLEAN_TRUE ) {
    std::cout << "z is a key" << std::endl;
} else {
    std::cout << "z is NOT a key" << std::endl;
}


[OUTPUT]
x is NOT a key
DDS_DynamicData_is_member_key:typecode error 7 on is_member_key
y is NOT a key
z is NOT a key

gianpiero's picture
Offline
Last seen: 2 weeks 6 days ago
Joined: 06/02/2010
Posts: 174

 

Hello Michael,

Thanks for writing on the forum and providing such a good reproducer. I was able to reproduce the issue and I have been looking in the our code. Unfortunately i believe is a bug and I did file a bug in our internal system (Bug # CORE-7505) . We did find a fix and we are working on implementing it. Contact support to find out when this bug will be rolled out or if you are in a rush. 

Also, the bug is related to the fact that you are using inheritance in your types.. i am not sure if you can get rid of that for now while waiting for the fix. 

I apoligize for the issue and thanks for reporting it again! 

Best,
  Gianpiero

 

Michael