This is an old revision of the document!
DataWriter objects are responsible for sending type-specific data to one or more DataReaders.
A DataWriter is created with a Topic, which gives a name to the data stream and associates the DataWriter with a data type. A DataWriter sends data to one or more DataReaders if the DataWriter and DataReader(s):
The behavior of a DataWriter is controlled by QoS. For example, a DataWriter can be made reliable by configuring its RELIABILITY QoS. A DataWriter provides asynchronous notifications in the form of Status Changes.
There are two types of objects that can be referred to as DataWriters: DDS DataWriter objects and type-specific DataWriter objects (usually called FooDataWriter to indicate a user data type “Foo”).
The DDS::DataWriter object is used for actions that are not specific to a single data type, such as configuring QoS or installing listeners. The type-specific FooDataWriter object is used for actions that involve the specific data type, such as writing data or unregistering/disposing of an instance.
For example, when writing data, you must use a type-specific DataWriter, rather than the generic DataWriter class:
Example of using a DDS DataWriter
// Create the DDS::DataWriter. This object can be used for configuring QoS,
// asserting liveliness, or other non-type specific actions.
DDS::DataWriter *ddsWriter
= publisher->create_datawriter
( medicalDataTopic,
qos,
listener,
DDS_STATUS_MASK_ALL
);
// Create the type-specific DataWriter. This object can be used for writing data,
// disposing a data-instance, or other actions that are specific to a data type
MedicalDeviceDataWriter *medicalDataWriter
= MedicalDeviceDataWriter::narrow(ddsWriter);
medicalDataWriter->write(deviceData, ...);