Working with entities.
Working with entities.
Enabling an entity
- To enable an DDS_Entity
printf("***Error: failed to enable entity\n");
}
DDS_ReturnCode_t DDS_Entity_enable(DDS_Entity *self)
Enables the DDS_Entity.
struct DDS_EntityImpl DDS_Entity
<<interface>> Abstract base class for all the DDS objects that support QoS policies,...
Definition: infrastructure.ifc:8219
@ DDS_RETCODE_OK
Successful return.
Definition: infrastructure.ifc:1355
Checking if a status changed on an entity.
- Given an DDS_Entity and a DDS_StatusKind to check for, get the list of statuses that have changed since the last time they were respectively cleared.
DDS_StatusMask DDS_Entity_get_status_changes(DDS_Entity *self)
Retrieves the list of communication statuses in the DDS_Entity that are triggered.
DDS_UnsignedLong DDS_StatusMask
A bit-mask (list) of concrete status types, i.e. DDS_StatusKind[].
Definition: infrastructure.ifc:1419
- Check if
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;
} else {
return 0;
}
Changing the QoS for an entity
The QoS for an entity can be specified at the entity creation time. Once an entity has been created, its QoS can be manipulated as follows.
- Get an entity's QoS settings using get_qos (abstract)
printf("***Error: failed to get qos\n");
}
DDS_ReturnCode_t DDS_DomainParticipant_get_qos(DDS_DomainParticipant *self, struct DDS_DomainParticipantQos *qos)
Get the participant QoS.
- Change the desired qos policy fields
- Set the qos using set_qos (abstract).
} break;
printf("***Error: tried changing a policy that can only be"
" set at entity creation time\n");
} break;
printf("***Error: tried changing a policy to a value inconsistent"
" with other policy settings\n");
} break;
default: {
printf("***Error: some other failure\n");
}
}
DDS_ReturnCode_t DDS_DomainParticipant_set_qos(DDS_DomainParticipant *self, const struct DDS_DomainParticipantQos *qos)
Change the QoS of this DomainParticipant.
DDS_ReturnCode_t DDS_DomainParticipantQos_finalize(struct DDS_DomainParticipantQos *self)
Free any dynamic memory allocated by the policies in this DDS_DomainParticipantQos.
@ DDS_RETCODE_INCONSISTENT_POLICY
Application specified a set of QoS policies that are not consistent with each other.
Definition: infrastructure.ifc:1387
@ DDS_RETCODE_IMMUTABLE_POLICY
Application attempted to modify an immutable QoS policy.
Definition: infrastructure.ifc:1383
Changing the listener and enabling/disabling statuses associated with it
The listener for an entity can be specified at the entity creation time. By default the listener is enabled for all the statuses supported by the entity.
Once an entity has been created, its listener and/or the statuses for which it is enabled can be manipulated as follows.
- User defines entity listener methods
MyEntityListener_LivelinessChanged(
void* listener_data,
DDS_LIVELINESS_CHANGED_STATUS
Definition: subscription.ifc:316
- Set the entity_listener functions
entity_listener.on_liveliness_changed = MyEntityListener_LivelinessChanged;
- Get an entity's listener using get_listener (abstract)
entity_listener = DDS_Entity_get_listener(entity);
- Enable
status_kind
for the listener
enabled_status_list |= status_kind;
- Disable
status_kind
for the listener
enabled_status_list &= ~status_kind;
- Set an entity's listener to
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)
printf("***Error: setting entity listener\n");
}
Enabling/Disabling statuses associated with a status condition
Upon entity creation, by default, all the statuses are enabled for the DDS_StatusCondition associated with the entity.
Once an entity has been created, the list of statuses for which the DDS_StatusCondition is triggered can be manipulated as follows.
- Given an
entity
, a status_kind
, and the associated status_condition:
DDS_StatusCondition * DDS_Entity_get_statuscondition(DDS_Entity *self)
Allows access to the DDS_StatusCondition associated with the DDS_Entity.
- Get the list of statuses enabled for the
status_condition
DDS_StatusMask DDS_StatusCondition_get_enabled_statuses(DDS_StatusCondition *self)
Get the list of statuses enabled on an DDS_Entity.
- Check if the given
status_kind
is enabled for the status_condition
if (enabled_status_list & status_kind) {
} else {
}
- Enable
status_kind
for the status_condition
enabled_status_list | status_kind)
}
DDS_ReturnCode_t DDS_StatusCondition_set_enabled_statuses(DDS_StatusCondition *self, DDS_StatusMask mask)
This operation defines the list of communication statuses that determine the trigger_value of the DDS...
- Disable
status_kind
for the status_condition
enabled_status_list & ~status_kind)
}