Base templates
There are two kinds of classes in zenoh-cpp: zenohcxx::Copyable
and zenohcxx::Owned
.
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.
Owned types are the types which own resources. They implements move semantics and cannot be copied. They releases their resources when they are destroyed.
This separation follows the logic of the zenoh-c and zenoh-pico API. Owned zenoh-cpp types are the wrappers
for the corresponding ::z_owned_XXX_t
types. Copyable zenoh-cpp types are the wrappers for the
non-owned ::z_XXX_t
types.
-
template<typename ZC_COPYABLE_TYPE>
struct Copyable : public ZC_COPYABLE_TYPE Base type for C++ wrappers of Zenoh copyable structures, like GetOptions, PutOptions, etc.
- Template Parameters:
ZC_COPYABLE_TYPE – - zenoh-c structure type ::z_XXX_t
Subclassed by zenoh::_StrArrayView<::z_str_array_t >
Constructors
-
Copyable() = delete
Default constructor is deleted.
-
inline Copyable(ZC_COPYABLE_TYPE v)
Construct from wrapped zenoh-c / zenoh-pico structure.
-
template<typename ZC_OWNED_TYPE>
class Owned Base type for C++ wrappers of Zenoh owned structures
- Template Parameters:
ZC_OWNED_TYPE – - zenoh-c owned type ::z_owned_XXX_t
Subclassed by zenohcxx::ClosureMoveParam<::z_owned_closure_reply_t, ::z_owned_reply_t, zenoh::Reply >, zenohcxx::ClosureMoveParam<::z_owned_reply_channel_closure_t, ::z_owned_reply_t, zenoh::Reply >
Operators
-
inline explicit operator ZC_OWNED_TYPE&()
Get read/write direct access to wrapped zenoh structure.
-
inline explicit operator const ZC_OWNED_TYPE&() const
Get read only direct access to wrapped zenoh structure.
Constructors
-
Owned() = delete
Default constructor is deleted.
-
inline Owned(ZC_OWNED_TYPE *pv)
Creationg from non-constant pointer to structure is allowed. Ownership is taken, source structure is emptied. Creation of null owned object is also allowed by passing nullptr to constructor
-
inline Owned(ZC_OWNED_TYPE &&v)
Move constructor from wrapped value.
-
inline ~Owned()
Destructor drops owned value using z_drop from zenoh API.
Methods
-
inline void drop()
Explicit drop. Makes the object null.
-
inline ZC_OWNED_TYPE take()
Take zenoh structure and leave Owned object null.
-
inline void put(ZC_OWNED_TYPE &v)
Replace value with zenoh structure, dropping old value.
-
inline bool check() const
Check object validity uzing zenoh API.
-
template<typename ZC_LOAN_TYPE = decltype(::z_loan(*static_cast<const ZC_OWNED_TYPE*>(nullptr)))>
inline ZC_LOAN_TYPE loan() const Get zenoh-c loan structure
z_XXX_t
associated with owned objectz_owned_XXX_t
if the corresponding zenoh-c functionz_loan
is defined.- Returns:
zenoh-c loan structure
z_XXX_t