diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 1edddf80..79f9bfbb 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -26,8 +26,13 @@ set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/html/index.html) set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) -file(GLOB_RECURSE HEADERS ${DOXYGEN_INPUT_DIR}/*.hxx) +# file(GLOB_RECURSE HEADERS ${DOXYGEN_INPUT_DIR}/*.hxx) +set(DOXYGEN_INPUT_FILES +${DOXYGEN_INPUT_DIR}/zenohcxx/base.hxx +${DOXYGEN_INPUT_DIR}/zenohcxx/api.hxx +) +list(JOIN DOXYGEN_INPUT_FILES " " DOXYGEN_INPUT_FILES_CFG) configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY) #This will be the main output of our command @@ -35,7 +40,7 @@ set(DOXYGEN_INDEX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/html/index.html) file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR}) add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE} - DEPENDS ${HEADERS} + DEPENDS ${DOXYGEN_INPUT_FILES} COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT} MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN} COMMENT "Generating docs") diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 1f8387f5..2fb0c98c 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -943,7 +943,7 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = "@DOXYGEN_INPUT_DIR@" +INPUT = @DOXYGEN_INPUT_FILES_CFG@ # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -2303,7 +2303,7 @@ PERLMOD_MAKEVAR_PREFIX = # C-preprocessor directives found in the sources and include files. # The default value is: YES. -ENABLE_PREPROCESSING = YES +ENABLE_PREPROCESSING = NO # If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names # in the source code. If set to NO, only conditional compilation will be @@ -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 = +PREDEFINED = __ZENOHCXX_ZENOHPICO __ZENOHCXX_ZENOHC # 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 diff --git a/docs/api.rst b/docs/api.rst index 187f4183..e03c7009 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -16,14 +16,9 @@ API Reference ************* -Generic types -============= +.. toctree:: + :maxdepth: 10 -.. doxygentypedef:: ErrorMessage - -.. doxygentypedef:: ErrNo - -.. doxygentypedef:: SampleKind - -.. doxygenstruct:: StrArrayView - :members: \ No newline at end of file + enums + copyable + utility \ No newline at end of file diff --git a/docs/copyable.rst b/docs/copyable.rst new file mode 100644 index 00000000..bd176dbd --- /dev/null +++ b/docs/copyable.rst @@ -0,0 +1,32 @@ +.. +.. Copyright (c) 2023 ZettaScale Technology +.. +.. This program and the accompanying materials are made available under the +.. terms of the Eclipse Public License 2.0 which is available at +.. http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +.. which is available at https://www.apache.org/licenses/LICENSE-2.0. +.. +.. SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +.. +.. Contributors: +.. ZettaScale Zenoh Team, +.. + +Copyable types +============== + +Copyable types are the types which can be freely copied and passed by value. +They either don't reference external resources or they reference resources +without taking ownership. + +All these types are based on `Copyable` template. + +.. doxygenstruct:: zenohcxx::Copyable + :members: + +.. doxygenclass:: BytesView + :members: + +.. doxygenstruct:: StrArrayView +.. doxygenstruct:: _StrArrayView + :members: \ No newline at end of file diff --git a/docs/enums.rst b/docs/enums.rst new file mode 100644 index 00000000..312e6a58 --- /dev/null +++ b/docs/enums.rst @@ -0,0 +1,44 @@ +.. +.. Copyright (c) 2023 ZettaScale Technology +.. +.. This program and the accompanying materials are made available under the +.. terms of the Eclipse Public License 2.0 which is available at +.. http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +.. which is available at https://www.apache.org/licenses/LICENSE-2.0. +.. +.. SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +.. +.. Contributors: +.. ZettaScale Zenoh Team, +.. + +Enums +===== + +Enum types are C++ - style typedefs for corrresponding enums of zenoh-c / zenoh-pico C API. + +.. doxygentypedef:: ErrorMessage + +.. doxygentypedef:: ErrNo + +.. doxygentypedef:: SampleKind + +.. doxygentypedef:: EncodingPrefix + +.. doxygentypedef:: ConsolidationMode + +.. doxygentypedef:: Reliability + +.. doxygentypedef:: CongestionControl + +.. doxygentypedef:: Priority + +.. doxygentypedef:: QueryTarget + +.. doxygenfunction:: query_target_default + +.. doxygentypedef:: WhatAmI +See also ::cpp:func:`as_cstr` + +.. doxygenenum:: WhatAmI +See also ::cpp:func:`as_cstr` \ No newline at end of file diff --git a/docs/utility.rst b/docs/utility.rst new file mode 100644 index 00000000..bb61092e --- /dev/null +++ b/docs/utility.rst @@ -0,0 +1,20 @@ +.. +.. Copyright (c) 2023 ZettaScale Technology +.. +.. This program and the accompanying materials are made available under the +.. terms of the Eclipse Public License 2.0 which is available at +.. http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +.. which is available at https://www.apache.org/licenses/LICENSE-2.0. +.. +.. SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +.. +.. Contributors: +.. ZettaScale Zenoh Team, +.. + +Utility functions +================= + +.. doxygenfunction:: init_logger + +.. doxygenfunction:: as_cstr \ No newline at end of file diff --git a/include/zenohcxx/api.hxx b/include/zenohcxx/api.hxx index eb30ab4d..af7166e3 100644 --- a/include/zenohcxx/api.hxx +++ b/include/zenohcxx/api.hxx @@ -29,181 +29,216 @@ class Session; class Value; -/** -Error message returned by some functions -*/ +/// Text error message returned in ``std::variant`` retrun types. typedef z::Value ErrorMessage; -/** -Error code value returned as negative value from zenohc/zenohpico functions -*/ +/// Numeric error code value typedef int8_t ErrNo; -/** -Sample kind values. - -Enumerators: - -Z_SAMPLE_KIND_PUT: The Sample was issued by a ``put`` operation. -Z_SAMPLE_KIND_DELETE: The Sample was issued by a ``delete`` operation. -*/ +/// Sample kind values. +/// +/// Values: +/// +/// - **Z_SAMPLE_KIND_PUT**: The Sample was issued by a ``put`` operation. +/// - **Z_SAMPLE_KIND_DELETE**: The Sample was issued by a ``delete`` operation. typedef ::z_sample_kind_t SampleKind; -// -// Zenoh encoding values. -// These values are based on already existing HTTP MIME types and extended with other relevant encodings. -// -// Enumerators: -// Z_ENCODING_PREFIX_EMPTY: Encoding not defined. -// Z_ENCODING_PREFIX_APP_OCTET_STREAM: ``application/octet-stream``. Default value for all other cases. An unknown -// file type should use this type. Z_ENCODING_PREFIX_APP_CUSTOM: Custom application type. Non IANA standard. -// Z_ENCODING_PREFIX_TEXT_PLAIN: ``text/plain``. Default value for textual files. A textual file should be -// human-readable and must not contain binary data. Z_ENCODING_PREFIX_APP_PROPERTIES: Application properties -// type. Non IANA standard. Z_ENCODING_PREFIX_APP_JSON: ``application/json``. JSON format. -// Z_ENCODING_PREFIX_APP_SQL: Application sql type. Non IANA standard. Z_ENCODING_PREFIX_APP_INTEGER: Application -// integer type. Non IANA standard. Z_ENCODING_PREFIX_APP_FLOAT: Application float type. Non IANA standard. -// Z_ENCODING_PREFIX_APP_XML: ``application/xml``. XML. -// Z_ENCODING_PREFIX_APP_XHTML_XML: ``application/xhtml+xml``. XHTML. -// Z_ENCODING_PREFIX_APP_X_WWW_FORM_URLENCODED: ``application/x-www-form-urlencoded``. The keys and values are -// encoded in key-value tuples separated by '&', with a '=' between the key and the value. -// Z_ENCODING_PREFIX_TEXT_JSON: Text JSON. Non IANA standard. Z_ENCODING_PREFIX_TEXT_HTML: ``text/html``. -// HyperText -// Markup Language (HTML). Z_ENCODING_PREFIX_TEXT_XML: ``text/xml``. `Application/xml` is recommended as of RFC -// 7303 (section 4.1), but `text/xml` is still used sometimes. Z_ENCODING_PREFIX_TEXT_CSS: ``text/css``. -// Cascading Style Sheets (CSS). Z_ENCODING_PREFIX_TEXT_CSV: ``text/csv``. Comma-separated values (CSV). -// Z_ENCODING_PREFIX_TEXT_JAVASCRIPT: ``text/javascript``. JavaScript. -// Z_ENCODING_PREFIX_IMAGE_JPEG: ``image/jpeg``. JPEG images. -// Z_ENCODING_PREFIX_IMAGE_PNG: ``image/png``. Portable Network Graphics. -// Z_ENCODING_PREFIX_IMAGE_GIF: ``image/gif``. Graphics Interchange Format (GIF). -// +// Zenoh encoding values. +// These values are based on already existing HTTP MIME types and extended with other relevant encodings. + +/// Values: +/// - **Z_ENCODING_PREFIX_EMPTY**: Encoding not defined. +/// - **Z_ENCODING_PREFIX_APP_OCTET_STREAM**: ``application/octet-stream``. Default value for all other cases. An +/// unknown file type should use this type. +/// - **Z_ENCODING_PREFIX_APP_CUSTOM**: Custom application type. Non IANA standard. +/// - **Z_ENCODING_PREFIX_TEXT_PLAIN**: ``text/plain``. Default value for textual files. A textual file should be +/// human-readable and must not contain binary data. +/// - **Z_ENCODING_PREFIX_APP_PROPERTIES**: Application properties +/// type. Non IANA standard. +/// - **Z_ENCODING_PREFIX_APP_JSON**: ``application/json``. JSON format. +/// - **Z_ENCODING_PREFIX_APP_SQL**: Application sql type. Non IANA standard. +/// - **Z_ENCODING_PREFIX_APP_INTEGER**: Application integer type. Non IANA standard. +/// - **Z_ENCODING_PREFIX_APP_FLOAT**: Application float type. Non IANA standard. +/// - **Z_ENCODING_PREFIX_APP_XML**: ``application/xml``. XML. +/// - **Z_ENCODING_PREFIX_APP_XHTML_XML**: ``application/xhtml+xml``. XHTML. +/// - **Z_ENCODING_PREFIX_APP_X_WWW_FORM_URLENCODED**: ``application/x-www-form-urlencoded``. The keys and values +/// are +/// encoded in key-value tuples separated by '&', with a '=' between the key and the value. +/// -**Z_ENCODING_PREFIX_TEXT_JSON**: Text JSON. Non IANA standard. +/// -**Z_ENCODING_PREFIX_TEXT_HTML**: ``text/html``. HyperText Markup Language (HTML). +/// -**Z_ENCODING_PREFIX_TEXT_XML**: ``text/xml``. `Application/xml` is recommended as of RFC +/// 7303 (section 4.1), but `text/xml` is still used sometimes. +/// - **Z_ENCODING_PREFIX_TEXT_CSS**: ``text/css``. Cascading Style Sheets (CSS). +/// - **Z_ENCODING_PREFIX_TEXT_CSV**: ``text/csv``. Comma-separated values (CSV). +/// - **Z_ENCODING_PREFIX_TEXT_JAVASCRIPT**: ``text/javascript``. JavaScript. +/// - **Z_ENCODING_PREFIX_IMAGE_JPEG**: ``image/jpeg``. JPEG images. +/// - **Z_ENCODING_PREFIX_IMAGE_PNG**: ``image/png``. Portable Network Graphics. +/// - **Z_ENCODING_PREFIX_IMAGE_GIF**: ``image/gif``. Graphics Interchange Format (GIF). typedef ::z_encoding_prefix_t EncodingPrefix; -// -// Consolidation mode values. -// -// Enumerators: -// Z_CONSOLIDATION_MODE_AUTO: Let Zenoh decide the best consolidation mode depending on the query selector. -// Z_CONSOLIDATION_MODE_NONE: No consolidation is applied. Replies may come in any order and any number. -// Z_CONSOLIDATION_MODE_MONOTONIC: It guarantees that any reply for a given key expression will be monotonic in -// time -// w.r.t. the previous received replies for the same key expression. I.e., for the same key expression multiple -// replies may be received. It is guaranteed that two replies received at t1 and t2 will have timestamp -// ts2 > ts1. It optimizes latency. -// Z_CONSOLIDATION_MODE_LATEST: It guarantees unicity of replies for the same key expression. -// It optimizes bandwidth. -// +/// Consolidation mode values. +/// +/// Values: +/// - **Z_CONSOLIDATION_MODE_AUTO**: Let Zenoh decide the best consolidation mode depending on the query selector. +/// - **Z_CONSOLIDATION_MODE_NONE**: No consolidation is applied. Replies may come in any order and any number. +/// - **Z_CONSOLIDATION_MODE_MONOTONIC**: It guarantees that any reply for a given key expression will be +/// monotonic in time +/// w.r.t. the previous received replies for the same key expression. I.e., for the same key expression +/// multiple replies may be received. It is guaranteed that two replies received at t1 and t2 will have +/// timestamp ts2 > ts1. It optimizes latency. +/// - **Z_CONSOLIDATION_MODE_LATEST**: It guarantees unicity of replies for the same key expression. +/// It optimizes bandwidth. typedef ::z_consolidation_mode_t ConsolidationMode; -// -// Reliability values. -// -// Enumerators: -// Z_RELIABILITY_BEST_EFFORT: Defines reliability as ``BEST_EFFORT`` -// Z_RELIABILITY_RELIABLE: Defines reliability as ``RELIABLE`` -// +/// Reliability values. +/// +/// Values: +/// - **Z_RELIABILITY_BEST_EFFORT**: Defines reliability as ``BEST_EFFORT`` +/// - **Z_RELIABILITY_RELIABLE**: Defines reliability as ``RELIABLE`` typedef ::z_reliability_t Reliability; -// -// Congestion control values. -// Enumerators: -// Z_CONGESTION_CONTROL_BLOCK: Defines congestion control as ``BLOCK``. Messages are not dropped in case of -// congestion control. -// Z_CONGESTION_CONTROL_DROP: Defines congestion control as ``DROP``. Messages are dropped in case -// of congestion control. -// +/// Congestion control values. +/// +/// Values: +/// - **Z_CONGESTION_CONTROL_BLOCK**: Defines congestion control as ``BLOCK``. Messages are not dropped in case of +/// congestion control. +/// - **Z_CONGESTION_CONTROL_DROP**: Defines congestion control as ``DROP``. Messages are dropped in case +/// of congestion control. typedef ::z_congestion_control_t CongestionControl; -// -// Priority of Zenoh messages values. -// Enumerators: -// _Z_PRIORITY_CONTROL: Priority for ``Control`` messages. -// Z_PRIORITY_REAL_TIME: Priority for ``RealTime`` messages. -// Z_PRIORITY_INTERACTIVE_HIGH: Highest priority for ``Interactive`` messages. -// Z_PRIORITY_INTERACTIVE_LOW: Lowest priority for ``Interactive`` messages. -// Z_PRIORITY_DATA_HIGH: Highest priority for ``Data`` messages. -// Z_PRIORITY_DATA: Default priority for ``Data`` messages. -// Z_PRIORITY_DATA_LOW: Lowest priority for ``Data`` messages. -// Z_PRIORITY_BACKGROUND: Priority for ``Background traffic`` messages. -// +/// Priority of Zenoh messages values. +/// +/// Values: +/// - **Z_PRIORITY_REAL_TIME**: Priority for ``RealTime`` messages. +/// - **Z_PRIORITY_INTERACTIVE_HIGH**: Highest priority for ``Interactive`` messages. +/// - **Z_PRIORITY_INTERACTIVE_LOW**: Lowest priority for ``Interactive`` messages. +/// - **Z_PRIORITY_DATA_HIGH**: Highest priority for ``Data`` messages. +/// - **Z_PRIORITY_DATA**: Default priority for ``Data`` messages. +/// - **Z_PRIORITY_DATA_LOW**: Lowest priority for ``Data`` messages. +/// - **Z_PRIORITY_BACKGROUND**: Priority for ``Background traffic`` messages. typedef ::z_priority_t Priority; -// -// Query target values. -// Enumerators: -// Z_QUERY_TARGET_BEST_MATCHING: The nearest complete queryable if any else all matching queryables. -// Z_QUERY_TARGET_ALL: All matching queryables. -// Z_QUERY_TARGET_ALL_COMPLETE: A set of complete queryables. -// +/// Query target values. +/// +/// Values: +/// - **Z_QUERY_TARGET_BEST_MATCHING**: The nearest complete queryable if any else all matching queryables. +/// - **Z_QUERY_TARGET_ALL**: All matching queryables. +/// - **Z_QUERY_TARGET_ALL_COMPLETE**: A set of complete queryables. typedef ::z_query_target_t QueryTarget; -// -// Whatami values, defined as a bitmask. -// Enumerators: -// Z_WHATAMI_ROUTER: Bitmask to filter Zenoh routers. -// Z_WHATAMI_PEER: Bitmask to filter for Zenoh peers. -// Z_WHATAMI_CLIENT: Bitmask to filter for Zenoh clients. -// +/// Constructs a default ``QueryTarget`` +/// @return a default ``QueryTarget`` +inline z::QueryTarget query_target_default(); + #ifdef __ZENOHCXX_ZENOHPICO +/// (*zenoh-pico* only) Whatami values, defined as a bitmask +/// +/// Values: +/// - **Z_WHATAMI_ROUTER**: Bitmask to filter Zenoh routers. +/// - **Z_WHATAMI_PEER**: Bitmask to filter for Zenoh peers. +/// - **Z_WHATAMI_CLIENT**: Bitmask to filter for Zenoh clients. typedef ::z_whatami_t WhatAmI; #endif #ifdef __ZENOHCXX_ZENOHC -enum WhatAmI { Z_WHATAMI_ROUTER = 1, Z_WHATAMI_PEER = 1 << 1, Z_WHATAMI_CLIENT = 1 << 2 }; +/// (*zenoh-c* only) Whatami values, defined as a bitmask +enum WhatAmI { + /// Bitmask to filter Zenoh routers + Z_WHATAMI_ROUTER = 1, + /// Bitmask to filter for Zenoh peers + Z_WHATAMI_PEER = 1 << 1, + /// Bitmask to filter for Zenoh clients + Z_WHATAMI_CLIENT = 1 << 2 +}; #endif +/// Returns a string representation of the given ``WhatAmI`` value. +/// @param whatami the ``WhatAmI`` value +/// @return a string representation of the given ``WhatAmI`` value inline const char* as_cstr(z::WhatAmI whatami); -// -// Constructs a default QueryTarget -// -inline z::QueryTarget query_target_default(); - #ifdef __ZENOHCXX_ZENOHC -// Initializes logger for zenohc -// User may set environment variable RUST_LOG to values debug|info|warn|error to show diagnostic output. +/// Initializes logger (zenoh-c library only) +/// User may set environment variable RUST_LOG to values debug|info|warn|error to show diagnostic output void init_logger(); #endif -// -// StrArrayView represents non-owned read only array of char* -// Impmemented as template to handle with different const definitions in ::z_str_array_t struct in zenohpico and zenohc -// template struct _StrArrayView : Copyable { typedef decltype(Z_STR_ARRAY_T::val) VALTYPE; using Copyable::Copyable; + /// Constructs an uninitialized instance _StrArrayView() : Copyable({0, nullptr}) {} + /// Constructs an instance from a ``std::vector`` of ``const char*`` + /// @param v the ``std::vector`` of ``const char*`` _StrArrayView(const std::vector& v) : Copyable({v.size(), const_cast(&v[0])}) {} + /// Constructs an instance from an array of ``const char*`` + /// @param v the array of ``const char*`` + /// @param len the length of the array + //// _StrArrayView(const char** v, size_t len) : Copyable({len, const_cast(v)}) {} + /// Constructs an instance from an constant array of ``const char*`` + /// @param v the array of ``const char*`` + /// @param len the length of the array _StrArrayView(const char* const* v, size_t len) : Copyable({len, const_cast(v)}) {} + /// Operator to access an element of the array by index + /// @param pos the index of the element + /// @return the element at the given index const char* operator[](size_t pos) const { return Copyable::val[pos]; } + /// Returns the length of the array + /// @return the length of the array size_t get_len() const { return Copyable::len; } }; +/// Represents non-owned read only array of ``char*`` +/// Impmemented in a template ``_StrArrayView`` to handle with different const definitions in ``::z_str_array_t`` struct +/// in zenoh-pico and zenoh-c struct StrArrayView : z::_StrArrayView<::z_str_array_t> { using _StrArrayView<::z_str_array_t>::_StrArrayView; }; -// -// BytesView represents non-owned read only array of bytes -// +/// Represents non-owned read only array of bytes class BytesView : public Copyable<::z_bytes_t> { public: using Copyable::Copyable; + /// Constructs an uninitialized instance BytesView(nullptr_t) : Copyable(init(nullptr, 0)) {} + /// Constructs an instance from an array of bytes + /// @param s the array of bytes + /// @param _len the length of the array BytesView(const void* s, size_t _len) : Copyable(init(reinterpret_cast(s), _len)) {} + /// Constructs an instance from a null-terminated string + /// @param s the null-terminated string BytesView(const char* s) : Copyable({s ? strlen(s) : 0, reinterpret_cast(s)}) {} + /// Constructs an instance from a ``std::vector`` of type ``T`` + /// @param v the ``std::vector`` of type ``T`` template BytesView(const std::vector& v) : Copyable({v.size() * sizeof(T), reinterpret_cast(&v[0])}) {} + /// Constructs an instance from a ``std::string_view`` + /// @param s the ``std::string_view`` BytesView(const std::string_view& s) : Copyable({s.length(), reinterpret_cast(s.data())}) {} + /// Constructs an instance from a ``std::string`` + /// @param s the ``std::string`` BytesView(const std::string& s) : Copyable({s.length(), reinterpret_cast(s.data())}) {} + /// Returns a ``std::string_view`` representation of the array of bytes + /// @return a ``std::string_view`` representation of the array of bytes std::string_view as_string_view() const { return std::string_view(reinterpret_cast(start), len); } + /// Compares two instances of ``BytesView`` + /// @param v the other instance of ``BytesView`` + /// @return true if the two instances are equal, false otherwise bool operator==(const BytesView& v) const { return as_string_view() == v.as_string_view(); } + /// Compares two instances of ``BytesView`` + /// @param v the other instance of ``BytesView`` + /// @return true if the two instances are not equal, false otherwise bool operator!=(const BytesView& v) const { return !operator==(v); } + /// Returns the length of the array + /// @return the length of the array size_t get_len() const { return len; } + /// Checks if the array is initialized + /// @return true if the array is initialized bool check() const { return ::z_bytes_check(this); } private: diff --git a/include/zenohcxx/base.hxx b/include/zenohcxx/base.hxx index db6472f9..a33f5535 100644 --- a/include/zenohcxx/base.hxx +++ b/include/zenohcxx/base.hxx @@ -33,13 +33,17 @@ namespace zenohcxx { // Template base classes implementing common functionality // -// -// Base type for C++ wrappers of Zenoh copyable structures, like GetOptions, PutOptions, etc. -// +/// @brief Base type for C++ wrappers of Zenoh copyable structures, like GetOptions, PutOptions, etc. +/// +/// @tparam ZC_COPYABLE_TYPE template struct Copyable : public ZC_COPYABLE_TYPE { + /// @brief Default constructor is deleted by default, derived classes may override it to create default valid object + /// when corresponding z_XXX_default function is available in zenoh-c / zenoh-pico API. Copyable() = delete; // May be overloaded in derived structs with corresponding z_XXX_default function + /// @brief Copying is allowed Copyable(const Copyable& v) { *this = v; } + /// @brief Construct from wrapped zenoh-c / zenoh-pico structure Copyable(ZC_COPYABLE_TYPE v) : ZC_COPYABLE_TYPE(v) {} };