5. Using the generated API in applications

The DDS API implementation will allow the use of GPB types for DDS transparently, and the generated underlying DDS type will be invisible to the application.

5.1. Protobuf data model

For the comming example the following proto file is used:

import "omg/dds/descriptor.proto";

package address;

message Organisation {
    required string name = 1 [(.omg.dds.member).key = true];
    required string address = 2 [(.omg.dds.member).filterable = true];
    optional Person.PhoneNumber phone = 3;
}

message Person {
  option (.omg.dds.type) = {name: "dds.Person"};
  required string name = 1 [(.omg.dds.member).key = true]; 
  required int32 age = 2 [(.omg.dds.member) = {filterable: true}];
  optional string email = 3;
  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    required string number = 1;
    optional PhoneType type = 2 [default = HOME];
  }
  repeated PhoneNumber phone = 4;
  required Organisation worksFor = 5;
}

5.2. Java

java

In this example we will publish a person Jane Doe with one friend, John Doe.

The Subscriber example will read this data and print it to the stdout. This example is delivered with OpenSplice, and is located in examples/protobuf/java5.

5.2.1. Publisher

java

Example Publisher for the generated Person data:

5.2.2. Subscriber

java

Example Subscriber for the generated Person data:

5.3. ISO-C++

cpp

In this example the publisher and subscriber are embedded into one file.

The publisher part will publish a person Jane Doe with one friend, John Doe.

The Subscriber part in this example will read this data and print it to the stdout.

This example is delivered with Vortex OpenSplice, and is located in examples/protobuf/isocpp2.