Working with data writers.
More...
Working with data writers.
Setting up a data writer
- Create a data writer, FooDataWriter, of user data type
Foo:
DataWriterQos writer_qos = new DataWriterQos();
MyWriterListener writer_listener = new MyWriterListener();
publisher.get_default_datawriter_qos(writer_qos);
FooDataWriter writer = null;
try {
writer = (FooDataWriter) publisher.create_datawriter(topic, writer_qos,
writer_listener,
StatusKind.STATUS_MASK_ALL);
} catch (RETCODE_ERROR err) {
}
Managing instances
- Getting an instance "key" value of user data type
Foo
Foo data = ...;
try {
writer.get_key_value(data, instance_handle);
} catch (RETCODE_ERROR err) {
}
- Registering an instance of type
Foo
InstanceHandle_t instance_handle = InstanceHandle_t.HANDLE_NIL;
instance_handle = writer->register_instance(data);
- Unregistering an instance of type
Foo
try {
writer.unregister_instance(data, instance_handle);
} catch (RETCODE_ERROR err) {
}
- Disposing of an instance of type
Foo
try {
writer.dispose(data, instance_handle);
} catch (RETCODE_ERROR err) {
}
Sending data
- Write instance of type
Foo
Foo data = new Foo();
InstanceHandle_t instance_handle
= InstanceHandle_t.HANDLE_NIL;
try {
writer.write(data, instance_handle);
} catch (RETCODE_ERR err) {
}
Tearing down a data writer
- Delete DataWriter:
try {
publisher.delete_datawriter(writer);
} catch (RETCODE_ERR err) {
}