Instantiating Generated Type from Type Code

2 posts / 0 new
Last post
Offline
Last seen: 5 years 7 months ago
Joined: 11/07/2014
Posts: 13
Instantiating Generated Type from Type Code

I have "rtiddsgen" generated c++ types and I'm somewhat familiar with the usage of generated data reader, but what if you have extracted the type code from Dynamic Data and now want to instantiate the corresponding generated type from it. Is that possible? Is there an example of this somewhere?

Thanks,

D.K. Miller

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

Hi,

It looks like no one took a shot at answering this, so I will.

Given the typecode, pulled from Discovery, you can use it to instantiate a DynamicData object.  But, with typecode, you can't directly instantiate it as a (generated c++ type) instance.

Now, it is possible with rtiddsgen2 to hack the templates to generate an API and methods for taking the data from a DynamicData object and populating an instance, or taking an instance and populating a pre-typed DynamicData object.  I had a PoC once that did this in a routing service adapter, because I found working with the (generated) instances was a lot simpler then working with the DynamicData version of the data.  It defeats the purpose of the DynamicData libraries, however.

But there isn't a way to supply a class/struct/pojo from the typecode at runtime (you could also just use the typecode and the DynamicData libraries to generate IDL, run that through rtiddsgen, compile the resulting generated code as a shared object and then load that back into your running system.  I don't know if that sort of clunky magic is a good idea, though.  

May be that I missed the point of the question.  Let me know...