You are here: Part 2: Core Concepts > Sending Data > Preview: Steps to Sending Data

Preview: Steps to Sending Data

To send DDS samples of a data instance:

  1. Create and configure the required Entities:
    1. Create a DomainParticipant (see Creating a DomainParticipant).
    2. Register user data types1Type registration is not required for built-in types (see Registering Built-in Types). with the DomainParticipant. For example, the ‘FooDataType’. (This step is not necessary in the Modern C++ API--the Topic instantiation automatically registers the type)
    3. Use the DomainParticipant to create a Topic with the registered data type.
    4. Optionally2You are not required to explicitly create a Publisher; instead, you can use the 'implicit Publisher' created from the DomainParticipant. See Creating Publishers Explicitly vs. Implicitly. , use the DomainParticipant to create a Publisher.
    5. Use the Publisher or DomainParticipant to create a DataWriter for the Topic.
    6. Use a type-safe method to cast the generic DataWriter created by the Publisher to a type-specific DataWriter. For example, ‘FooDataWriter’. (This step doesn't apply to the Modern C++ API where you directly instantiate a type-safe ‘DataWriter<Foo>.')
    7. Optionally, register data instances with the DataWriter. If the Topic’s user data type contain key fields, then registering a data instance (data with a specific key value) will improve performance when repeatedly sending data with the same key. You may register many different data instances; each registration will return an instance handle corresponding to the specific key value. For non-keyed data types, instance registration has no effect. See DDS Samples, Instances, and Keys for more information on keyed data types and instances.
  2. Every time there is changed data to be published:
    1. Store the data in a variable of the correct data type (for instance, variable ‘Foo’ of the type ‘FooDataType’).
    2. Call the FooDataWriter’s write() operation, passing it a reference to the variable ‘Foo’.
      • For non-keyed data types or for non-registered instances, also pass in DDS_HANDLE_NIL.
      • For keyed data types, pass in the instance handle corresponding to the instance stored in ‘Foo’, if you have registered the instance previously. This means that the data stored in ‘Foo’ has the same key value that was used to create instance handle.
    3. The write() function will take a snapshot of the contents of ‘Foo’ and store it in Connext DDS internal buffers from where the DDS data sample is sent under the criteria set by the Publisher’s and DataWriter’s QosPolicies. If there are matched DataReaders, then the DDS data sample will have been passed to the physical transport plug-in/device driver by the time that write() returns.

© 2016 RTI