5. DDS Options for Protocol Buffers
5.1. Message Options
Table 5.1 Message Options ( .omg.dds.type)Option
Description
Value
IDL4 Output
.nameSpecifies a custom name that will be used to identify the type when used on a DDS topic.
"MyCustomName"(non-empty string literal)
@type_name("MyCustomName")
.extensibilityControls the extensibility annotation of the corresponding IDL4
struct.
MUTABLE
@mutable
FINAL
@final
APPENDABLE
@appendable
.default_idSpecifies the default policy used to control the default
@idannotation emitted for each member of an IDL4struct.
PROTOBUF_DEFAULT_ID
@id(N)(on members)
DDS_DEFAULT_IDN/A (use default DDS id for each member)
.auto_idControls the
@autoidannotation for the IDL4struct.
NO_AUTO_IDN/A (no annotation)
SEQUENTIAL
@autoid(sequential)
HASH
@autoid(hash)
5.2. Field Options
Table 5.2 Field Options ( .omg.dds.member)Option
Description
Value
IDL4 Output
.keySpecifies whether the corresponding member is part of the DDS key.
true
@key
false(default)N/A (no annotation)
.optionalControls whether the corresponding member should be annotated as
@optional. If specified, this option will take precedence over the default annotionation derived from the field’s “presence”.
true
@optional
falseN/A (no annotation)
.default_idControls the default
@idannotation emitted for the corresponding member. If specified, this option will take precedence over the default policy set at the message level via option.omg.dds.type.default_id.See
.omg.dds.type.default_id.
.idExplicitly set and emit a specific
@idannotation for the corresponding member.
N(32-bit unsigned integer)
@id(N)
.hash_idGenerates the
@hashidannotation for the corresponding member with the specified source string.
"My String"(non-empty string literal)
@hashid("My String")
5.3. omg/dds/descriptor.proto
1syntax = "proto2";
2import "google/protobuf/descriptor.proto";
3
4package omg.dds;
5
6enum ExtensibilityKind {
7 MUTABLE = 0; // "Mutable" extensibility, members can be reordered, added, or removed.
8 APPENDABLE = 1; // "Appendable" extensibility, members can be added or removed from the end.
9 FINAL = 2; // "Final" extensibility, member cannot be added, removed or reordered.
10}
11
12enum DefaultIdKind {
13 PROTOBUF_DEFAULT_ID = 0; // Derive an @id annotation for each DDS member from the corresponding protobuf field number.
14 DDS_DEFAULT_ID = 1; // Do not emit @id annotations, unless explicitly provided through the "omg.dds.member.id" option.
15}
16
17enum AutoIdKind {
18 NO_AUTO_ID = 0; // Do not emit an @autoid annotation
19 SEQUENTIAL = 1; // Emit @autoid(sequential) to use sequential IDs starting from 0
20 HASH = 2; // Emit @autoid(hash), to use a hash of the field name to generate IDs
21}
22
23message TypeAnnotation {
24 optional string name = 1;
25 optional ExtensibilityKind extensibility = 2;
26 optional DefaultIdKind default_id = 3;
27 optional AutoIdKind auto_id = 4;
28}
29
30extend google.protobuf.MessageOptions {
31 optional TypeAnnotation type = 7400;
32}
33
34message MemberAnnotation {
35 optional bool key = 1;
36 optional bool filterable = 2;
37 optional bool optional = 3;
38 optional DefaultIdKind default_id = 4;
39 optional uint32 id = 5;
40 optional string hash_id = 6;
41}
42
43extend google.protobuf.FieldOptions {
44 optional MemberAnnotation member = 7400;
45}