Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ze_querying_subscriber_get method #200

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ Functions

.. autocfunction:: zenoh_commons.h::ze_declare_querying_subscriber
.. autocfunction:: zenoh_commons.h::ze_undeclare_querying_subscriber
.. autocfunction:: zenoh_commons.h::ze_querying_subscriber_get
.. autocfunction:: zenoh_commons.h::ze_querying_subscriber_check
.. autocfunction:: zenoh_commons.h::ze_querying_subscriber_null
.. autocfunction:: zenoh_commons.h::ze_querying_subscriber_options_default
16 changes: 16 additions & 0 deletions include/zenoh_commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,9 @@ typedef struct ze_querying_subscriber_options_t {
enum zcu_reply_keyexpr_t query_accept_replies;
uint64_t query_timeout_ms;
} ze_querying_subscriber_options_t;
typedef struct ze_querying_subscriber_t {
const struct ze_owned_querying_subscriber_t *_0;
} ze_querying_subscriber_t;
ZENOHC_API extern const unsigned int Z_ROUTER;
ZENOHC_API extern const unsigned int Z_PEER;
ZENOHC_API extern const unsigned int Z_CLIENT;
Expand Down Expand Up @@ -2091,6 +2094,19 @@ ZENOHC_API struct ze_publication_cache_options_t ze_publication_cache_options_de
* Returns ``true`` if `sub` is valid.
*/
ZENOHC_API bool ze_querying_subscriber_check(const struct ze_owned_querying_subscriber_t *sub);
/**
* Make a :c:type:`ze_owned_querying_subscriber_t` to perform an additional query on a specified selector.
* The queried samples will be merged with the received publications and made available in the subscriber callback.
*/
ZENOHC_API
JEnoch marked this conversation as resolved.
Show resolved Hide resolved
int8_t ze_querying_subscriber_get(struct ze_querying_subscriber_t sub,
struct z_keyexpr_t selector,
const struct z_get_options_t *options);
/**
* Returns a :c:type:`ze_querying_subscriber_loan` loaned from `p`.
*/
ZENOHC_API
struct ze_querying_subscriber_t ze_querying_subscriber_loan(const struct ze_owned_querying_subscriber_t *p);
/**
* Constructs a null safe-to-drop value of 'ze_owned_querying_subscriber_t' type
*/
Expand Down
21 changes: 12 additions & 9 deletions include/zenoh_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

// clang-format off
#define z_loan(x) \
_Generic((x), z_owned_session_t : z_session_loan, \
z_owned_keyexpr_t : z_keyexpr_loan, \
z_owned_config_t : z_config_loan, \
z_owned_publisher_t : z_publisher_loan, \
z_owned_subscriber_t : z_subscriber_loan, \
z_owned_pull_subscriber_t : z_pull_subscriber_loan, \
z_owned_encoding_t : z_encoding_loan, \
z_owned_hello_t : z_hello_loan, \
z_owned_str_t : z_str_loan \
_Generic((x), z_owned_session_t : z_session_loan, \
z_owned_keyexpr_t : z_keyexpr_loan, \
z_owned_config_t : z_config_loan, \
z_owned_publisher_t : z_publisher_loan, \
z_owned_subscriber_t : z_subscriber_loan, \
z_owned_pull_subscriber_t : z_pull_subscriber_loan, \
z_owned_encoding_t : z_encoding_loan, \
z_owned_hello_t : z_hello_loan, \
z_owned_str_t : z_str_loan, \
ze_owned_querying_subscriber_t : ze_querying_subscriber_loan \
)(&x)

#define z_drop(x) \
Expand Down Expand Up @@ -123,6 +124,7 @@ template<> struct zenoh_loan_type<z_owned_pull_subscriber_t>{ typedef z_pull_sub
template<> struct zenoh_loan_type<z_owned_encoding_t>{ typedef z_encoding_t type; };
template<> struct zenoh_loan_type<z_owned_hello_t>{ typedef z_hello_t type; };
template<> struct zenoh_loan_type<z_owned_str_t>{ typedef const char* type; };
template<> struct zenoh_loan_type<ze_owned_querying_subscriber_t>{ typedef ze_querying_subscriber_t type; };

template<> inline z_session_t z_loan(const z_owned_session_t& x) { return z_session_loan(&x); }
template<> inline z_keyexpr_t z_loan(const z_owned_keyexpr_t& x) { return z_keyexpr_loan(&x); }
Expand All @@ -133,6 +135,7 @@ template<> inline z_pull_subscriber_t z_loan(const z_owned_pull_subscriber_t& x)
template<> inline z_encoding_t z_loan(const z_owned_encoding_t& x) { return z_encoding_loan(&x); }
template<> inline z_hello_t z_loan(const z_owned_hello_t& x) { return z_hello_loan(&x); }
template<> inline const char* z_loan(const z_owned_str_t& x) { return z_str_loan(&x); }
template<> inline ze_querying_subscriber_t z_loan(const ze_owned_querying_subscriber_t& x) { return ze_querying_subscriber_loan(&x); }

template<class T> struct zenoh_drop_type { typedef T type; };
template<class T> inline typename zenoh_drop_type<T>::type z_drop(T*);
Expand Down
Loading
Loading