if (DDS_Entity_enable((DDS_Entity*)entity) != DDS_RETCODE_OK) { printf("***Error: failed to enable entity\n"); }
DDS_StatusMask status_changes_mask; status_changes_mask = DDS_Entity_get_status_changes(entity);
status_kind
was changed since the last time it was cleared. A plain communication status change is cleared when the status is read using the entity's get_<plain communication status>()
method. A read communication status change is cleared when the data is taken from the middleware via a TDataReader_take() call [see Changes in Status for details]. if (status_changes_mask & status_kind) { return 1; /* ... YES, status_kind changed ... */ } else { return 0; /* ... NO, status_kind did NOT change ... */ }
if (DDS_DomainParticipant_get_qos(entity, &qos) != DDS_RETCODE_OK) { printf("***Error: failed to get qos\n"); }
/* Change the desired qos policies */ /* qos.policy.field = ... */
switch (DDS_DomainParticipant_set_qos(entity, &qos)) { case DDS_RETCODE_OK: { /* success */ } break; case DDS_RETCODE_IMMUTABLE_POLICY: { printf("***Error: tried changing a policy that can only be" " set at entity creation time\n"); } break; case DDS_RETCODE_INCONSISTENT_POLICY: { printf("***Error: tried changing a policy to a value inconsistent" " with other policy settings\n"); } break; default: { printf("***Error: some other failure\n"); } } DDS_DomainParticipantQos_finalize(&qos);
Once an entity has been created, its listener and/or the statuses for which it is enabled can be manipulated as follows.
/* ... methods defined by EntityListener ... */ MyEntityListener_LivelinessChanged( /* one example method */ void* listener_data, DDS_Entity* entity, const struct DDS_LivelinessChangedStatus *status);
/* ... set the listener struct to the previously defined functions ... one example is shown */ entity_listener.on_liveliness_changed = MyEntityListener_LivelinessChanged;
entity_listener = DDS_Entity_get_listener(entity);
status_kind
for the listener
enabled_status_list |= status_kind;
status_kind
for the listener
enabled_status_list &= ~status_kind;
entity_listener
using set_listener (abstract). Only enable the listener for the statuses specified by the enabled_status_list
. if (DDS_Entity_set_listener(entity, &entity_listener, enabled_status_list) != DDS_RETCODE_OK) { printf("***Error: setting entity listener\n"); }
Once an entity has been created, the list of statuses for which the DDS_StatusCondition is triggered can be manipulated as follows.
entity
, a status_kind
, and the associated status_condition:
statuscondition = DDS_Entity_get_statuscondition(entity);
status_condition
enabled_status_list = DDS_StatusCondition_get_enabled_statuses(statuscondition);
status_kind
is enabled for the status_condition
if (enabled_status_list & status_kind) { /*... YES, status_kind is enabled ... */ } else { /* ... NO, status_kind is NOT enabled ... */ }
status_kind
for the status_condition
if (DDS_StatusCondition_set_enabled_statuses(status_condition, enabled_status_list | status_kind) != DDS_RETCODE_OK) { /* ... check for cause of failure */ }
status_kind
for the status_condition
if (DDS_StatusCondition_set_enabled_statuses(status_condition, enabled_status_list & ~status_kind) != DDS_RETCODE_OK) { /* ... check for cause of failure */ }