I'm trying to add the following functionality to my app: with knowledge of a DynamicType, it parses any field at any depth of a DynamicData instance of that type. For example, I have the following idl:
struct Point {
double x;
double y;
};
struct Odometry {
Point point;
};
struct Location {
Odometry odometry;
};
WIth a DynamicData sample of type Location, I would like to get the value of sample.odometry, sample.odometry.point or sample.odometry.point.x as requested by the user. I'm able to solve part of the problem using the "value" api of DynamicData.
auto data0 = sample.value<DynamicData>("odometry");
auto data1 = sample.value<DynamicData>("odometry.point");
However, this no longer works when it comes to primitive types:
auto data0 = sample.value<DynamicData>("odometry.point.x"); // runtime error
It seems that when I reach the deepest level, I can no longer treat the field as a DynamicData. Instead I have to use its "real" type, i.e. int. double or string. What I want eventually is a function like this
DynamicData getField(const DynamicData& data, const std::vector<Field>& fields);
Hi,
Good afternoon!
Is your goal just to retrieve the value of the primitive type? That would be quite trivial, and you will be able to do so as shown in the samples below:
https://community.rti.com/static/documentation/connext-dds/6.1.1/doc/api/connext_dds/api_cpp2/group__DDSXTypesExampleModule.html
Or is there any particular reason you would like to cast the primitive type as a DynamicData instance?
But anyway, I believe you are a customer with a support account and such questions can actually be directed to our support team and they will be best equipped to advise you on the proper API use.
You can contact me at zklim@rti.com to discuss this further as well.
Thanks!