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 missing subscriber methods #340

Merged
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
14 changes: 14 additions & 0 deletions include/zenoh/api/ext/advanced_subscriber.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "../interop.hxx"
#include "../keyexpr.hxx"
#include "../sample.hxx"
#include "../source_info.hxx"
#include "miss.hxx"

namespace zenoh::ext {
Expand Down Expand Up @@ -183,6 +184,19 @@ class AdvancedSubscriberBase : public Owned<::ze_owned_advanced_subscriber_t> {
return zenoh::Subscriber<typename Channel::template HandlerType<zenoh::Sample>>(
std::move(s), std::move(cb_handler_pair.second));
}

/// @brief Get the key expression of the advanced subscriber.
const KeyExpr& get_keyexpr() const {
return zenoh::interop::as_owned_cpp_ref<zenoh::KeyExpr>(
::ze_advanced_subscriber_keyexpr(zenoh::interop::as_loaned_c_ptr(*this)));
}

/// @brief Get the id of the advanced subscriber.
/// @return id of this advanced subscriber.
EntityGlobalId get_id() const {
return zenoh::interop::into_copyable_cpp_obj<zenoh::EntityGlobalId>(
::ze_advanced_subscriber_id(zenoh::interop::as_loaned_c_ptr(*this)));
}
};
} // namespace detail

Expand Down
15 changes: 14 additions & 1 deletion include/zenoh/api/subscriber.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "base.hxx"
#include "interop.hxx"
#include "keyexpr.hxx"
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
#include "source_info.hxx"
#endif

namespace zenoh {

Expand All @@ -31,10 +34,20 @@ class SubscriberBase : public Owned<::z_owned_subscriber_t> {
SubscriberBase(::z_owned_subscriber_t* s) : Owned(s){};

public:
/// @brief Get the key expression of the subscriber
/// @brief Get the key expression of the subscriber.
const KeyExpr& get_keyexpr() const {
return interop::as_owned_cpp_ref<KeyExpr>(::z_subscriber_keyexpr(interop::as_loaned_c_ptr(*this)));
}

#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
/// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future
/// release.
/// @brief Get the id of the subscriber.
/// @return id of this subscriber.
EntityGlobalId get_id() const {
return interop::into_copyable_cpp_obj<EntityGlobalId>(::z_subscriber_id(interop::as_loaned_c_ptr(*this)));
}
#endif
};

} // namespace detail
Expand Down
2 changes: 1 addition & 1 deletion zenoh-c
Loading