ROS 2 rclcpp + rcl - rolling  rolling-e7363f10
ROS 2 C++ Client Library with ROS Client Library
event.h
Go to the documentation of this file.
1 // Copyright 2019 Open Source Robotics Foundation, Inc.
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 
16 
17 #ifndef RCL__EVENT_H_
18 #define RCL__EVENT_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include <stdbool.h>
26 
27 #include <rmw/event.h>
28 
29 #include "rcl/client.h"
30 #include "rcl/event_callback.h"
31 #include "rcl/macros.h"
32 #include "rcl/publisher.h"
33 #include "rcl/service.h"
34 #include "rcl/subscription.h"
35 #include "rcl/types.h"
36 #include "rcl/visibility_control.h"
37 
40 {
41  RCL_PUBLISHER_OFFERED_DEADLINE_MISSED,
42  RCL_PUBLISHER_LIVELINESS_LOST,
43  RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS,
44  RCL_PUBLISHER_INCOMPATIBLE_TYPE,
45  RCL_PUBLISHER_MATCHED,
47 
50 {
51  RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED,
52  RCL_SUBSCRIPTION_LIVELINESS_CHANGED,
53  RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS,
54  RCL_SUBSCRIPTION_MESSAGE_LOST,
55  RCL_SUBSCRIPTION_INCOMPATIBLE_TYPE,
56  RCL_SUBSCRIPTION_MATCHED,
58 
60 typedef struct rcl_event_impl_s rcl_event_impl_t;
61 
63 typedef struct rcl_event_s
64 {
68 
70 
76 RCL_PUBLIC
77 RCL_WARN_UNUSED
80 
82 
94 RCL_PUBLIC
95 RCL_WARN_UNUSED
98  rcl_event_t * event,
99  const rcl_publisher_t * publisher,
100  const rcl_publisher_event_type_t event_type);
101 
103 
115 RCL_PUBLIC
116 RCL_WARN_UNUSED
117 rcl_ret_t
119  rcl_event_t * event,
120  const rcl_subscription_t * subscription,
121  const rcl_subscription_event_type_t event_type);
122 
123 // Take event using the event handle.
135 RCL_PUBLIC
136 RCL_WARN_UNUSED
137 rcl_ret_t
139  const rcl_event_t * event,
140  void * event_info);
141 
142 // Finalize an event.
151 RCL_PUBLIC
152 RCL_WARN_UNUSED
153 rcl_ret_t
154 rcl_event_fini(rcl_event_t * event);
155 
157 
182 RCL_PUBLIC
183 RCL_WARN_UNUSED
184 rmw_event_t *
186 
188 
205 RCL_PUBLIC
206 bool
207 rcl_event_is_valid(const rcl_event_t * event);
208 
210 
227 RCL_PUBLIC
228 RCL_WARN_UNUSED
229 bool
231  const rcl_publisher_event_type_t event_type);
232 
234 
251 RCL_PUBLIC
252 RCL_WARN_UNUSED
253 bool
255  const rcl_subscription_event_type_t event_type);
256 
258 
280 RCL_PUBLIC
281 RCL_WARN_UNUSED
282 rcl_ret_t
284  const rcl_event_t * event,
285  rcl_event_callback_t callback,
286  const void * user_data);
287 
288 #ifdef __cplusplus
289 }
290 #endif
291 
292 #endif // RCL__EVENT_H_
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_take_event(const rcl_event_t *event, void *event_info)
Definition: event.c:169
struct rcl_event_s rcl_event_t
Structure which encapsulates a ROS QoS event handle.
enum rcl_publisher_event_type_e rcl_publisher_event_type_t
Enumeration of all of the publisher events that may fire.
RCL_PUBLIC RCL_WARN_UNUSED rcl_event_t rcl_get_zero_initialized_event(void)
Return a rcl_event_t struct with members set to NULL.
Definition: event.c:42
rcl_subscription_event_type_e
Enumeration of all of the subscription events that may fire.
Definition: event.h:50
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_event_set_callback(const rcl_event_t *event, rcl_event_callback_t callback, const void *user_data)
Set the callback function for the event.
Definition: event.c:299
enum rcl_subscription_event_type_e rcl_subscription_event_type_t
Enumeration of all of the subscription events that may fire.
RCL_PUBLIC RCL_WARN_UNUSED rmw_event_t * rcl_event_get_rmw_handle(const rcl_event_t *event)
Return the rmw event handle.
Definition: event.c:216
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_subscription_event_init(rcl_event_t *event, const rcl_subscription_t *subscription, const rcl_subscription_event_type_t event_type)
Initialize an rcl_event_t with a subscription.
Definition: event.c:108
RCL_PUBLIC RCL_WARN_UNUSED bool rcl_subscription_event_type_is_supported(const rcl_subscription_event_type_t event_type)
Check if a subscription event type is supported by the active RMW implementation.
Definition: event.c:268
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_event_fini(rcl_event_t *event)
Definition: event.c:194
RCL_PUBLIC bool rcl_event_is_valid(const rcl_event_t *event)
Check that the event is valid.
Definition: event.c:226
RCL_PUBLIC RCL_WARN_UNUSED rcl_ret_t rcl_publisher_event_init(rcl_event_t *event, const rcl_publisher_t *publisher, const rcl_publisher_event_type_t event_type)
Initialize an rcl_event_t with a publisher.
Definition: event.c:50
rcl_publisher_event_type_e
Enumeration of all of the publisher events that may fire.
Definition: event.h:40
RCL_PUBLIC RCL_WARN_UNUSED bool rcl_publisher_event_type_is_supported(const rcl_publisher_event_type_t event_type)
Check if a publisher event type is supported by the active RMW implementation.
Definition: event.c:240
Structure which encapsulates a ROS QoS event handle.
Definition: event.h:64
rcl_event_impl_t * impl
Pointer to the event implementation.
Definition: event.h:66
Structure which encapsulates a ROS Publisher.
Definition: publisher.h:44
Structure which encapsulates a ROS Subscription.
Definition: subscription.h:48
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:25