27
27
#include "zenoh-pico/net/session.h"
28
28
#include "zenoh-pico/net/subscribe.h"
29
29
#include "zenoh-pico/protocol/core.h"
30
+ #include "zenoh-pico/utils/olv_macros.h"
30
31
31
32
#ifdef __cplusplus
32
33
extern "C" {
33
34
#endif
34
35
35
- /* Owned/Loaned types */
36
-
37
- // For pointer types
38
- #define _OWNED_TYPE_PTR (type , name ) \
39
- typedef struct { \
40
- type *_val; \
41
- } z_owned_##name##_t;
42
-
43
- // For refcounted types
44
- #define _OWNED_TYPE_RC (type , name ) \
45
- typedef struct { \
46
- type _rc; \
47
- } z_owned_##name##_t;
48
-
49
- #define _LOANED_TYPE (type , name ) typedef type z_loaned_##name##_t;
50
-
51
- #define _VIEW_TYPE (type , name ) \
52
- typedef struct { \
53
- type _val; \
54
- } z_view_##name##_t;
55
-
56
36
/**
57
37
* Represents a variable-length encoding unsigned integer.
58
38
*
@@ -82,17 +62,17 @@ typedef _z_timestamp_t z_timestamp_t;
82
62
* size_t len: The length of the bytes array.
83
63
* uint8_t *start: A pointer to the bytes array.
84
64
*/
85
- _OWNED_TYPE_PTR (_z_slice_t , slice )
86
- _LOANED_TYPE (_z_slice_t , slice )
65
+ _Z_OWNED_TYPE_PTR (_z_slice_t , slice )
66
+ _Z_LOANED_TYPE (_z_slice_t , slice )
87
67
88
68
/**
89
69
* Represents a container for slices.
90
70
*
91
71
* Members:
92
72
* _z_slice_t slice: content of the container.
93
73
*/
94
- _OWNED_TYPE_PTR (_z_bytes_t , bytes )
95
- _LOANED_TYPE (_z_bytes_t , bytes )
74
+ _Z_OWNED_TYPE_PTR (_z_bytes_t , bytes )
75
+ _Z_LOANED_TYPE (_z_bytes_t , bytes )
96
76
97
77
/**
98
78
* Represents a string without null-terminator.
@@ -101,9 +81,9 @@ _LOANED_TYPE(_z_bytes_t, bytes)
101
81
* size_t len: The length of the string.
102
82
* const char *val: A pointer to the string.
103
83
*/
104
- _OWNED_TYPE_PTR (_z_string_t , string )
105
- _LOANED_TYPE (_z_string_t , string )
106
- _VIEW_TYPE (_z_string_t , string )
84
+ _Z_OWNED_TYPE_PTR (_z_string_t , string )
85
+ _Z_LOANED_TYPE (_z_string_t , string )
86
+ _Z_VIEW_TYPE (_z_string_t , string )
107
87
108
88
/**
109
89
* Represents a key expression in Zenoh.
@@ -115,9 +95,9 @@ _VIEW_TYPE(_z_string_t, string)
115
95
* - :c:func:`z_keyexpr_to_string`
116
96
* - :c:func:`zp_keyexpr_resolve`
117
97
*/
118
- _OWNED_TYPE_PTR (_z_keyexpr_t , keyexpr )
119
- _LOANED_TYPE (_z_keyexpr_t , keyexpr )
120
- _VIEW_TYPE (_z_keyexpr_t , keyexpr )
98
+ _Z_OWNED_TYPE_PTR (_z_keyexpr_t , keyexpr )
99
+ _Z_LOANED_TYPE (_z_keyexpr_t , keyexpr )
100
+ _Z_VIEW_TYPE (_z_keyexpr_t , keyexpr )
121
101
122
102
/**
123
103
* Represents a Zenoh configuration, used to configure Zenoh sessions upon opening.
@@ -129,8 +109,8 @@ _VIEW_TYPE(_z_keyexpr_t, keyexpr)
129
109
* - :c:func:`zp_config_get`
130
110
* - :c:func:`zp_config_insert`
131
111
*/
132
- _OWNED_TYPE_PTR (_z_config_t , config )
133
- _LOANED_TYPE (_z_config_t , config )
112
+ _Z_OWNED_TYPE_PTR (_z_config_t , config )
113
+ _Z_LOANED_TYPE (_z_config_t , config )
134
114
135
115
/**
136
116
* Represents a scouting configuration, used to configure a scouting procedure.
@@ -142,14 +122,14 @@ _LOANED_TYPE(_z_config_t, config)
142
122
* - :c:func:`zp_scouting_config_get`
143
123
* - :c:func:`zp_scouting_config_insert`
144
124
*/
145
- _OWNED_TYPE_PTR (_z_scouting_config_t , scouting_config )
146
- _LOANED_TYPE (_z_scouting_config_t , scouting_config )
125
+ _Z_OWNED_TYPE_PTR (_z_scouting_config_t , scouting_config )
126
+ _Z_LOANED_TYPE (_z_scouting_config_t , scouting_config )
147
127
148
128
/**
149
129
* Represents a Zenoh Session.
150
130
*/
151
- _OWNED_TYPE_RC (_z_session_rc_t , session )
152
- _LOANED_TYPE (_z_session_rc_t , session )
131
+ _Z_OWNED_TYPE_RC (_z_session_rc_t , session )
132
+ _Z_LOANED_TYPE (_z_session_rc_t , session )
153
133
154
134
/**
155
135
* Represents a Zenoh Subscriber entity.
@@ -159,8 +139,8 @@ _LOANED_TYPE(_z_session_rc_t, session)
159
139
* - :c:func:`z_declare_subscriber`
160
140
* - :c:func:`z_undeclare_subscriber`
161
141
*/
162
- _OWNED_TYPE_PTR (_z_subscriber_t , subscriber )
163
- _LOANED_TYPE (_z_subscriber_t , subscriber )
142
+ _Z_OWNED_TYPE_PTR (_z_subscriber_t , subscriber )
143
+ _Z_LOANED_TYPE (_z_subscriber_t , subscriber )
164
144
165
145
/**
166
146
* Represents a Zenoh Publisher entity.
@@ -172,8 +152,8 @@ _LOANED_TYPE(_z_subscriber_t, subscriber)
172
152
* - :c:func:`z_publisher_put`
173
153
* - :c:func:`z_publisher_delete`
174
154
*/
175
- _OWNED_TYPE_PTR (_z_publisher_t , publisher )
176
- _LOANED_TYPE (_z_publisher_t , publisher )
155
+ _Z_OWNED_TYPE_PTR (_z_publisher_t , publisher )
156
+ _Z_LOANED_TYPE (_z_publisher_t , publisher )
177
157
178
158
/**
179
159
* Represents a Zenoh Queryable entity.
@@ -183,15 +163,15 @@ _LOANED_TYPE(_z_publisher_t, publisher)
183
163
* - :c:func:`z_declare_queryable`
184
164
* - :c:func:`z_undeclare_queryable`
185
165
*/
186
- _OWNED_TYPE_PTR (_z_queryable_t , queryable )
187
- _LOANED_TYPE (_z_queryable_t , queryable )
166
+ _Z_OWNED_TYPE_PTR (_z_queryable_t , queryable )
167
+ _Z_LOANED_TYPE (_z_queryable_t , queryable )
188
168
189
169
/**
190
170
* Represents a Zenoh Query entity, received by Zenoh Queryable entities.
191
171
*
192
172
*/
193
- _OWNED_TYPE_RC (_z_query_rc_t , query )
194
- _LOANED_TYPE (_z_query_rc_t , query )
173
+ _Z_OWNED_TYPE_RC (_z_query_rc_t , query )
174
+ _Z_LOANED_TYPE (_z_query_rc_t , query )
195
175
196
176
/**
197
177
* Represents the encoding of a payload, in a MIME-like format.
@@ -200,8 +180,8 @@ _LOANED_TYPE(_z_query_rc_t, query)
200
180
* z_encoding_id_t prefix: The integer prefix of this encoding.
201
181
* z_loaned_slice_t* suffix: The suffix of this encoding. It MUST be a valid UTF-8 string.
202
182
*/
203
- _OWNED_TYPE_PTR (_z_encoding_t , encoding )
204
- _LOANED_TYPE (_z_encoding_t , encoding )
183
+ _Z_OWNED_TYPE_PTR (_z_encoding_t , encoding )
184
+ _Z_LOANED_TYPE (_z_encoding_t , encoding )
205
185
206
186
/**
207
187
* Represents a Zenoh value.
@@ -210,8 +190,8 @@ _LOANED_TYPE(_z_encoding_t, encoding)
210
190
* z_loaned_encoding_t encoding: The encoding of the `payload`.
211
191
* z_loaned_bytes_t* payload: The payload of this zenoh value.
212
192
*/
213
- _OWNED_TYPE_PTR (_z_value_t , value )
214
- _LOANED_TYPE (_z_value_t , value )
193
+ _Z_OWNED_TYPE_PTR (_z_value_t , value )
194
+ _Z_LOANED_TYPE (_z_value_t , value )
215
195
216
196
/**
217
197
* Represents the configuration used to configure a subscriber upon declaration :c:func:`z_declare_subscriber`.
@@ -422,8 +402,8 @@ static inline z_qos_t z_qos_default(void) { return _Z_N_QOS_DEFAULT; }
422
402
* z_timestamp_t timestamp: The timestamp of this data sample.
423
403
* z_qos_t qos: Quality of service settings used to deliver this sample.
424
404
*/
425
- _OWNED_TYPE_RC (_z_sample_rc_t , sample )
426
- _LOANED_TYPE (_z_sample_rc_t , sample )
405
+ _Z_OWNED_TYPE_RC (_z_sample_rc_t , sample )
406
+ _Z_LOANED_TYPE (_z_sample_rc_t , sample )
427
407
428
408
/**
429
409
* Represents the content of a `hello` message returned by a zenoh entity as a reply to a `scout` message.
@@ -433,14 +413,14 @@ _LOANED_TYPE(_z_sample_rc_t, sample)
433
413
* z_loaned_slice_t* zid: The Zenoh ID of the scouted entity (empty if absent).
434
414
* z_loaned_string_array_t locators: The locators of the scouted entity.
435
415
*/
436
- _OWNED_TYPE_PTR (_z_hello_t , hello )
437
- _LOANED_TYPE (_z_hello_t , hello )
416
+ _Z_OWNED_TYPE_PTR (_z_hello_t , hello )
417
+ _Z_LOANED_TYPE (_z_hello_t , hello )
438
418
439
419
/**
440
420
* Represents the reply to a query.
441
421
*/
442
- _OWNED_TYPE_RC (_z_reply_rc_t , reply )
443
- _LOANED_TYPE (_z_reply_rc_t , reply )
422
+ _Z_OWNED_TYPE_RC (_z_reply_rc_t , reply )
423
+ _Z_LOANED_TYPE (_z_reply_rc_t , reply )
444
424
445
425
/**
446
426
* Represents an array of non null-terminated string.
@@ -451,9 +431,9 @@ _LOANED_TYPE(_z_reply_rc_t, reply)
451
431
* - :c:func:`z_string_array_len`
452
432
* - :c:func:`z_str_array_array_is_empty`
453
433
*/
454
- _OWNED_TYPE_PTR (_z_string_vec_t , string_array )
455
- _LOANED_TYPE (_z_string_vec_t , string_array )
456
- _VIEW_TYPE (_z_string_vec_t , string_array )
434
+ _Z_OWNED_TYPE_PTR (_z_string_vec_t , string_array )
435
+ _Z_LOANED_TYPE (_z_string_vec_t , string_array )
436
+ _Z_VIEW_TYPE (_z_string_vec_t , string_array )
457
437
458
438
const z_loaned_string_t * z_string_array_get (const z_loaned_string_array_t * a , size_t k );
459
439
size_t z_string_array_len (const z_loaned_string_array_t * a );
0 commit comments