Foo:
struct DDS_DataWriterQos writer_qos = DDS_DataWriterQos_INITIALIZER; DDS_DataWriter* writer; struct DDS_DataWriterListener writer_listener = DDS_DataWriterListener_INITIALIZER; /* MyWriterListener_* functions are user defined to match DDS_DataWriterListener functions */ writer_listener.on_offered_deadline_missed = MyWriterListener_OfferedDeadlineMissed; writer_listener.on_offered_incompatible_qos = MyWriterListener_OfferedIncompatibleQos; writer_listener.on_liveliness_lost = MyWriterListener_LivelinessLost; writer_listener.on_publication_match = MyWriterListener_PublicationMatch; retcode = DDS_Publisher_get_default_datawriter_qos(publisher, &writer_qos); if (retcode != DDS_RETCODE_OK) { printf("***Error: failed to get default datawriter qos\n"); } writer = DDS_Publisher_create_datawriter(publisher, topic, &writer_qos, &writer_listener /* or NULL */, DDS_STATUS_MASK_ALL); if (writer == NULL) { printf("***Error: failed to create writer\n"); }
Foo
struct Foo* data = ...; /* user data */ retcode = FooDataWriter_get_key_value(writer, data, &instance_handle); if (retcode != DDS_RETCODE_OK) { /* ... check for cause of failure */ }
Foo
DDS_InstanceHandle_t instance_handle = DDS_HANDLE_NIL; instance_handle = FooDataWriter_register_instance(writer, data);
Foo
retcode = FooDataWriter_unregister_instance(writer, data, &instance_handle); if (retcode != DDS_RETCODE_OK) { /* ... check for cause of failure */ }
Foo
retcode = FooDataWriter_dispose(writer, data, &instance_handle); if (retcode != DDS_RETCODE_OK) { /* ... check for cause of failure */ }
Foo
struct Foo* data = ...; /* user data */ DDS_InstanceHandle_t instance_handle = DDS_HANDLE_NIL; /* or a valid registered handle */ DDS_ReturnCode_t retcode; retcode = FooDataWriter_write(writer, data, &instance_handle); if (retcode != DDS_RETCODE_OK) { /* ... check for cause of failure */ }
DDS_ReturnCode_t retcode; retcode = DDS_Publisher_delete_datawriter(publisher, writer); if (retcode != DDS_RETCODE_OK) { printf("***Error: failed to delete writer\n"); }