back-and-forth conversion from legacy struct to dds type struct

3 posts / 0 new
Last post
Offline
Last seen: 5 years 5 months ago
Joined: 03/25/2015
Posts: 33
back-and-forth conversion from legacy struct to dds type struct

Hi,

I am looking into porting a legacy c-struct definition into idl definition so that the generated struct is used instead of the original c-struct. My c-struct doesn't have any fancy user-defined structures - just the well-known available c-types or enums.

Assuming I have the conversion ready, is there a way ('easier') for getting the c-struct from the dds generated struct. I said easier, as the other long way is to have a small plugin that does the conversion / mapping back. I am actually looking forward on serialize / deserialize functionality, but not sure if it can help me in this scenario.

Any ideas?

Thanks in advance.

Uday

Organization:
gianpiero's picture
Offline
Last seen: 11 months 2 weeks ago
Joined: 06/02/2010
Posts: 177

Hi Uday,

I am not sure I fully understand your problem but let me give you some pointers hoping that those will help you. 

  • When you have an IDL (e.g.: HelloWorld.idl) and you generate the code using rtiddsgen, the C structure is available in the header file called the same as the IDL (e.g.: HelloWorld.h)
  • We also generate for you a type support that allows you to create an instance of that structure:
HelloWorld *instance = HelloWorldTypeSupport_create_data_ex(DDS_BOOLEAN_FALSE);
  • In the generated code (e.g.: HelloWorldPlugin.c) we also generate functions to serialize / deserialize the code. Those function are called by the middleware when needed:
HelloWorldPlugin_serialize 
and
HelloWorldPlugin_deserialize  

I am not sure this will help you. Let me know.

Regards,
  Gianpiero

Offline
Last seen: 5 years 5 months ago
Joined: 03/25/2015
Posts: 33

Hi Gianpiero,

May be I haven't stated my problem clearly.

I already have a set of structs defined, that are widely used in all my applications. My objective is to introduce the equivalent dds struct topic of this for DDS communication. But, I dont want to use the new struct everywhere. So, effectively I am looking if I can convert the new struct to a byte stream and copy it to or cast as my legacy struct. If something like that isn't possible I would have to define some bridging functions which convert new struct to legacy one and vice-versa.

This should be the most common problem people face as they move from legacy systems to DDS-based systems. So I am just trying to find if there are any alternatives.

Uday