Skip to content

Commit f57e64e

Browse files
iRobot ROSMauro Passerinoalsora
authored
Add rmw listener apis (#44)
* Add stubs for setting listener callbacks Signed-off-by: Mauro Passerino <[email protected]> * Address PR suggestions Signed-off-by: Mauro Passerino <[email protected]> * Fix linter issues Signed-off-by: Mauro Passerino <[email protected]> Co-authored-by: Mauro Passerino <[email protected]> Co-authored-by: Alberto Soragna <[email protected]>
1 parent 3bfb894 commit f57e64e

File tree

5 files changed

+185
-0
lines changed

5 files changed

+185
-0
lines changed

rmw_connextdds/src/rmw_api_impl_ndds.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ rmw_take_event(
120120
return rmw_api_connextdds_take_event(event_handle, event_info, taken);
121121
}
122122

123+
rmw_ret_t
124+
rmw_event_set_callback(
125+
rmw_event_t * event,
126+
rmw_event_callback_t callback,
127+
const void * user_data)
128+
{
129+
return rmw_api_connextdds_event_set_callback(event, callback, user_data);
130+
}
123131
/*****************************************************************************
124132
* Info API
125133
*****************************************************************************/
@@ -634,6 +642,27 @@ rmw_destroy_service(
634642
{
635643
return rmw_api_connextdds_destroy_service(node, service);
636644
}
645+
646+
rmw_ret_t
647+
rmw_service_set_on_new_request_callback(
648+
rmw_service_t * rmw_service,
649+
rmw_event_callback_t callback,
650+
const void * user_data)
651+
{
652+
return rmw_api_connextdds_service_set_on_new_request_callback(
653+
rmw_service, callback, user_data);
654+
}
655+
656+
rmw_ret_t
657+
rmw_client_set_on_new_response_callback(
658+
rmw_client_t * rmw_client,
659+
rmw_event_callback_t callback,
660+
const void * user_data)
661+
{
662+
return rmw_api_connextdds_client_set_on_new_response_callback(
663+
rmw_client, callback, user_data);
664+
}
665+
637666
/*****************************************************************************
638667
* Subscription API
639668
*****************************************************************************/
@@ -794,6 +823,16 @@ rmw_return_loaned_message_from_subscription(
794823
subscription, loaned_message);
795824
}
796825

826+
rmw_ret_t
827+
rmw_subscription_set_on_new_message_callback(
828+
rmw_subscription_t * rmw_subscription,
829+
rmw_event_callback_t callback,
830+
const void * user_data)
831+
{
832+
return rmw_api_connextdds_subscription_set_on_new_message_callback(
833+
rmw_subscription, callback, user_data);
834+
}
835+
797836
/*****************************************************************************
798837
* WaitSet API
799838
*****************************************************************************/

rmw_connextdds_common/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ set(RMW_CONNEXT_COMMON_SOURCE_CPP
132132
src/common/rmw_impl.cpp
133133
src/common/rmw_impl_waitset_std.cpp
134134
src/common/rmw_info.cpp
135+
src/common/rmw_listener.cpp
135136
src/common/rmw_node.cpp
136137
src/common/rmw_publication.cpp
137138
src/common/rmw_qos.cpp

rmw_connextdds_common/include/rmw_connextdds/rmw_api_impl.hpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ rmw_api_connextdds_take_event(
8686
void * event_info,
8787
bool * taken);
8888

89+
RMW_CONNEXTDDS_PUBLIC
90+
rmw_ret_t
91+
rmw_api_connextdds_event_set_callback(
92+
rmw_event_t * event,
93+
rmw_event_callback_t callback,
94+
const void * user_data);
95+
8996
/*****************************************************************************
9097
* Info API
9198
*****************************************************************************/
@@ -423,6 +430,21 @@ rmw_ret_t
423430
rmw_api_connextdds_destroy_service(
424431
rmw_node_t * node,
425432
rmw_service_t * service);
433+
434+
RMW_CONNEXTDDS_PUBLIC
435+
rmw_ret_t
436+
rmw_api_connextdds_service_set_on_new_request_callback(
437+
rmw_service_t * rmw_service,
438+
rmw_event_callback_t callback,
439+
const void * user_data);
440+
441+
RMW_CONNEXTDDS_PUBLIC
442+
rmw_ret_t
443+
rmw_api_connextdds_client_set_on_new_response_callback(
444+
rmw_client_t * rmw_client,
445+
rmw_event_callback_t callback,
446+
const void * user_data);
447+
426448
/*****************************************************************************
427449
* Subscription API
428450
*****************************************************************************/
@@ -535,6 +557,13 @@ rmw_api_connextdds_return_loaned_message_from_subscription(
535557
const rmw_subscription_t * subscription,
536558
void * loaned_message);
537559

560+
RMW_CONNEXTDDS_PUBLIC
561+
rmw_ret_t
562+
rmw_api_connextdds_subscription_set_on_new_message_callback(
563+
rmw_subscription_t * rmw_subscription,
564+
rmw_event_callback_t callback,
565+
const void * user_data);
566+
538567
/*****************************************************************************
539568
* WaitSet API
540569
*****************************************************************************/
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright 2021 Real-Time Innovations, Inc. (RTI)
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "rmw_connextdds/rmw_impl.hpp"
16+
17+
/******************************************************************************
18+
* Event Listener API
19+
******************************************************************************/
20+
rmw_ret_t
21+
rmw_api_connextdds_event_set_callback(
22+
rmw_event_t * event,
23+
rmw_event_callback_t callback,
24+
const void * user_data)
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;
31+
}
32+
33+
/******************************************************************************
34+
* Service Listener API
35+
******************************************************************************/
36+
rmw_ret_t
37+
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)
41+
{
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;
47+
}
48+
49+
rmw_ret_t
50+
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)
54+
{
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;
60+
}
61+
62+
/******************************************************************************
63+
* Subscription Listener API
64+
******************************************************************************/
65+
rmw_ret_t
66+
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)
70+
{
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;
76+
}

rmw_connextddsmicro/src/rmw_api_impl_rtime.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ rmw_take_event(
120120
return rmw_api_connextdds_take_event(event_handle, event_info, taken);
121121
}
122122

123+
rmw_ret_t
124+
rmw_event_set_callback(
125+
rmw_event_t * event,
126+
rmw_event_callback_t callback,
127+
const void * user_data)
128+
{
129+
return rmw_api_connextdds_event_set_callback(event, callback, user_data);
130+
}
131+
123132
/*****************************************************************************
124133
* Info API
125134
*****************************************************************************/
@@ -633,6 +642,27 @@ rmw_destroy_service(
633642
{
634643
return rmw_api_connextdds_destroy_service(node, service);
635644
}
645+
646+
rmw_ret_t
647+
rmw_service_set_on_new_request_callback(
648+
rmw_service_t * rmw_service,
649+
rmw_event_callback_t callback,
650+
const void * user_data)
651+
{
652+
return rmw_api_connextdds_service_set_on_new_request_callback(
653+
rmw_service, callback, user_data);
654+
}
655+
656+
rmw_ret_t
657+
rmw_client_set_on_new_response_callback(
658+
rmw_client_t * rmw_client,
659+
rmw_event_callback_t callback,
660+
const void * user_data)
661+
{
662+
return rmw_api_connextdds_client_set_on_new_response_callback(
663+
rmw_client, callback, user_data);
664+
}
665+
636666
/*****************************************************************************
637667
* Subscription API
638668
*****************************************************************************/
@@ -793,6 +823,16 @@ rmw_return_loaned_message_from_subscription(
793823
subscription, loaned_message);
794824
}
795825

826+
rmw_ret_t
827+
rmw_subscription_set_on_new_message_callback(
828+
rmw_subscription_t * rmw_subscription,
829+
rmw_event_callback_t callback,
830+
const void * user_data)
831+
{
832+
return rmw_api_connextdds_subscription_set_on_new_message_callback(
833+
rmw_subscription, callback, user_data);
834+
}
835+
796836
/*****************************************************************************
797837
* WaitSet API
798838
*****************************************************************************/

0 commit comments

Comments
 (0)