Skip to content

Commit

Permalink
add-missing-subscriber-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Dec 19, 2024
1 parent aa9b20d commit 82e37e2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
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

0 comments on commit 82e37e2

Please sign in to comment.