Why does my keyed data type behave as if there is no key?
Note: Applies to RTI Connext 4.x and above
These are some common errors when specifying the key in the IDL:
- In the IDL file, you must use
//@key
after the key field. Do not use a space between any of these characters://@key
- Also note that the directive is case-sensitive—use all lower case.
- Only struct definitions in IDL may have key fields.
- When rtiddsgen encounters
//@key
, it considers the previously declared field in the enclosing structure to be part of the key. For example:
struct Foo { short not_a_key1; long this_is_the_key; //@key octet not_a_key2; };
This is true even if //@key
is on a line by itself. For instance, the following is equivalent to the preceding example:
struct Foo { short not_a_key1; long this_is_the_key; //@key octet not_a_key2; };
See the Core Libraries and Utilities User's Manual (User Data Types chapter) for more examples.
You can verify that the type plugin has been generated correctly by checking the generated code:
- In C or C++ look at the FooPlugin.c or FooPlugin.cxx file. It should contain a function/method
get_key_kind
which must returnPRES_TYPEPLUGIN_USER_KEY
. - Also, the relevant key methods must be implemented in the type plugin.
- In Java, the constructor for the
FooTypeSupport
class should pass TRUE to its parent class constructor in the second argument.