|
19 | 19 | ******************************************************************************/
|
20 | 20 | rmw_ret_t
|
21 | 21 | rmw_api_connextdds_event_set_callback(
|
22 |
| - rmw_event_t * event, |
23 |
| - rmw_event_callback_t callback, |
24 |
| - const void * user_data) |
| 22 | + rmw_event_t * const event, |
| 23 | + const rmw_event_callback_t callback, |
| 24 | + const void * const user_data) |
25 | 25 | {
|
26 |
| - UNUSED_ARG(event); |
27 |
| - UNUSED_ARG(callback); |
28 |
| - UNUSED_ARG(user_data); |
29 |
| - RMW_CONNEXT_LOG_ERROR_SET("rmw_event_set_callback not implemented") |
30 |
| - return RMW_RET_UNSUPPORTED; |
| 26 | + RMW_CHECK_ARGUMENT_FOR_NULL(event, RMW_RET_INVALID_ARGUMENT); |
| 27 | + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( |
| 28 | + event, |
| 29 | + event->implementation_identifier, |
| 30 | + RMW_CONNEXTDDS_ID, |
| 31 | + return RMW_RET_INVALID_ARGUMENT); |
| 32 | + |
| 33 | + RMW_Connext_StatusCondition * condition = nullptr; |
| 34 | + if (RMW_Connext_Event::reader_event(event)) { |
| 35 | + condition = RMW_Connext_Event::subscriber(event)->condition(); |
| 36 | + } else { |
| 37 | + condition = RMW_Connext_Event::publisher(event)->condition(); |
| 38 | + } |
| 39 | + condition->set_new_event_callback(callback, user_data); |
| 40 | + return RMW_RET_OK; |
31 | 41 | }
|
32 | 42 |
|
33 | 43 | /******************************************************************************
|
34 | 44 | * Service Listener API
|
35 | 45 | ******************************************************************************/
|
36 | 46 | rmw_ret_t
|
37 | 47 | rmw_api_connextdds_service_set_on_new_request_callback(
|
38 |
| - rmw_service_t * rmw_service, |
39 |
| - rmw_event_callback_t callback, |
40 |
| - const void * user_data) |
| 48 | + rmw_service_t * const service, |
| 49 | + const rmw_event_callback_t callback, |
| 50 | + const void * const user_data) |
41 | 51 | {
|
42 |
| - UNUSED_ARG(rmw_service); |
43 |
| - UNUSED_ARG(callback); |
44 |
| - UNUSED_ARG(user_data); |
45 |
| - RMW_CONNEXT_LOG_ERROR_SET("rmw_service_set_on_new_request_callback not implemented") |
46 |
| - return RMW_RET_UNSUPPORTED; |
| 52 | + RMW_CHECK_ARGUMENT_FOR_NULL(service, RMW_RET_INVALID_ARGUMENT); |
| 53 | + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( |
| 54 | + service, |
| 55 | + service->implementation_identifier, |
| 56 | + RMW_CONNEXTDDS_ID, |
| 57 | + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); |
| 58 | + |
| 59 | + RMW_Connext_Service * const svc_impl = |
| 60 | + reinterpret_cast<RMW_Connext_Service *>(service->data); |
| 61 | + svc_impl->subscriber()->condition()->set_on_new_data_callback(callback, user_data); |
| 62 | + return RMW_RET_OK; |
47 | 63 | }
|
48 | 64 |
|
49 | 65 | rmw_ret_t
|
50 | 66 | rmw_api_connextdds_client_set_on_new_response_callback(
|
51 |
| - rmw_client_t * rmw_client, |
52 |
| - rmw_event_callback_t callback, |
53 |
| - const void * user_data) |
| 67 | + rmw_client_t * const client, |
| 68 | + const rmw_event_callback_t callback, |
| 69 | + const void * const user_data) |
54 | 70 | {
|
55 |
| - UNUSED_ARG(rmw_client); |
56 |
| - UNUSED_ARG(callback); |
57 |
| - UNUSED_ARG(user_data); |
58 |
| - RMW_CONNEXT_LOG_ERROR_SET("rmw_client_set_on_new_response_callback not implemented") |
59 |
| - return RMW_RET_UNSUPPORTED; |
| 71 | + RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT); |
| 72 | + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( |
| 73 | + client, |
| 74 | + client->implementation_identifier, |
| 75 | + RMW_CONNEXTDDS_ID, |
| 76 | + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); |
| 77 | + |
| 78 | + RMW_Connext_Client * const client_impl = |
| 79 | + reinterpret_cast<RMW_Connext_Client *>(client->data); |
| 80 | + client_impl->subscriber()->condition()->set_on_new_data_callback(callback, user_data); |
| 81 | + return RMW_RET_OK; |
60 | 82 | }
|
61 | 83 |
|
62 | 84 | /******************************************************************************
|
63 | 85 | * Subscription Listener API
|
64 | 86 | ******************************************************************************/
|
65 | 87 | rmw_ret_t
|
66 | 88 | rmw_api_connextdds_subscription_set_on_new_message_callback(
|
67 |
| - rmw_subscription_t * rmw_subscription, |
68 |
| - rmw_event_callback_t callback, |
69 |
| - const void * user_data) |
| 89 | + rmw_subscription_t * const subscription, |
| 90 | + const rmw_event_callback_t callback, |
| 91 | + const void * const user_data) |
70 | 92 | {
|
71 |
| - UNUSED_ARG(rmw_subscription); |
72 |
| - UNUSED_ARG(callback); |
73 |
| - UNUSED_ARG(user_data); |
74 |
| - RMW_CONNEXT_LOG_ERROR_SET("rmw_subscription_set_on_new_message_callback not implemented") |
75 |
| - return RMW_RET_UNSUPPORTED; |
| 93 | + RMW_CHECK_ARGUMENT_FOR_NULL(subscription, RMW_RET_INVALID_ARGUMENT); |
| 94 | + RMW_CHECK_TYPE_IDENTIFIERS_MATCH( |
| 95 | + subscription, |
| 96 | + subscription->implementation_identifier, |
| 97 | + RMW_CONNEXTDDS_ID, |
| 98 | + return RMW_RET_INCORRECT_RMW_IMPLEMENTATION); |
| 99 | + |
| 100 | + RMW_Connext_Subscriber * const sub_impl = |
| 101 | + reinterpret_cast<RMW_Connext_Subscriber *>(subscription->data); |
| 102 | + sub_impl->condition()->set_on_new_data_callback(callback, user_data); |
| 103 | + return RMW_RET_OK; |
76 | 104 | }
|
0 commit comments