From 1ff37892e18c49cae3c068928f0aba2e6b674370 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Fri, 18 Oct 2024 10:25:05 +0200 Subject: [PATCH 1/2] support for zenoh-pico build granularity --- examples/CMakeLists.txt | 20 ++ examples/simple/universal/z_simple.cxx | 4 + examples/simple/zenohpico/zp_simple.cxx | 2 + include/zenoh/api.hxx | 5 +- include/zenoh/api/channels.hxx | 8 + include/zenoh/api/liveliness.hxx | 4 +- include/zenoh/api/publisher.hxx | 4 + include/zenoh/api/query.hxx | 5 +- include/zenoh/api/query_consolidation.hxx | 5 +- include/zenoh/api/queryable.hxx | 5 +- include/zenoh/api/reply.hxx | 5 +- include/zenoh/api/sample.hxx | 1 + include/zenoh/api/session.hxx | 250 +++++++++++---------- include/zenoh/api/source_info.hxx | 2 + include/zenoh/api/subscriber.hxx | 5 +- include/zenoh/detail/closures_concrete.hxx | 8 +- tests/CMakeLists.txt | 8 +- 17 files changed, 208 insertions(+), 133 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9f6b475b..df8a685b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -61,6 +61,26 @@ function(add_examples glob mode lib) continue() endif() endif() + if("${mode}" STREQUAL "zenohpico") + if (((${file} MATCHES "^.*pub.*$") OR (${file} MATCHES "^.*delete.*$") OR (${file} MATCHES "^.*put.*$") + OR (${file} MATCHES "^.*ping.*$") OR (${file} MATCHES "^.*pong.*$")) + AND NOT(ZENOHPICO_FEATURE_PUBLICATION) + ) + continue() + endif() + if (((${file} MATCHES "^.*sub.*$") OR (${file} MATCHES "^.*ping.*$") OR (${file} MATCHES "^.*pong.*$")) + AND NOT(ZENOHPICO_FEATURE_SUBSCRIPTION) + ) + continue() + endif() + if ((${file} MATCHES "^.*get.*$") AND NOT(ZENOHPICO_FEATURE_QUERY)) + continue() + endif() + if ((${file} MATCHES "^.*queryable.*$") AND NOT(ZENOHPICO_FEATURE_QUERYABLE)) + continue() + endif() + endif() + add_example(${file} ${mode} ${lib}) endforeach() endfunction() diff --git a/examples/simple/universal/z_simple.cxx b/examples/simple/universal/z_simple.cxx index d3004125..5f4aef52 100644 --- a/examples/simple/universal/z_simple.cxx +++ b/examples/simple/universal/z_simple.cxx @@ -23,5 +23,9 @@ int main(int, char **) { #endif Config config = Config::create_default(); auto session = Session::open(std::move(config)); +#if (ZENOHCXX_ZENOHC) || \ + Z_FEATURE_PUBLICATION == \ + 1 // check if zenoh-pico is compiled with publication support (always included for zenoh-c) session.put("demo/example/simple", "Simple!"); +#endif } diff --git a/examples/simple/zenohpico/zp_simple.cxx b/examples/simple/zenohpico/zp_simple.cxx index c3247978..09a128d1 100644 --- a/examples/simple/zenohpico/zp_simple.cxx +++ b/examples/simple/zenohpico/zp_simple.cxx @@ -19,5 +19,7 @@ using namespace zenoh; int main(int, char **) { Config config = Config::create_default(); auto session = Session::open(std::move(config)); +#if Z_FEATURE_PUBLICATION == 1 // check if zenoh-pico is compliled with publication support session.put("demo/example/simple", "Simple!"); +#endif } diff --git a/include/zenoh/api.hxx b/include/zenoh/api.hxx index f63f0307..94266bb5 100644 --- a/include/zenoh/api.hxx +++ b/include/zenoh/api.hxx @@ -14,16 +14,15 @@ #pragma once #include "api/bytes.hxx" +#include "api/channels.hxx" #include "api/closures.hxx" #include "api/config.hxx" #include "api/encoding.hxx" #include "api/enums.hxx" #include "api/hello.hxx" -#if defined Z_FEATURE_UNSTABLE_API #include "api/id.hxx" -#endif -#include "api/channels.hxx" #include "api/keyexpr.hxx" +#include "api/liveliness.hxx" #include "api/logging.hxx" #include "api/publisher.hxx" #include "api/query.hxx" diff --git a/include/zenoh/api/channels.hxx b/include/zenoh/api/channels.hxx index 5ee46202..364a755b 100644 --- a/include/zenoh/api/channels.hxx +++ b/include/zenoh/api/channels.hxx @@ -48,6 +48,7 @@ struct FifoHandlerData { } }; +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1 template <> struct FifoHandlerData { typedef ::z_owned_fifo_handler_query_t handler_type; @@ -56,7 +57,9 @@ struct FifoHandlerData { ::z_fifo_channel_query_new(cb, h, capacity); } }; +#endif +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1 template <> struct FifoHandlerData { typedef ::z_owned_fifo_handler_reply_t handler_type; @@ -65,6 +68,7 @@ struct FifoHandlerData { ::z_fifo_channel_reply_new(cb, h, capacity); } }; +#endif template struct RingHandlerData {}; @@ -78,6 +82,7 @@ struct RingHandlerData { } }; +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1 template <> struct RingHandlerData { typedef ::z_owned_ring_handler_query_t handler_type; @@ -86,7 +91,9 @@ struct RingHandlerData { ::z_ring_channel_query_new(cb, h, capacity); } }; +#endif +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1 template <> struct RingHandlerData { typedef ::z_owned_ring_handler_reply_t handler_type; @@ -95,6 +102,7 @@ struct RingHandlerData { ::z_ring_channel_reply_new(cb, h, capacity); } }; +#endif } // namespace detail class FifoChannel; diff --git a/include/zenoh/api/liveliness.hxx b/include/zenoh/api/liveliness.hxx index 04f6c1ee..c96e37f7 100644 --- a/include/zenoh/api/liveliness.hxx +++ b/include/zenoh/api/liveliness.hxx @@ -13,6 +13,7 @@ #pragma once +#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API) #include "base.hxx" #include "interop.hxx" @@ -43,4 +44,5 @@ class LivelinessToken : public Owned<::zc_owned_liveliness_token_t> { } }; -} // namespace zenoh \ No newline at end of file +} // namespace zenoh +#endif \ No newline at end of file diff --git a/include/zenoh/api/publisher.hxx b/include/zenoh/api/publisher.hxx index a56de249..1c78a0b4 100644 --- a/include/zenoh/api/publisher.hxx +++ b/include/zenoh/api/publisher.hxx @@ -13,6 +13,8 @@ #pragma once +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_PUBLICATION == 1 + #include "base.hxx" #include "bytes.hxx" #include "encoding.hxx" @@ -47,6 +49,7 @@ class Publisher : public Owned<::z_owned_publisher_t> { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future /// release. /// @brief The source info of this message. + /// @note Zenoh-c only. std::optional source_info = {}; #endif /// @brief The attachment to attach to the publication. @@ -125,3 +128,4 @@ class Publisher : public Owned<::z_owned_publisher_t> { #endif }; } // namespace zenoh +#endif \ No newline at end of file diff --git a/include/zenoh/api/query.hxx b/include/zenoh/api/query.hxx index 43efb7d7..ee900be0 100644 --- a/include/zenoh/api/query.hxx +++ b/include/zenoh/api/query.hxx @@ -13,6 +13,7 @@ #pragma once +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1 #include #include #include @@ -97,6 +98,7 @@ class Query : public Owned<::z_owned_query_t> { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future /// release. /// @brief The source info of this reply message. + /// @note Zenoh-c only. std::optional source_info = {}; #endif /// @brief An optional attachment to this reply message. @@ -221,4 +223,5 @@ class Query : public Owned<::z_owned_query_t> { }; }; -} // namespace zenoh \ No newline at end of file +} // namespace zenoh +#endif \ No newline at end of file diff --git a/include/zenoh/api/query_consolidation.hxx b/include/zenoh/api/query_consolidation.hxx index a8e054e5..5c4cc547 100644 --- a/include/zenoh/api/query_consolidation.hxx +++ b/include/zenoh/api/query_consolidation.hxx @@ -13,6 +13,8 @@ #pragma once +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1 + #include "base.hxx" #include "enums.hxx" #include "interop.hxx" @@ -48,4 +50,5 @@ class QueryConsolidation : public Copyable<::z_query_consolidation_t> { /// @return ``true`` if the two values are not equal (have different consolidation mode) bool operator!=(const QueryConsolidation& other) const { return !operator==(other); } }; -} // namespace zenoh \ No newline at end of file +} // namespace zenoh +#endif \ No newline at end of file diff --git a/include/zenoh/api/queryable.hxx b/include/zenoh/api/queryable.hxx index 30ca7466..8b2a91a1 100644 --- a/include/zenoh/api/queryable.hxx +++ b/include/zenoh/api/queryable.hxx @@ -13,6 +13,8 @@ #pragma once +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1 + #include #include "base.hxx" @@ -143,4 +145,5 @@ auto move_to_c_obj(Queryable&& q) { } } // namespace interop -} // namespace zenoh \ No newline at end of file +} // namespace zenoh +#endif \ No newline at end of file diff --git a/include/zenoh/api/reply.hxx b/include/zenoh/api/reply.hxx index 47e7ecc2..03b80915 100644 --- a/include/zenoh/api/reply.hxx +++ b/include/zenoh/api/reply.hxx @@ -13,6 +13,8 @@ #pragma once +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1 + #include "base.hxx" #include "bytes.hxx" #include "id.hxx" @@ -84,4 +86,5 @@ class Reply : public Owned<::z_owned_reply_t> { #endif }; -} // namespace zenoh \ No newline at end of file +} // namespace zenoh +#endif \ No newline at end of file diff --git a/include/zenoh/api/sample.hxx b/include/zenoh/api/sample.hxx index 62e58214..d4c554cf 100644 --- a/include/zenoh/api/sample.hxx +++ b/include/zenoh/api/sample.hxx @@ -94,6 +94,7 @@ class Sample : public Owned<::z_owned_sample_t> { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future /// release. /// @brief Get the source info of this sample. + /// @note Zenoh-c only. const SourceInfo& get_source_info() const { return interop::as_owned_cpp_ref(::z_sample_source_info(interop::as_loaned_c_ptr(*this))); } diff --git a/include/zenoh/api/session.hxx b/include/zenoh/api/session.hxx index 5160993d..13455d39 100644 --- a/include/zenoh/api/session.hxx +++ b/include/zenoh/api/session.hxx @@ -23,13 +23,11 @@ #include "enums.hxx" #include "id.hxx" #include "interop.hxx" +#include "liveliness.hxx" #include "publisher.hxx" #include "query_consolidation.hxx" #include "subscriber.hxx" #include "timestamp.hxx" -#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API) -#include "liveliness.hxx" -#endif #if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API) #include "shm/client_storage/client_storage.hxx" #endif @@ -160,7 +158,7 @@ class Session : public Owned<::z_owned_session_t> { __ZENOH_RESULT_CHECK(::z_undeclare_keyexpr(interop::as_loaned_c_ptr(*this), interop::as_moved_c_ptr(key_expr)), err, "Failed to undeclare key expression"); } - +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1 /// @brief Options passed to the ``get`` operation. struct GetOptions { /// @name Fields @@ -270,119 +268,8 @@ class Session : public Owned<::z_owned_session_t> { if (res != Z_OK) ::z_drop(interop::as_moved_c_ptr(cb_handler_pair.second)); return std::move(cb_handler_pair.second); } - /// @brief Options to be passed to ``delete_resource`` operation - struct DeleteOptions { - /// @name Fields - - /// @brief The priority of the delete message. - Priority priority = Z_PRIORITY_DEFAULT; - /// @brief The congestion control to apply when routing delete message. - CongestionControl congestion_control = Z_CONGESTION_CONTROL_DEFAULT; - /// @brief Whether Zenoh will NOT wait to batch delete message with others to reduce the bandwith. - bool is_express = false; -#if 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 The delete operation reliability. - Reliability reliability = Reliability::Z_RELIABILITY_BEST_EFFORT; #endif - /// @brief the timestamp of this message. - std::optional timestamp = {}; - - /// @name Methods - /// @brief Create default option settings. - static DeleteOptions create_default() { return {}; } - }; - - /// @brief Undeclare a resource. Equivalent to ``Publisher::delete_resource``. - /// @param key_expr the key expression to delete the resource. - /// @param options options to pass to delete operation. - /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be - /// thrown in case of error. - void delete_resource(const KeyExpr& key_expr, DeleteOptions&& options = DeleteOptions::create_default(), - ZResult* err = nullptr) const { - ::z_delete_options_t opts; - z_delete_options_default(&opts); - opts.congestion_control = options.congestion_control; - opts.priority = options.priority; - opts.is_express = options.is_express; -#if defined(Z_FEATURE_UNSTABLE_API) - opts.reliability = options.reliability; -#endif - - __ZENOH_RESULT_CHECK(::z_delete(interop::as_loaned_c_ptr(*this), interop::as_loaned_c_ptr(key_expr), &opts), - err, "Failed to perform delete operation"); - } - - /// @brief Options passed to the ``Session::put`` operation. - struct PutOptions { - /// @name Fields - - /// @brief The priority of this message. - Priority priority = Z_PRIORITY_DEFAULT; - /// @brief The congestion control to apply when routing this message. - CongestionControl congestion_control = Z_CONGESTION_CONTROL_DEFAULT; - /// @brief Whether Zenoh will NOT wait to batch this message with others to reduce the bandwith. - bool is_express = false; -#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 Allowed destination. - Locality allowed_destination = ::zc_locality_default(); -#endif - /// @brief the timestamp of this message. - std::optional timestamp = {}; - /// @brief An optional encoding of the message payload and/or attachment. - std::optional encoding = {}; -#if 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 The put operation reliability. - Reliability reliability = Reliability::Z_RELIABILITY_BEST_EFFORT; -#endif -#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 The source info of this message. - std::optional source_info = {}; -#endif - /// @brief An optional attachment to the message. - std::optional attachment = {}; - - /// @name Methods - /// @brief Create default option settings. - static PutOptions create_default() { return {}; } - }; - - /// @brief Publish data to the matching subscribers in the system. Equivalent to ``Publisher::put``. - /// @param key_expr the key expression to put the data. - /// @param payload the data to publish. - /// @param options options to pass to put operation. - /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be - /// thrown in case of error. - void put(const KeyExpr& key_expr, Bytes&& payload, PutOptions&& options = PutOptions::create_default(), - ZResult* err = nullptr) const { - ::z_put_options_t opts; - z_put_options_default(&opts); - opts.encoding = interop::as_moved_c_ptr(options.encoding); - opts.congestion_control = options.congestion_control; - opts.priority = options.priority; - opts.is_express = options.is_express; -#if defined(Z_FEATURE_UNSTABLE_API) - opts.reliability = options.reliability; -#endif -#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API) - opts.allowed_destination = options.allowed_destination; - opts.source_info = interop::as_moved_c_ptr(options.source_info); -#endif - opts.attachment = interop::as_moved_c_ptr(options.attachment); - opts.timestamp = interop::as_copyable_c_ptr(options.timestamp); - auto payload_ptr = interop::as_moved_c_ptr(payload); - __ZENOH_RESULT_CHECK( - ::z_put(interop::as_loaned_c_ptr(*this), interop::as_loaned_c_ptr(key_expr), payload_ptr, &opts), err, - "Failed to perform put operation"); - } - +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1 /// @brief Options to be passed when declaring a ``Queryable`` struct QueryableOptions { /// @name Fields @@ -485,7 +372,8 @@ class Session : public Owned<::z_owned_session_t> { return Queryable>(std::move(q), std::move(cb_handler_pair.second)); } - +#endif +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_SUBSCRIPTION == 1 /// @brief Options to be passed when declaring a ``Subscriber``. struct SubscriberOptions { /// @name Fields @@ -588,7 +476,122 @@ class Session : public Owned<::z_owned_session_t> { return Subscriber>(std::move(s), std::move(cb_handler_pair.second)); } +#endif +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_PUBLICATION == 1 + /// @brief Options to be passed to ``delete_resource`` operation + struct DeleteOptions { + /// @name Fields + + /// @brief The priority of the delete message. + Priority priority = Z_PRIORITY_DEFAULT; + /// @brief The congestion control to apply when routing delete message. + CongestionControl congestion_control = Z_CONGESTION_CONTROL_DEFAULT; + /// @brief Whether Zenoh will NOT wait to batch delete message with others to reduce the bandwith. + bool is_express = false; +#if 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 The delete operation reliability. + Reliability reliability = Reliability::Z_RELIABILITY_BEST_EFFORT; +#endif + /// @brief the timestamp of this message. + std::optional timestamp = {}; + /// @name Methods + /// @brief Create default option settings. + static DeleteOptions create_default() { return {}; } + }; + + /// @brief Undeclare a resource. Equivalent to ``Publisher::delete_resource``. + /// @param key_expr the key expression to delete the resource. + /// @param options options to pass to delete operation. + /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be + /// thrown in case of error. + void delete_resource(const KeyExpr& key_expr, DeleteOptions&& options = DeleteOptions::create_default(), + ZResult* err = nullptr) const { + ::z_delete_options_t opts; + z_delete_options_default(&opts); + opts.congestion_control = options.congestion_control; + opts.priority = options.priority; + opts.is_express = options.is_express; +#if defined(Z_FEATURE_UNSTABLE_API) + opts.reliability = options.reliability; +#endif + + __ZENOH_RESULT_CHECK(::z_delete(interop::as_loaned_c_ptr(*this), interop::as_loaned_c_ptr(key_expr), &opts), + err, "Failed to perform delete operation"); + } + + /// @brief Options passed to the ``Session::put`` operation. + struct PutOptions { + /// @name Fields + + /// @brief The priority of this message. + Priority priority = Z_PRIORITY_DEFAULT; + /// @brief The congestion control to apply when routing this message. + CongestionControl congestion_control = Z_CONGESTION_CONTROL_DEFAULT; + /// @brief Whether Zenoh will NOT wait to batch this message with others to reduce the bandwith. + bool is_express = false; +#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 Allowed destination. + /// @note Zenoh-c only. + Locality allowed_destination = ::zc_locality_default(); +#endif + /// @brief the timestamp of this message. + std::optional timestamp = {}; + /// @brief An optional encoding of the message payload and/or attachment. + std::optional encoding = {}; +#if 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 The put operation reliability. + Reliability reliability = Reliability::Z_RELIABILITY_BEST_EFFORT; +#endif +#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 The source info of this message. + /// @note Zenoh-c only. + std::optional source_info = {}; +#endif + /// @brief An optional attachment to the message. + std::optional attachment = {}; + + /// @name Methods + /// @brief Create default option settings. + static PutOptions create_default() { return {}; } + }; + + /// @brief Publish data to the matching subscribers in the system. Equivalent to ``Publisher::put``. + /// @param key_expr the key expression to put the data. + /// @param payload the data to publish. + /// @param options options to pass to put operation. + /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be + /// thrown in case of error. + void put(const KeyExpr& key_expr, Bytes&& payload, PutOptions&& options = PutOptions::create_default(), + ZResult* err = nullptr) const { + ::z_put_options_t opts; + z_put_options_default(&opts); + opts.encoding = interop::as_moved_c_ptr(options.encoding); + opts.congestion_control = options.congestion_control; + opts.priority = options.priority; + opts.is_express = options.is_express; +#if defined(Z_FEATURE_UNSTABLE_API) + opts.reliability = options.reliability; +#endif +#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API) + opts.allowed_destination = options.allowed_destination; + opts.source_info = interop::as_moved_c_ptr(options.source_info); +#endif + opts.attachment = interop::as_moved_c_ptr(options.attachment); + opts.timestamp = interop::as_copyable_c_ptr(options.timestamp); + auto payload_ptr = interop::as_moved_c_ptr(payload); + __ZENOH_RESULT_CHECK( + ::z_put(interop::as_loaned_c_ptr(*this), interop::as_loaned_c_ptr(key_expr), payload_ptr, &opts), err, + "Failed to perform put operation"); + } /// @brief Options to be passed when declaring a ``Publisher``. struct PublisherOptions { /// @name Fields @@ -609,6 +612,7 @@ class Session : public Owned<::z_owned_session_t> { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future /// release. /// @brief Allowed destination. + /// @note Zenoh-c only. Locality allowed_destination = ::zc_locality_default(); #endif /// @brief Default encoding to use for Publisher::put. @@ -647,7 +651,7 @@ class Session : public Owned<::z_owned_session_t> { __ZENOH_RESULT_CHECK(res, err, "Failed to declare Publisher"); return p; } - +#endif /// @brief Fetches the Zenoh IDs of all connected routers. /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be /// thrown in case of error. @@ -681,7 +685,6 @@ class Session : public Owned<::z_owned_session_t> { "Failed to fetch peer Ids"); return out; } - #ifdef ZENOHCXX_ZENOHPICO /// @brief Start a separate task to read from the network and process the messages as soon as they are received. /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be @@ -750,6 +753,7 @@ class Session : public Owned<::z_owned_session_t> { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future /// release. /// @brief Options to pass to ``Session::liveliness_declare_token``. + /// @note Zenoh-c only. struct LivelinessDeclarationOptions { protected: uint8_t _dummy = 0; @@ -770,6 +774,7 @@ class Session : public Owned<::z_owned_session_t> { /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be /// thrown in case of error. /// @return a ``LivelinessToken``. + /// @note Zenoh-c only. LivelinessToken liveliness_declare_token( const KeyExpr& key_expr, LivelinessDeclarationOptions&& options = LivelinessDeclarationOptions::create_default(), @@ -787,6 +792,7 @@ class Session : public Owned<::z_owned_session_t> { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future /// release. /// @brief Options to pass to ``Session::liveliness_declare_subscriber``. + /// @note Zenoh-c only. struct LivelinessSubscriberOptions { public: bool history = false; @@ -804,6 +810,7 @@ class Session : public Owned<::z_owned_session_t> { /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be /// thrown in case of error. /// @return a ``Subscriber`` object. + /// @note Zenoh-c only. template [[nodiscard]] Subscriber liveliness_declare_subscriber( const KeyExpr& key_expr, C&& on_sample, D&& on_drop, @@ -841,6 +848,7 @@ class Session : public Owned<::z_owned_session_t> { /// @param options options to pass to subscriber declaration. /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be /// thrown in case of error. + /// @note Zenoh-c only. template void liveliness_declare_background_subscriber( const KeyExpr& key_expr, C&& on_sample, D&& on_drop, @@ -876,6 +884,7 @@ class Session : public Owned<::z_owned_session_t> { /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be /// thrown in case of error. /// @return a ``Subscriber`` object. + /// @note Zenoh-c only. template [[nodiscard]] Subscriber> liveliness_declare_subscriber( const KeyExpr& key_expr, Channel channel, @@ -898,6 +907,7 @@ class Session : public Owned<::z_owned_session_t> { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future /// release. /// @brief Options to pass to ``Session::liveliness_get``. + /// @note Zenoh-c only. struct LivelinessGetOptions { /// @name Fields @@ -919,6 +929,7 @@ class Session : public Owned<::z_owned_session_t> { /// @param options: additional options for the liveliness get operation. /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be /// thrown in case of error. + /// @note Zenoh-c only. template void liveliness_get(const KeyExpr& key_expr, C&& on_reply, D&& on_drop, LivelinessGetOptions&& options = LivelinessGetOptions::create_default(), @@ -953,6 +964,7 @@ class Session : public Owned<::z_owned_session_t> { /// @param err if not null, the result code will be written to this location, otherwise ZException exception will be /// thrown in case of error. /// @return reply handler. + /// @note Zenoh-c only. template typename Channel::template HandlerType liveliness_get( const KeyExpr& key_expr, Channel channel, diff --git a/include/zenoh/api/source_info.hxx b/include/zenoh/api/source_info.hxx index 74e1f721..616ffac5 100644 --- a/include/zenoh/api/source_info.hxx +++ b/include/zenoh/api/source_info.hxx @@ -22,6 +22,7 @@ namespace zenoh { #ifdef ZENOHCXX_ZENOHC /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief The global unique id of a Zenoh entity. +/// @note Zenoh-c only. class EntityGlobalId : public Copyable<::z_entity_global_id_t> { using Copyable::Copyable; friend struct interop::detail::Converter; @@ -38,6 +39,7 @@ class EntityGlobalId : public Copyable<::z_entity_global_id_t> { /// @warning This API has been marked as unstable: it works as advertised, but it may be changed in a future release. /// @brief Informations on the Zenoh source. +/// @note Zenoh-c only. class SourceInfo : public Owned<::z_owned_source_info_t> { public: /// @name Constructors diff --git a/include/zenoh/api/subscriber.hxx b/include/zenoh/api/subscriber.hxx index 51302c97..db51c83b 100644 --- a/include/zenoh/api/subscriber.hxx +++ b/include/zenoh/api/subscriber.hxx @@ -13,6 +13,8 @@ #pragma once +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_SUBSCRIPTION == 1 + #include #include "base.hxx" @@ -153,4 +155,5 @@ auto move_to_c_obj(Subscriber&& s) { } } // namespace interop -} // namespace zenoh \ No newline at end of file +} // namespace zenoh +#endif \ No newline at end of file diff --git a/include/zenoh/detail/closures_concrete.hxx b/include/zenoh/detail/closures_concrete.hxx index a06c3827..ebe53e03 100644 --- a/include/zenoh/detail/closures_concrete.hxx +++ b/include/zenoh/detail/closures_concrete.hxx @@ -26,19 +26,19 @@ namespace zenoh::detail::closures { extern "C" { inline void _zenoh_on_drop(void* context) { IDroppable::delete_from_context(context); } - +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1 inline void _zenoh_on_reply_call(::z_loaned_reply_t* reply, void* context) { IClosure::call_from_context(context, interop::as_owned_cpp_ref(reply)); } - +#endif inline void _zenoh_on_sample_call(::z_loaned_sample_t* sample, void* context) { IClosure::call_from_context(context, interop::as_owned_cpp_ref(sample)); } - +#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1 inline void _zenoh_on_query_call(::z_loaned_query_t* query, void* context) { IClosure::call_from_context(context, interop::as_owned_cpp_ref(query)); } - +#endif inline void _zenoh_on_id_call(const ::z_id_t* z_id, void* context) { IClosure::call_from_context(context, interop::as_copyable_cpp_ref(z_id)); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 311180e4..06d650e1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -54,7 +54,13 @@ foreach(file ${files}) if(ZENOHCXX_ZENOHC) add_test_instance(${file} zenohc zenohcxx::zenohc "") endif() - if(ZENOHCXX_ZENOHPICO) + if(ZENOHCXX_ZENOHPICO) + if ((${file} MATCHES "^.*pub_sub.*$") AND NOT((ZENOHPICO_FEATURE_PUBLICATION) AND (ZENOHPICO_FEATURE_SUBSCRIPTION))) + continue() + endif() + if ((${file} MATCHES "^.*queryable_get.*$") AND NOT((ZENOHPICO_FEATURE_QUERY) AND (ZENOHPICO_FEATURE_QUERYABLE))) + continue() + endif() add_test_instance(${file} zenohpico zenohcxx::zenohpico Router) endif() endforeach() From 659074ad357d83e210c751a5ba61671b087da947 Mon Sep 17 00:00:00 2001 From: Denis Biryukov Date: Fri, 18 Oct 2024 10:26:51 +0200 Subject: [PATCH 2/2] bump zenoh-c/pico submodules --- zenoh-c | 2 +- zenoh-pico | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/zenoh-c b/zenoh-c index 1765a259..cbe57833 160000 --- a/zenoh-c +++ b/zenoh-c @@ -1 +1 @@ -Subproject commit 1765a259573004d5f83ec7be05ac1109dbf10333 +Subproject commit cbe57833f3cde47636983fc2f5bcf9bcf61ec181 diff --git a/zenoh-pico b/zenoh-pico index 65f6927c..5f39d6aa 160000 --- a/zenoh-pico +++ b/zenoh-pico @@ -1 +1 @@ -Subproject commit 65f6927c64893f5f59dbcb9c30633f3cd01374aa +Subproject commit 5f39d6aa53327c9bff4dec9bb5a30852a5db8728