Source:
RTI (Rick Warren, rick.warren@rti.com)
Summary:
The specification does not provide a simple, portable way to create a new data sample to use with the middleware. Instead, there are several partial solutions:
· Instantiate a concrete sample type directly: “new Foo()”. This approach doesn’t work in generic methodsi.e. when the concrete type is not statically known. It also doesn’t work with DynamicData.
· Instantiate DynamicData from DynamicDataFactory. But samples of statically known, user-defined types don’t have a “data factory”.
· Use DataReader.createData(). But there is not equivalent on the publishing side.
There should be a single way that works uniformly and generically.
Proposed Resolution:
The proposed resolution has several parts:
1. Introduce a new factory instance method to the TypeSupport class: TypeSupport.newData(). The name of this method is parallel to that of other value type “constructor-like” factories.
2. Support navigation from the TopicDescription to the TypeSupport. Add a new method TopicDescription.getTypeSupport().
3. Simplify the number of ways to get from the data type’s TypeSupport to its Class. Add a method TypeSupport.getType(). Remove the existing methods TopicDescription.getType(), DataWriter.getType(), and DataReader.getType(): they are redundant.
4. Remove the existing method DataReader.createData() and the existing class DynamicDataFactory. They are not needed.
There will therefore be a single polymorphic and generic way to instantiate a sample of any type: by using its TypeSupport. (You can get the TypeSupport from any related TopicDescription, or transitively any DataReader or DataWriter.)
Likewise, there will be a single polymorphic and generic way to get the Class object for any data type: from its TypeSupport. As described in the previous paragraph, you can get to the TypeSupport from a variety of places.