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

support for zenoh-pico build granularity #258

Merged
merged 3 commits into from
Oct 18, 2024
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
20 changes: 20 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions examples/simple/universal/z_simple.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions examples/simple/zenohpico/zp_simple.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 2 additions & 3 deletions include/zenoh/api.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 8 additions & 0 deletions include/zenoh/api/channels.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct FifoHandlerData<zenoh::Sample> {
}
};

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1
template <>
struct FifoHandlerData<zenoh::Query> {
typedef ::z_owned_fifo_handler_query_t handler_type;
Expand All @@ -56,7 +57,9 @@ struct FifoHandlerData<zenoh::Query> {
::z_fifo_channel_query_new(cb, h, capacity);
}
};
#endif

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1
template <>
struct FifoHandlerData<zenoh::Reply> {
typedef ::z_owned_fifo_handler_reply_t handler_type;
Expand All @@ -65,6 +68,7 @@ struct FifoHandlerData<zenoh::Reply> {
::z_fifo_channel_reply_new(cb, h, capacity);
}
};
#endif

template <class T>
struct RingHandlerData {};
Expand All @@ -78,6 +82,7 @@ struct RingHandlerData<zenoh::Sample> {
}
};

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1
template <>
struct RingHandlerData<zenoh::Query> {
typedef ::z_owned_ring_handler_query_t handler_type;
Expand All @@ -86,7 +91,9 @@ struct RingHandlerData<zenoh::Query> {
::z_ring_channel_query_new(cb, h, capacity);
}
};
#endif

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1
template <>
struct RingHandlerData<zenoh::Reply> {
typedef ::z_owned_ring_handler_reply_t handler_type;
Expand All @@ -95,6 +102,7 @@ struct RingHandlerData<zenoh::Reply> {
::z_ring_channel_reply_new(cb, h, capacity);
}
};
#endif
} // namespace detail

class FifoChannel;
Expand Down
4 changes: 3 additions & 1 deletion include/zenoh/api/liveliness.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#pragma once

#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
#include "base.hxx"
#include "interop.hxx"

Expand Down Expand Up @@ -43,4 +44,5 @@ class LivelinessToken : public Owned<::zc_owned_liveliness_token_t> {
}
};

} // namespace zenoh
} // namespace zenoh
#endif
4 changes: 4 additions & 0 deletions include/zenoh/api/publisher.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#pragma once

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_PUBLICATION == 1

#include "base.hxx"
#include "bytes.hxx"
#include "encoding.hxx"
Expand Down Expand Up @@ -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<SourceInfo> source_info = {};
#endif
/// @brief The attachment to attach to the publication.
Expand Down Expand Up @@ -125,3 +128,4 @@ class Publisher : public Owned<::z_owned_publisher_t> {
#endif
};
} // namespace zenoh
#endif
5 changes: 4 additions & 1 deletion include/zenoh/api/query.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#pragma once

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1
#include <functional>
#include <optional>
#include <string_view>
Expand Down Expand Up @@ -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<SourceInfo> source_info = {};
#endif
/// @brief An optional attachment to this reply message.
Expand Down Expand Up @@ -221,4 +223,5 @@ class Query : public Owned<::z_owned_query_t> {
};
};

} // namespace zenoh
} // namespace zenoh
#endif
5 changes: 4 additions & 1 deletion include/zenoh/api/query_consolidation.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#pragma once

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1

#include "base.hxx"
#include "enums.hxx"
#include "interop.hxx"
Expand Down Expand Up @@ -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
} // namespace zenoh
#endif
5 changes: 4 additions & 1 deletion include/zenoh/api/queryable.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#pragma once

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERYABLE == 1

#include <utility>

#include "base.hxx"
Expand Down Expand Up @@ -143,4 +145,5 @@ auto move_to_c_obj(Queryable<Handler>&& q) {
}
} // namespace interop

} // namespace zenoh
} // namespace zenoh
#endif
5 changes: 4 additions & 1 deletion include/zenoh/api/reply.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#pragma once

#if defined(ZENOHCXX_ZENOHC) || Z_FEATURE_QUERY == 1

#include "base.hxx"
#include "bytes.hxx"
#include "id.hxx"
Expand Down Expand Up @@ -84,4 +86,5 @@ class Reply : public Owned<::z_owned_reply_t> {
#endif
};

} // namespace zenoh
} // namespace zenoh
#endif
1 change: 1 addition & 0 deletions include/zenoh/api/sample.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<SourceInfo>(::z_sample_source_info(interop::as_loaned_c_ptr(*this)));
}
Expand Down
Loading
Loading