Skip to content

Commit

Permalink
Add .get_sequencenumber function to ddsi_serdata_ops interface, so th…
Browse files Browse the repository at this point in the history
…at the sequence number can be retrieved from serdata

Signed-off-by: TheFixer <[email protected]>
  • Loading branch information
TheFixer committed Jan 23, 2023
1 parent 436313c commit 566c5f7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/core/ddsc/src/dds_serdata_builtintopic.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_builtintopic = {
.to_untyped = serdata_builtin_to_untyped,
.untyped_to_sample = serdata_builtin_untyped_to_sample,
.print = serdata_builtin_type_print,
.get_keyhash = 0
.get_keyhash = 0,
.get_sequencenumber = 0
};

#ifdef DDS_HAS_TOPIC_DISCOVERY
Expand Down Expand Up @@ -497,7 +498,8 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_builtintopic_topic = {
.to_untyped = serdata_builtin_to_untyped,
.untyped_to_sample = serdata_builtin_untyped_to_sample,
.print = serdata_builtin_type_print,
.get_keyhash = 0
.get_keyhash = 0,
.get_sequencenumber = 0
};

#endif /* DDS_HAS_TOPIC_DISCOVERY */
18 changes: 14 additions & 4 deletions src/core/ddsc/src/dds_serdata_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ static uint32_t serdata_default_get_size(const struct ddsi_serdata *dcmn)
return d->pos + (uint32_t)sizeof (struct dds_cdr_header);
}

static uint64_t serdata_default_get_sequencenumber(const struct ddsi_serdata *dcmn)
{
const struct dds_serdata_default *d = (const struct dds_serdata_default *) dcmn;
return d->c.sequence_number;
}

static bool serdata_default_eqkey(const struct ddsi_serdata *acmn, const struct ddsi_serdata *bcmn)
{
const struct dds_serdata_default *a = (const struct dds_serdata_default *)acmn;
Expand Down Expand Up @@ -834,7 +840,8 @@ const struct ddsi_serdata_ops dds_serdata_ops_cdr = {
.to_untyped = serdata_default_to_untyped,
.untyped_to_sample = serdata_default_untyped_to_sample_cdr,
.print = serdata_default_print_cdr,
.get_keyhash = serdata_default_get_keyhash
.get_keyhash = serdata_default_get_keyhash,
.get_sequencenumber = serdata_default_get_sequencenumber
#ifdef DDS_HAS_SHM
, .get_sample_size = ddsi_serdata_iox_size
, .from_iox_buffer = serdata_default_from_iox
Expand All @@ -856,7 +863,8 @@ const struct ddsi_serdata_ops dds_serdata_ops_xcdr2 = {
.to_untyped = serdata_default_to_untyped,
.untyped_to_sample = serdata_default_untyped_to_sample_cdr,
.print = serdata_default_print_cdr,
.get_keyhash = serdata_default_get_keyhash
.get_keyhash = serdata_default_get_keyhash,
.get_sequencenumber = serdata_default_get_sequencenumber
#ifdef DDS_HAS_SHM
, .get_sample_size = ddsi_serdata_iox_size
, .from_iox_buffer = serdata_default_from_iox
Expand All @@ -878,7 +886,8 @@ const struct ddsi_serdata_ops dds_serdata_ops_cdr_nokey = {
.to_untyped = serdata_default_to_untyped,
.untyped_to_sample = serdata_default_untyped_to_sample_cdr_nokey,
.print = serdata_default_print_cdr,
.get_keyhash = serdata_default_get_keyhash
.get_keyhash = serdata_default_get_keyhash,
.get_sequencenumber = serdata_default_get_sequencenumber
#ifdef DDS_HAS_SHM
, .get_sample_size = ddsi_serdata_iox_size
, .from_iox_buffer = serdata_default_from_iox
Expand All @@ -900,7 +909,8 @@ const struct ddsi_serdata_ops dds_serdata_ops_xcdr2_nokey = {
.to_untyped = serdata_default_to_untyped,
.untyped_to_sample = serdata_default_untyped_to_sample_cdr_nokey,
.print = serdata_default_print_cdr,
.get_keyhash = serdata_default_get_keyhash
.get_keyhash = serdata_default_get_keyhash,
.get_sequencenumber = serdata_default_get_sequencenumber
#ifdef DDS_HAS_SHM
, .get_sample_size = ddsi_serdata_iox_size
, .from_iox_buffer = serdata_default_from_iox
Expand Down
3 changes: 2 additions & 1 deletion src/core/ddsc/tests/cdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ static const struct ddsi_serdata_ops sd_ops = {
.to_untyped = sd_to_untyped,
.untyped_to_sample = sd_untyped_to_sample,
.print = sd_print,
.get_keyhash = sd_get_keyhash
.get_keyhash = sd_get_keyhash,
.get_sequencenumber = 0
};

/*----------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/core/ddsi/include/dds/ddsi/ddsi_serdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ typedef size_t (*ddsi_serdata_print_t) (const struct ddsi_sertype *type, const s
- buf needs to be at least 16 bytes large */
typedef void (*ddsi_serdata_get_keyhash_t) (const struct ddsi_serdata *d, struct ddsi_keyhash *buf, bool force_md5);

/* Sequence number of the sample as advertised by the publisher */
typedef uint64_t (*ddsi_serdata_get_sequencenumber_t) (const struct ddsi_serdata *d);

#ifdef DDS_HAS_SHM
typedef uint32_t(*ddsi_serdata_iox_size_t) (const struct ddsi_serdata* d);

Expand Down Expand Up @@ -176,6 +179,7 @@ struct ddsi_serdata_ops {
ddsi_serdata_free_t free;
ddsi_serdata_print_t print;
ddsi_serdata_get_keyhash_t get_keyhash;
ddsi_serdata_get_sequencenumber_t get_sequencenumber;
#ifdef DDS_HAS_SHM
ddsi_serdata_iox_size_t get_sample_size;
ddsi_serdata_from_iox_t from_iox_buffer;
Expand Down Expand Up @@ -235,6 +239,10 @@ DDS_INLINE_EXPORT inline uint32_t ddsi_serdata_size (const struct ddsi_serdata *
return d->ops->get_size (d);
}

DDS_INLINE_EXPORT inline uint64_t ddsi_serdata_sequencenumber(const struct ddsi_serdata *d) {
return d->ops->get_sequencenumber (d);
}

DDS_INLINE_EXPORT inline struct ddsi_serdata *ddsi_serdata_from_ser (const struct ddsi_sertype *type, enum ddsi_serdata_kind kind, const struct ddsi_rdata *fragchain, size_t size) {
return type->serdata_ops->from_ser (type, kind, fragchain, size);
}
Expand Down
5 changes: 3 additions & 2 deletions src/core/ddsi/src/ddsi_serdata_cdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_cdr = {
.untyped_to_sample = serdata_cdr_untyped_to_sample_cdr,
.print = serdata_cdr_print_cdr,
.get_keyhash = 0,
.get_sequencenumber = 0
#ifdef DDS_HAS_SHM
.get_sample_size = 0,
.from_iox_buffer = 0
, .get_sample_size = 0
, .from_iox_buffer = 0
#endif
};
3 changes: 2 additions & 1 deletion src/core/ddsi/src/ddsi_serdata_plist.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,5 +325,6 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_plist = {
.to_untyped = serdata_plist_to_untyped,
.untyped_to_sample = serdata_plist_untyped_to_sample,
.print = serdata_plist_print_plist,
.get_keyhash = serdata_plist_get_keyhash
.get_keyhash = serdata_plist_get_keyhash,
.get_sequencenumber = 0
};
3 changes: 2 additions & 1 deletion src/core/ddsi/src/ddsi_serdata_pserop.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,5 +304,6 @@ const struct ddsi_serdata_ops ddsi_serdata_ops_pserop = {
.to_untyped = serdata_pserop_to_untyped,
.untyped_to_sample = serdata_pserop_untyped_to_sample,
.print = serdata_pserop_print_pserop,
.get_keyhash = serdata_pserop_get_keyhash
.get_keyhash = serdata_pserop_get_keyhash,
.get_sequencenumber = 0
};

0 comments on commit 566c5f7

Please sign in to comment.