6. Working with Instances

Instances are a way for an application to represent unique objects within a Topic, by specifying one or more key fields that form a unique identifier for the instance. Examples include identifying unique commercial flights within a “Flight Status” Topic or a unique sensor measuring the temperature in a “Temperature” Topic.

Modeling data using instances can provide several benefits to a system, including:

Instances are defined by key fields that make up a unique identifier of the object being represented. Key fields are similar to primary keys in a database—each unique combination of key field values represents a unique instance. Key fields are specified using the @key directive, as shown in 2.4 DDS Samples, Instances, and Keys.

Table 6.1 Example Keys and Instances

Instance
(object represented in data)

Key
(field/s uniquely identifying object)

Data type

Sample
(update to object)

Commercial flight being tracked

Airline name and flight number, such as:

Airline: "United Airlines"

Flight number: 901

string airline
short flight_num
float lat
float long

UA, 901, 37.7749, 122.4194

UA, 901, 37.7748, 122.4195

Sensor that is sending data, such as an individual temperature sensor

Unique identifier of that sensor, such as:

"Floor-08-South"

string sensor_id
long temperature

Floor-08-South, 78

Floor-08-South, 79

Car being monitored

Vehicle identification number (VIN) of the car

string VIN
float lat
float long

JH4DA9370MS016526, 37.7749, 122.4194

JH4DA9370MS016526, 37.7748, 122.4195

See the following sections:

See also more details on instances from the DataWriter and DataReader perspectives:

© 2020 RTI