Make it possible to create reader with custom RHC
The default RHC implementation is not always ideal and rather than trying to squeeze everything in a fixed interface it makes more sense to allow the caller to provide an arbitrary implementation of the interface. This is not yet a stable interface. Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
57d20e07a4
commit
fbc05777f3
7 changed files with 75 additions and 14 deletions
|
@ -49,6 +49,7 @@ typedef int32_t dds_entity_t;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct dds_rhc;
|
||||
struct ddsi_serdata;
|
||||
|
||||
#define DDS_MIN_PSEUDO_HANDLE ((dds_entity_t) 0x7fff0000)
|
||||
|
@ -1195,6 +1196,34 @@ dds_create_reader(
|
|||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener);
|
||||
|
||||
/**
|
||||
* @brief Creates a new instance of a DDS reader with a custom history cache.
|
||||
*
|
||||
* This implicit subscriber will be deleted automatically when the created reader
|
||||
* is deleted.
|
||||
*
|
||||
* @param[in] participant_or_subscriber The participant or subscriber on which the reader is being created.
|
||||
* @param[in] topic The topic to read.
|
||||
* @param[in] qos The QoS to set on the new reader (can be NULL).
|
||||
* @param[in] listener Any listener functions associated with the new reader (can be NULL).
|
||||
* @param[in] rhc Reader history cache to use, reader becomes the owner
|
||||
*
|
||||
* @returns A valid reader handle or an error code.
|
||||
*
|
||||
* @retval >0
|
||||
* A valid reader handle.
|
||||
* @retval DDS_RETCODE_ERROR
|
||||
* An internal error occurred.
|
||||
*/
|
||||
/* TODO: Complete list of error codes */
|
||||
DDS_EXPORT dds_entity_t
|
||||
dds_create_reader_rhc(
|
||||
dds_entity_t participant_or_subscriber,
|
||||
dds_entity_t topic,
|
||||
const dds_qos_t *qos,
|
||||
const dds_listener_t *listener,
|
||||
struct dds_rhc *rhc);
|
||||
|
||||
/**
|
||||
* @brief Wait until reader receives all historic data
|
||||
*
|
||||
|
|
|
@ -23,7 +23,10 @@ extern "C" {
|
|||
|
||||
struct dds_rhc;
|
||||
struct dds_readcond;
|
||||
struct dds_reader;
|
||||
struct ddsi_tkmap;
|
||||
|
||||
typedef dds_return_t (*dds_rhc_associate_t) (struct dds_rhc *rhc, struct dds_reader *reader, const struct ddsi_sertopic *topic, struct ddsi_tkmap *tkmap);
|
||||
typedef int (*dds_rhc_read_t) (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond);
|
||||
typedef int (*dds_rhc_take_t) (struct dds_rhc *rhc, bool lock, void **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t mask, dds_instance_handle_t handle, struct dds_readcond *cond);
|
||||
typedef int (*dds_rhc_takecdr_t) (struct dds_rhc *rhc, bool lock, struct ddsi_serdata **values, dds_sample_info_t *info_seq, uint32_t max_samples, uint32_t sample_states, uint32_t view_states, uint32_t instance_states, dds_instance_handle_t handle);
|
||||
|
@ -43,6 +46,7 @@ struct dds_rhc_ops {
|
|||
dds_rhc_add_readcondition_t add_readcondition;
|
||||
dds_rhc_remove_readcondition_t remove_readcondition;
|
||||
dds_rhc_lock_samples_t lock_samples;
|
||||
dds_rhc_associate_t associate;
|
||||
};
|
||||
|
||||
struct dds_rhc {
|
||||
|
@ -54,11 +58,14 @@ struct dds_rhc {
|
|||
|
||||
DDSRT_STATIC_ASSERT (offsetof (struct dds_rhc, common.ops) == offsetof (struct ddsi_rhc, ops));
|
||||
|
||||
DDS_EXPORT inline bool dds_rhc_store (struct dds_rhc * __restrict rhc, const struct ddsi_writer_info * __restrict pwr_info, struct ddsi_serdata * __restrict sample, struct ddsi_tkmap_instance * __restrict tk) {
|
||||
return rhc->common.ops->rhc_ops.store (&rhc->common.rhc, pwr_info, sample, tk);
|
||||
DDS_EXPORT inline dds_return_t dds_rhc_associate (struct dds_rhc *rhc, struct dds_reader *reader, const struct ddsi_sertopic *topic, struct ddsi_tkmap *tkmap) {
|
||||
return rhc->common.ops->associate (rhc, reader, topic, tkmap);
|
||||
}
|
||||
DDS_EXPORT inline void dds_rhc_unregister_wr (struct dds_rhc * __restrict rhc, const struct ddsi_writer_info * __restrict pwr_info) {
|
||||
rhc->common.ops->rhc_ops.unregister_wr (&rhc->common.rhc, pwr_info);
|
||||
DDS_EXPORT inline bool dds_rhc_store (struct dds_rhc * __restrict rhc, const struct ddsi_writer_info * __restrict wrinfo, struct ddsi_serdata * __restrict sample, struct ddsi_tkmap_instance * __restrict tk) {
|
||||
return rhc->common.ops->rhc_ops.store (&rhc->common.rhc, wrinfo, sample, tk);
|
||||
}
|
||||
DDS_EXPORT inline void dds_rhc_unregister_wr (struct dds_rhc * __restrict rhc, const struct ddsi_writer_info * __restrict wrinfo) {
|
||||
rhc->common.ops->rhc_ops.unregister_wr (&rhc->common.rhc, wrinfo);
|
||||
}
|
||||
DDS_EXPORT inline void dds_rhc_relinquish_ownership (struct dds_rhc * __restrict rhc, const uint64_t wr_iid) {
|
||||
rhc->common.ops->rhc_ops.relinquish_ownership (&rhc->common.rhc, wr_iid);
|
||||
|
@ -88,6 +95,8 @@ DDS_EXPORT inline uint32_t dds_rhc_lock_samples (struct dds_rhc *rhc) {
|
|||
return rhc->common.ops->lock_samples (rhc);
|
||||
}
|
||||
|
||||
DDS_EXPORT void dds_reader_data_available_cb (struct dds_reader *rd);
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue