How do I specify a nested structure as the key for my data type?
This depends on what version of RTI Software you have installed:
- Version 4.2x and earlier: rtiddsgen only recognizes keys in the outermost structure.
- Version 4.3x and later: You can specify the key not only in the top-level message but also in nested structures.
Let's look at some use cases:
1) You want the top-level message to be keyed with just one field from a nested structure:
struct FirstKeyedType { long member1; //@key long member2; }; struct HelloWorldType { FirstKeyedType member1; //@key };
//@key
on the outer structure (HelloWorldType), it will consider that, within the structure, there are key fields. When it finds the //@key
on the inner structure (FirstKeyedType) it will know that "member1" is going to be both the key for the FirstKeyedType messages and the key for the HelloWorldType messages that will be published.
2) You want the top-level message to be keyed with all the fields from a nested structure:
struct FirstKeyedType { long member1; long member2; } struct HelloWorldType { FirstKeyedType member1; //@key }
//@key
on the outer structure (HelloWorldType) it will consider all the members of the nested structure (FirstKeyedType) to be part of the key.
3) If you do not specify a key in the top level structure, the topic will not be considered as a keyed topic.
The //@key
notation is ignored. This is an example of how not to describe your data type.
struct FirstKeyedType { long member1; //@key long member2; }; struct HelloWorldType { FirstKeyedType member1; };
Following these rules will allow you to successfully specify a nested structure as the key, no matter how complex your IDL file is.
Comments
TmOHaR
Thu, 04/16/2020 - 05:03
Permalink
Keyholders for nested keys in IDL
I'm looking for instructions to fill a key holder as described in use case 1. At the moment I don't seem to get a result when I don't fill member2 as well. Using Connext 6.0.1.
TmOHaR
Thu, 04/16/2020 - 06:25
Permalink
As for me not getting results
As for me not getting results when not filling member2, I messed up my dependencies. The instruction is rather straightforward, just fill in the key fields and it seems to work.