Serialization / Deserialization of a DDS data sample

2 posts / 0 new
Last post
Offline
Last seen: 9 years 3 months ago
Joined: 05/25/2014
Posts: 6
Serialization / Deserialization of a DDS data sample

Hello,

How can I take advantage of RTI's APIs in order to convert a data sample object which I read using a DataReader into a byte array and vice versa (in Java)?

I would like to save the binary serialized object to file and then be able to read it again into object. 

 

Thanks

David

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

Hi,

The serialize/deserialize of a Typed object happens in code auto-generated by rtiddsgen.  They are keyword public, not but part of the public API.  We don't supply any documentation on how to use them. 

Unfortunately, they only return a CDR Output Stream object (CdrOutputStream) and not a byte array.  CdrOutputStream may have a .getBytes(...):byte[] but it isn't documented.

It should be possible using rtiddsgen2 (experimental, distributed with 5.1.0 only) to write your own serialization/deserialization stubs using the existing serialize/deserialize template as (*cough*) a template.  This would then allow rtiddsgen2 to auto-generate Type-specific marshaling code for you.  If I were to attempt this, I would go all in and make FooType "serializable" by implementing the java.io.Serializable interface. 

rip