Convert user sample into a DynamicData sample

3 posts / 0 new
Last post
njc
Offline
Last seen: 10 years 8 months ago
Joined: 08/09/2012
Posts: 17
Convert user sample into a DynamicData sample

Hi,

I'd like to convert a user-defined sample into a DynamicData sample so that I can use typecodes to output the message in a custom format (in C++).

Say the user-data type is Foo defined in my IDL. I'm receiving messages via a FooDataReader and the Foo* structures are being passed through the code. At some point, I'd like to take a Foo* sample and output it in a custom format (there are actually many types, and I'd like to have a generic outputter that works with any type). To do that, it looks like I need the TypeCode and DynamicData APIs. I can get the type code information using Foo_get_typecode(), and I can create a DyanicData object from that. My problem is this DynamicData object doesn't represent my specific Foo sample. Is there any way to create a DynamicData object that already has all the data in the Foo sample?

It looks like I could create a separate DynamicData reader that gives me DynamicData samples instead of Foo samples, but I'd rather not create one reader for custom output and one reader for normal data processing.


Thanks,

-Neal

rip
rip's picture
Offline
Last seen: 4 days 12 hours ago
Joined: 04/06/2012
Posts: 324

Hi,

There isn't a way to use a generic Type<->DynamicData converter, it has to be written by hand, or auto-generated.  You can probably use rtiddsgen2 (with 5.1.0), and modify the type templates, such that an API for Type<->DynamicData conversion (as well as the conversions) are auto-generated.

This is unsupported.

I was going to suggest just using an untyped data reader direct to DynamicData, but you've already looked at that.  It's still easier then hacking the templates.

Rip

njc
Offline
Last seen: 10 years 8 months ago
Joined: 08/09/2012
Posts: 17

Thanks for the response. Will probably end up going with the untyped data reader in the end.