Serialization / Deserialization of a DDS data sample

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


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. 




rip's picture
Last seen: 3 days 20 hours ago
Joined: 04/06/2012
Posts: 324


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 interface.