Skip to content

Commit

Permalink
Rename z_publisher_declare to z_declare_publisher and make session first
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Oct 10, 2024
1 parent e43f9ff commit 5f04746
Show file tree
Hide file tree
Showing 27 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ Functions
.. autocfunction:: primitives.h::z_put
.. autocfunction:: primitives.h::z_delete
.. autocfunction:: primitives.h::z_publisher_declare
.. autocfunction:: primitives.h::z_declare_publisher
.. autocfunction:: primitives.h::z_publisher_put
.. autocfunction:: primitives.h::z_publisher_delete
.. autocfunction:: primitives.h::z_publisher_keyexpr
Expand Down
2 changes: 1 addition & 1 deletion examples/arduino/z_pub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void setup() {
Serial.println("...");
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
if (z_publisher_declare(&pub, z_session_loan(&s), z_view_keyexpr_loan(&ke), NULL) < 0) {
if (z_declare_publisher(z_session_loan(&s), &pub, z_view_keyexpr_loan(&ke), NULL) < 0) {
Serial.println("Unable to declare publisher for key expression!");
while (1) {
;
Expand Down
2 changes: 1 addition & 1 deletion examples/espidf/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void app_main() {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
exit(-1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void app_main(void) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void app_main(void) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/mbed/z_pub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
if (z_publisher_declare(&pub, z_session_loan(&s), z_view_keyexpr_loan(&ke), NULL) < 0) {
if (z_declare_publisher(z_session_loan(&s), &pub, z_view_keyexpr_loan(&ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
exit(-1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int main(int argc, char** argv) {
z_view_keyexpr_from_str_unchecked(&pong, "test/pong");

z_owned_publisher_t pub;
if (z_publisher_declare(&pub, z_loan(session), z_loan(ping), NULL) < 0) {
if (z_declare_publisher(z_loan(session), &pub, z_loan(ping), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char** argv) {
z_view_keyexpr_t pong;
z_view_keyexpr_from_str_unchecked(&pong, "test/pong");
z_owned_publisher_t pub;
if (z_publisher_declare(&pub, z_loan(session), z_loan(pong), NULL) < 0) {
if (z_declare_publisher(z_loan(session), &pub, z_loan(pong), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_pub_attachment.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int main(int argc, char **argv) {
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
z_owned_publisher_t pub;
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c11/z_pub_thr.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
exit(-1);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c99/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char** argv) {
z_view_keyexpr_t ping;
z_view_keyexpr_from_str_unchecked(&ping, "test/ping");
z_owned_publisher_t pub;
if (z_publisher_declare(&pub, z_session_loan(&session), z_view_keyexpr_loan(&ping), NULL) < 0) {
if (z_declare_publisher(z_session_loan(&session), &pub, z_view_keyexpr_loan(&ping), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c99/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main(int argc, char** argv) {
z_view_keyexpr_t pong;
z_view_keyexpr_from_str_unchecked(&pong, "test/pong");
z_owned_publisher_t pub;
if (z_publisher_declare(&pub, z_session_loan(&session), z_view_keyexpr_loan(&pong), NULL) < 0) {
if (z_declare_publisher(z_session_loan(&session), &pub, z_view_keyexpr_loan(&pong), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c99/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
if (z_publisher_declare(&pub, z_session_loan(&s), z_view_keyexpr_loan(&ke), NULL) < 0) {
if (z_declare_publisher(z_session_loan(&s), &pub, z_view_keyexpr_loan(&ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/unix/c99/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
if (z_publisher_declare(&pub, z_session_loan(&s), z_view_keyexpr_loan(&ke), NULL) < 0) {
if (z_declare_publisher(z_session_loan(&s), &pub, z_view_keyexpr_loan(&ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char** argv) {
z_view_keyexpr_t ping;
z_view_keyexpr_from_str_unchecked(&ping, "test/ping");
z_owned_publisher_t pub;
if (z_publisher_declare(&pub, z_loan(session), z_loan(ping), NULL) < 0) {
if (z_declare_publisher(z_loan(session), &pub, z_loan(ping), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_pong.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main(int argc, char** argv) {
z_view_keyexpr_t pong;
z_view_keyexpr_from_str_unchecked(&pong, "test/pong");
z_owned_publisher_t pub;
if (z_publisher_declare(&pub, z_loan(session), z_loan(pong), NULL) < 0) {
if (z_declare_publisher(z_loan(session), &pub, z_loan(pong), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/windows/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/zephyr/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int main(int argc, char **argv) {
z_view_keyexpr_t ke;
z_view_keyexpr_from_str_unchecked(&ke, KEYEXPR);
z_owned_publisher_t pub;
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
exit(-1);
}
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/api/primitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -1569,15 +1569,15 @@ void z_publisher_options_default(z_publisher_options_t *options);
* :c:func:`z_publisher_put` and :c:func:`z_publisher_delete` functions.
*
* Parameters:
* pub: Pointer to an uninitialized :c:type:`z_owned_publisher_t`.
* zs: Pointer to a :c:type:`z_loaned_session_t` to declare the publisher through.
* pub: Pointer to an uninitialized :c:type:`z_owned_publisher_t`.
* keyexpr: Pointer to a :c:type:`z_loaned_keyexpr_t` to bind the publisher with.
* options: Pointer to a :c:type:`z_publisher_options_t` to configure the operation.
*
* Return:
* ``0`` if declare is successful, ``negative value`` otherwise.
*/
z_result_t z_publisher_declare(z_owned_publisher_t *pub, const z_loaned_session_t *zs,
z_result_t z_declare_publisher(const z_loaned_session_t *zs, z_owned_publisher_t *pub,
const z_loaned_keyexpr_t *keyexpr, const z_publisher_options_t *options);

/**
Expand Down
4 changes: 2 additions & 2 deletions include/zenoh-pico/api/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ typedef struct {
} z_query_consolidation_t;

/**
* Represents the configuration used to configure a publisher upon declaration with :c:func:`z_publisher_declare`.
* Represents the configuration used to configure a publisher upon declaration with :c:func:`z_declare_publisher`.
*
* Members:
* z_owned_encoding_t *encoding: Default encoding for messages put by this publisher.
Expand Down Expand Up @@ -386,7 +386,7 @@ typedef struct {
} zp_send_join_options_t;

/**
* Represents the configuration used to configure a publisher upon declaration with :c:func:`z_publisher_declare`.
* Represents the configuration used to configure a publisher upon declaration with :c:func:`z_declare_publisher`.
*
* Members:
* uint64_t timeout_ms: The maximum duration in ms the scouting can take.
Expand Down
2 changes: 1 addition & 1 deletion src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ void z_publisher_options_default(z_publisher_options_t *options) {
#endif
}

z_result_t z_publisher_declare(z_owned_publisher_t *pub, const z_loaned_session_t *zs,
z_result_t z_declare_publisher(const z_loaned_session_t *zs, z_owned_publisher_t *pub,
const z_loaned_keyexpr_t *keyexpr, const z_publisher_options_t *options) {
_z_keyexpr_t keyexpr_aliased = _z_keyexpr_alias_from_user_defined(*keyexpr, true);
_z_keyexpr_t key = keyexpr_aliased;
Expand Down
2 changes: 1 addition & 1 deletion tests/z_api_alignment_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ int main(int argc, char **argv) {
_ret_pub_opt.encoding = z_move(encoding);
_ret_pub_opt.congestion_control = Z_CONGESTION_CONTROL_BLOCK;
z_owned_publisher_t _ret_pub;
_ret_res = z_publisher_declare(&_ret_pub, z_loan(s1), z_loan(s1_key), &_ret_pub_opt);
_ret_res = z_declare_publisher(z_loan(s1), &_ret_pub, z_loan(s1_key), &_ret_pub_opt);
assert(_ret_res == _Z_RES_OK);
assert(!z_internal_check(encoding));
printf("Ok\n");
Expand Down
2 changes: 1 addition & 1 deletion tests/z_client_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ int main(int argc, char **argv) {
// Declare publisher on first session
for (unsigned int i = 0; i < SET; i++) {
z_owned_publisher_t *pub = (z_owned_publisher_t *)z_malloc(sizeof(z_owned_publisher_t));
if (z_publisher_declare(pub, z_loan(s1), z_loan(rids1[i]), NULL) < 0) {
if (z_declare_publisher(z_loan(s1), pub, z_loan(rids1[i]), NULL) < 0) {
printf("Declared publisher on session 1: %zu\n", z_loan(*pub)->_id);
}
pubs1 = _z_list_push(pubs1, pub);
Expand Down
2 changes: 1 addition & 1 deletion tests/z_perf_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int main(int argc, char **argv) {
z_owned_publisher_t pub;
z_view_keyexpr_t ke;
z_view_keyexpr_from_str(&ke, keyexpr);
if (z_publisher_declare(&pub, z_loan(s), z_loan(ke), NULL) < 0) {
if (z_declare_publisher(z_loan(s), &pub, z_loan(ke), NULL) < 0) {
printf("Unable to declare publisher for key expression!\n");
exit(-1);
}
Expand Down

0 comments on commit 5f04746

Please sign in to comment.