Skip to content

Commit

Permalink
prepend feature macros with Z_FEATURE to avoid collisions
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Sep 19, 2024
1 parent a345711 commit 861f5f2
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 64 deletions.
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -2353,7 +2353,7 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED = ZENOHCXX_ZENOHPICO ZENOHCXX_ZENOHC SHARED_MEMORY UNSTABLE __DOXYGEN__
PREDEFINED = ZENOHCXX_ZENOHPICO ZENOHCXX_ZENOHC Z_FEATURE_SHARED_MEMORY Z_FEATURE_UNSTABLE_API __DOXYGEN__

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
2 changes: 1 addition & 1 deletion examples/universal/z_info.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int _main(int argc, char** argv) {
std::cout << "Opening session...\n";
auto session = Session::open(std::move(config));

#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
std::cout << "own id: " << session.get_zid() << std::endl;

std::cout << "routers ids:\n";
Expand Down
2 changes: 1 addition & 1 deletion examples/universal/z_scout.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void printlocators(const std::vector<std::string_view> &locs) {

void printhello(const Hello &hello) {
std::cout << "Hello { ";
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
std::cout << "pid: " << hello.get_id() << ", ";
#endif
std::cout << "whatami: " << hello.get_whatami();
Expand Down
6 changes: 3 additions & 3 deletions examples/zenohc/z_sub_shm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ const char *kind_to_str(SampleKind kind) {

void data_handler(const Sample &sample) {
// if Zenoh is built without SHM support, the only buffer type it can receive is RAW
#if !defined(SHARED_MEMORY)
#if !defined(Z_FEATURE_SHARED_MEMORY)
const char *payload_type = "RAW";
#endif

// if Zenoh is built with SHM support but without SHM API (that is unstable), it can
// receive buffers of any type, but there is no way to detect the buffer type
#if defined(SHARED_MEMORY) && !defined(UNSTABLE)
#if defined(Z_FEATURE_SHARED_MEMORY) && !defined(Z_FEATURE_UNSTABLE_API)
const char *payload_type = "UNKNOWN";
#endif

// if Zenoh is built with SHM support and with SHM API, we can detect the exact buffer type
#if defined(SHARED_MEMORY) && defined(UNSTABLE)
#if defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API)
const char *payload_type = "RAW";
{
ZResult result;
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh/api.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "api/encoding.hxx"
#include "api/enums.hxx"
#include "api/hello.hxx"
#if defined UNSTABLE
#if defined Z_FEATURE_UNSTABLE_API
#include "api/id.hxx"
#endif
#include "api/channels.hxx"
Expand All @@ -35,6 +35,6 @@
#include "api/session.hxx"
#include "api/subscriber.hxx"
#include "api/timestamp.hxx"
#if defined SHARED_MEMORY && defined UNSTABLE
#if defined Z_FEATURE_SHARED_MEMORY && defined Z_FEATURE_UNSTABLE_API
#include "api/shm/shm.hxx"
#endif
6 changes: 3 additions & 3 deletions include/zenoh/api/bytes.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "base.hxx"
#include "closures.hxx"
#include "interop.hxx"
#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API))
#include "shm/buffer/buffer.hxx"
#endif

Expand Down Expand Up @@ -357,7 +357,7 @@ struct ZenohDeserializer<std::string> {
}
};

#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API))
template <>
struct ZenohDeserializer<ZShm> {
static ZShm deserialize(const Bytes& b, ZResult* err = nullptr) {
Expand Down Expand Up @@ -553,7 +553,7 @@ class ZenohCodec {

Bytes serialize(const Bytes& b) const { return b.clone(); }

#if (defined(SHARED_MEMORY) && defined(UNSTABLE))
#if (defined(Z_FEATURE_SHARED_MEMORY) && defined(Z_FEATURE_UNSTABLE_API))
Bytes serialize(ZShm&& shm, ZResult* err = nullptr) const {
Bytes b;
__ZENOH_RESULT_CHECK(::z_bytes_serialize_from_shm(interop::as_owned_c_ptr(b), interop::as_moved_c_ptr(shm)),
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh/api/enums.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef ::z_sample_kind_t SampleKind;
/// It optimizes bandwidth.
typedef ::z_consolidation_mode_t ConsolidationMode;

#if defined(UNSTABLE)
#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 Publisher reliability values.
///
Expand Down Expand Up @@ -101,7 +101,7 @@ inline std::string_view whatami_as_str(WhatAmI whatami) {
return std::string_view(::z_string_data(::z_loan(str_out)), ::z_string_len(::z_loan(str_out)));
}

#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#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 locality of samples to be received by subscribers or targeted by publishers.
///
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh/api/hello.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "base.hxx"
#include "enums.hxx"
#include "interop.hxx"
#if defined UNSTABLE
#if defined Z_FEATURE_UNSTABLE_API
#include "id.hxx"
#endif

Expand All @@ -30,7 +30,7 @@ class Hello : public Owned<::z_owned_hello_t> {
public:
/// @name Methods

#if defined UNSTABLE
#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 Get ``Id`` of the entity.
Expand Down
2 changes: 1 addition & 1 deletion include/zenoh/api/keyexpr.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class KeyExpr : public Owned<::z_owned_keyexpr_t> {
bool intersects(const KeyExpr& other) const {
return ::z_keyexpr_intersects(interop::as_loaned_c_ptr(*this), interop::as_loaned_c_ptr(other));
}
#if defined(UNSTABLE)
#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 Intersection level of 2 key expressions.
Expand Down
8 changes: 4 additions & 4 deletions include/zenoh/api/publisher.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "interop.hxx"
#include "keyexpr.hxx"
#include "timestamp.hxx"
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
#include "source_info.hxx"
#endif
#include <optional>
Expand All @@ -43,7 +43,7 @@ class Publisher : public Owned<::z_owned_publisher_t> {
std::optional<Encoding> encoding = {};
/// @brief the timestamp of this message.
std::optional<Timestamp> timestamp = {};
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#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.
Expand Down Expand Up @@ -79,7 +79,7 @@ class Publisher : public Owned<::z_owned_publisher_t> {
::z_publisher_put_options_t opts;
z_publisher_put_options_default(&opts);
opts.encoding = interop::as_moved_c_ptr(options.encoding);
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
opts.source_info = interop::as_moved_c_ptr(options.source_info);
#endif
opts.attachment = interop::as_moved_c_ptr(options.attachment);
Expand All @@ -105,7 +105,7 @@ class Publisher : public Owned<::z_owned_publisher_t> {
const KeyExpr& get_keyexpr() const {
return interop::as_owned_cpp_ref<KeyExpr>(::z_publisher_keyexpr(interop::as_loaned_c_ptr(*this)));
}
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#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 publisher.
Expand Down
10 changes: 5 additions & 5 deletions include/zenoh/api/query.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "enums.hxx"
#include "interop.hxx"
#include "keyexpr.hxx"
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
#include "source_info.hxx"
#endif
#include "timestamp.hxx"
Expand Down Expand Up @@ -93,7 +93,7 @@ class Query : public Owned<::z_owned_query_t> {
bool is_express = false;
/// @brief The timestamp of this message.
std::optional<Timestamp> timestamp = {};
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#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 reply message.
Expand Down Expand Up @@ -122,7 +122,7 @@ class Query : public Owned<::z_owned_query_t> {
opts.congestion_control = options.congestion_control;
opts.is_express = options.is_express;
opts.timestamp = interop::as_copyable_c_ptr(options.timestamp);
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
opts.source_info = interop::as_moved_c_ptr(options.source_info);
#endif
opts.attachment = interop::as_moved_c_ptr(options.attachment);
Expand Down Expand Up @@ -172,7 +172,7 @@ class Query : public Owned<::z_owned_query_t> {
bool is_express = false;
/// @brief the timestamp of this message.
std::optional<Timestamp> timestamp = {};
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#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 reply message.
Expand Down Expand Up @@ -200,7 +200,7 @@ class Query : public Owned<::z_owned_query_t> {
opts.congestion_control = options.congestion_control;
opts.is_express = options.is_express;
opts.timestamp = interop::as_copyable_c_ptr(options.timestamp);
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
opts.source_info = interop::as_moved_c_ptr(options.source_info);
#endif
opts.attachment = interop::as_moved_c_ptr(options.attachment);
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh/api/reply.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "bytes.hxx"
#include "interop.hxx"
#include "sample.hxx"
#if defined UNSTABLE
#if defined Z_FEATURE_UNSTABLE_API
#include "id.hxx"
#endif

Expand Down Expand Up @@ -71,7 +71,7 @@ class Reply : public Owned<::z_owned_reply_t> {
return interop::as_owned_cpp_ref<ReplyError>(::z_reply_err(interop::as_loaned_c_ptr(*this)));
}

#if defined(UNSTABLE)
#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 Get the id of the Zenoh instance that issued this reply.
Expand Down
6 changes: 3 additions & 3 deletions include/zenoh/api/sample.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "interop.hxx"
#include "keyexpr.hxx"
#include "timestamp.hxx"
#if defined(ZENOHCXX_ZENOHC) && defined(UNSTABLE)
#if defined(ZENOHCXX_ZENOHC) && defined(Z_FEATURE_UNSTABLE_API)
#include "source_info.hxx"
#endif

Expand Down Expand Up @@ -90,7 +90,7 @@ class Sample : public Owned<::z_owned_sample_t> {
/// @brief Get the express setting this sample was sent with.
/// @return ``CongestionControl`` value.
bool get_express() const { return ::z_sample_express(interop::as_loaned_c_ptr(*this)); }
#if defined(ZENOHCXX) && defined(UNSTABLE)
#if defined(ZENOHCXX) && 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 source info of this sample.
Expand All @@ -99,7 +99,7 @@ class Sample : public Owned<::z_owned_sample_t> {
}
#endif

#if defined(UNSTABLE)
#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 Get the reliability this sample was sent with.
Expand Down
Loading

0 comments on commit 861f5f2

Please sign in to comment.