Enum value name and type from DynamicData

2 posts / 0 new
Last post
Last seen: 2 months 21 hours ago
Joined: 11/22/2020
Posts: 1
Enum value name and type from DynamicData

I have defined an enum MyEnum in my IDL with values One and Two. Then I define a struct MyStruct with a single member myEnum of type MyEnum. So far so good.

Now, in my recorder service plugin I'm looking at MyStruct, but in the shape of a DynamicData. I can get the value of the enum with dynamicData.value(int32_t), but how can I translate that to "One" or "Two"? And how can I work out the name of the type ("MyEnum") for that member of the DynamicType? I'm using the modern C++ API of DDS version 6.0.1.

The RTI Admn Console presents the information I need in the "DDS Data Type" tab, so the information is there somewhere...

Howard's picture
Last seen: 2 days 23 hours ago
Joined: 11/29/2012
Posts: 131

You have to use the DynamicData method get_type() which will return a DDS_TypeCode object.

Then on the TypeCode object, you have to use member_type(i) to get the TypeCode object of the enum member.

Which you can verify by checking if TypeCode.kind is


enumerated type.

Then on the TypeCode of the enum member, you have to iterate through the members of the enum (which are the enumerations) using member(i) which will return the literal and member_ordinal(i) that will return the enumeration "value" corresponding to the literal.

You'll have to write a lookup method based on the parts above...or keep your own mapping of ordinal values to literals.