Skip to content

Commit

Permalink
Add RMW listener APIs
Browse files Browse the repository at this point in the history
Add set_guard_condition_callback api

Move apis - Add constness

Use or discard previous events: Guard conditions

Rename to set_events_executor_callback

Rename Event_callback -> ExecutorEventCallback

update name

Add events support

void return on set_events_executor_callback

Revert "void return on set_events_executor_callback"

Rename ExecutorEventCallback -> EventsExecutorCallback

Rename set_events_executor_callback->set_listener_callback

Use data types when setting callbacks

Move rcutils/executor_event_types.h to rmw/

rename event types

Rename executor_context->callback_context

Rename callback_context->user_data

Reorder APIs arguments

rename rmw_listener_cb_t->rmw_listener_callback_t

use void * to pass executor ptr

Rework executor callback data

Use RMW renamed file

Signed-off-by: Alberto Soragna <asoragna@irobot.com>
  • Loading branch information
Mauro authored and Alberto Soragna committed Mar 12, 2021
1 parent ce2a436 commit 0f3ec09
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 0 deletions.
10 changes: 10 additions & 0 deletions rcl/include/rcl/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ extern "C"
#include "rcl/node.h"
#include "rcl/visibility_control.h"

#include "rmw/listener_callback_type.h"

/// Internal rcl client implementation struct.
struct rcl_client_impl_t;

Expand Down Expand Up @@ -409,6 +411,14 @@ RCL_PUBLIC
bool
rcl_client_is_valid(const rcl_client_t * client);

RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_client_set_listener_callback(
const rcl_client_t * client,
rmw_listener_callback_t listener_callback,
const void * user_data);

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 9 additions & 0 deletions rcl/include/rcl/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,15 @@ RCL_PUBLIC
bool
rcl_event_is_valid(const rcl_event_t * event);

RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_event_set_listener_callback(
const rcl_event_t * event,
rmw_listener_callback_t listener_callback,
const void * user_data,
bool use_previous_events);

#ifdef __cplusplus
}
#endif
Expand Down
11 changes: 11 additions & 0 deletions rcl/include/rcl/guard_condition.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ extern "C"
#include "rcl/types.h"
#include "rcl/visibility_control.h"

#include "rmw/listener_callback_type.h"

/// Internal rcl guard condition implementation struct.
struct rcl_guard_condition_impl_t;

Expand Down Expand Up @@ -262,6 +264,15 @@ RCL_WARN_UNUSED
rmw_guard_condition_t *
rcl_guard_condition_get_rmw_handle(const rcl_guard_condition_t * guard_condition);

RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_guard_condition_set_listener_callback(
const rcl_guard_condition_t * guard_condition,
rmw_listener_callback_t listener_callback,
const void * user_data,
bool use_previous_events);

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 10 additions & 0 deletions rcl/include/rcl/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ extern "C"
#include "rcl/node.h"
#include "rcl/visibility_control.h"

#include "rmw/listener_callback_type.h"

/// Internal rcl implementation struct.
struct rcl_service_impl_t;

Expand Down Expand Up @@ -440,6 +442,14 @@ RCL_PUBLIC
bool
rcl_service_is_valid(const rcl_service_t * service);

RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_service_set_listener_callback(
const rcl_service_t * service,
rmw_listener_callback_t listener_callback,
const void * user_data);

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 9 additions & 0 deletions rcl/include/rcl/subscription.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern "C"
#include "rcl/node.h"
#include "rcl/visibility_control.h"

#include "rmw/listener_callback_type.h"
#include "rmw/message_sequence.h"

/// Internal rcl implementation struct.
Expand Down Expand Up @@ -611,6 +612,14 @@ RCL_PUBLIC
bool
rcl_subscription_can_loan_messages(const rcl_subscription_t * subscription);

RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_subscription_set_listener_callback(
const rcl_subscription_t * subscription,
rmw_listener_callback_t listener_callback,
const void * user_data);

#ifdef __cplusplus
}
#endif
Expand Down
13 changes: 13 additions & 0 deletions rcl/src/rcl/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,19 @@ rcl_client_is_valid(const rcl_client_t * client)
client->impl->rmw_handle, "client's rmw handle is invalid", return false);
return true;
}

rcl_ret_t
rcl_client_set_listener_callback(
const rcl_client_t * client,
rmw_listener_callback_t listener_callback,
const void * user_data)
{
return rmw_client_set_listener_callback(
client->impl->rmw_handle,
listener_callback,
user_data);
}

#ifdef __cplusplus
}
#endif
14 changes: 14 additions & 0 deletions rcl/src/rcl/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ rcl_event_is_valid(const rcl_event_t * event)
return true;
}

rcl_ret_t
rcl_event_set_listener_callback(
const rcl_event_t * event,
rmw_listener_callback_t listener_callback,
const void * user_data,
bool use_previous_events)
{
return rmw_event_set_listener_callback(
&event->impl->rmw_handle,
listener_callback,
user_data,
use_previous_events);
}

#ifdef __cplusplus
}
#endif
14 changes: 14 additions & 0 deletions rcl/src/rcl/guard_condition.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,20 @@ rcl_guard_condition_get_rmw_handle(const rcl_guard_condition_t * guard_condition
return guard_condition->impl->rmw_handle;
}

rcl_ret_t
rcl_guard_condition_set_listener_callback(
const rcl_guard_condition_t * guard_condition,
rmw_listener_callback_t listener_callback,
const void * user_data,
bool use_previous_events)
{
return rmw_guard_condition_set_listener_callback(
guard_condition->impl->rmw_handle,
listener_callback,
user_data,
use_previous_events);
}

#ifdef __cplusplus
}
#endif
13 changes: 13 additions & 0 deletions rcl/src/rcl/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,19 @@ rcl_service_is_valid(const rcl_service_t * service)
return true;
}

rcl_ret_t
rcl_service_set_listener_callback(
const rcl_service_t * service,
rmw_listener_callback_t listener_callback,
const void * user_data)
{
return rmw_service_set_listener_callback(
service->impl->rmw_handle,
listener_callback,
user_data);
}


#ifdef __cplusplus
}
#endif
12 changes: 12 additions & 0 deletions rcl/src/rcl/subscription.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,18 @@ rcl_subscription_can_loan_messages(const rcl_subscription_t * subscription)
return subscription->impl->rmw_handle->can_loan_messages;
}

rcl_ret_t
rcl_subscription_set_listener_callback(
const rcl_subscription_t * subscription,
rmw_listener_callback_t listener_callback,
const void * user_data)
{
return rmw_subscription_set_listener_callback(
subscription->impl->rmw_handle,
listener_callback,
user_data);
}

#ifdef __cplusplus
}
#endif

0 comments on commit 0f3ec09

Please sign in to comment.