What is the best method to poll a reader for the latest sample of a given instance?
I can think of a several ways to do it, but I'm not sure which is 'best':
1) Call plain read, manually compare key fields for each sample, starting from the end of the sequence.
2) Call read_w_condition with a query condition that compares the key fields. Is this any different than 1?
3) Call read_instance. This requires additional logic to lookup_instance on each poll iteration untill lookup_instance returns non-nil. The polling will occur before publisher have come online.
Constraints:
1) No content filter is used, this reader is used to read for more than this one instance.
2) It should return the most recent valid_data sample from the reader's cache, even if the instance has since become not-alive.
3) Reader history depth is set to KeepLast(1). I only ever care about the latest value for this application.
4) I don't need low-latency or to react to every published sample. The additional complexity of listeners or waitsets is not required.
@seymour33: Have you gotten this question resolved? I'm also looking fo a solution to the same question.
This: https://community.rti.com/static/documentation/connext-dds/5.2.3/doc/api/connext_dds/api_cpp2/classdds_1_1sub_1_1DataReader_1_1Selector.html#a68edc8af79f33deaf685e9423fe5fb41
Iterate with this: https://community.rti.com/static/documentation/connext-dds/5.2.3/doc/api/connext_dds/api_cpp2/classdds_1_1sub_1_1LoanedSamples.html#a5417c8de7de7098e10ead01915b1b0cf