DataWritersΒΆ
DataWriters write data to a topic using a publisher, and take as a template parameter the data type being exchanged. The settings for the writer are either inherited from the publisher, or explicitly set in its own Qos policies and listener.
Inherited from the publisher:
dds_entity_t writer = dds_create_writer (publisher, topic, NULL, NULL);
dds::pub::DataWriter<DataType> writer(pub, topic);
writer = DataWriter(publisher, topic)
Explicitly set in its own QoS policies and listener:
dds_qos_t *qos = dds_create_qos ();
dds_listener_t *listener = dds_create_listener(NULL);
dds_lset_publication_matched(listener, publication_matched);
dds_entity_t writer = dds_create_writer (participant, topic, qos, listener);
dds::pub::NoOpAnyDataWriterListener listener; /*you need to create your own class that derives from this listener, and implement your own callback functions*/
/*the listener implementation should implement the on_publication_matched virtual function as we will rely on it later*/
dds::pub::qos::DataWriterQos wqos;
dds::pub::DataWriter<DataType> writer(pub, topic, wqos, &listener, dds::core::status::StatusMask::publication_matched());
Python code sample TBD
A writer can write a sample:
DataType sample;
dds_write (writer, &sample);
DataType sample;
writer.write(sample);
writer.write(sample)
A sample with a specific timestamp:
DataType sample;
dds_write_ts(writer, &sample, dds_time());
DataType sample;
dds::core::Time timestamp(123 /*seconds*/, 456 /*nanoseconds*/);
writer.write(sample, timestamp);
Python code sample TBD
A range of samples:
C code sample TBD
std::vector<DataType> samples;
writer.write(samples.begin(), samples.end());
Python code sample TBD