Program Listing for File event.h

Return to documentation for file (include/rcl/event.h)

// Copyright 2019 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


#ifndef RCL__EVENT_H_
#define RCL__EVENT_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <rmw/event.h>

#include "rcl/client.h"
#include "rcl/event_callback.h"
#include "rcl/macros.h"
#include "rcl/publisher.h"
#include "rcl/service.h"
#include "rcl/subscription.h"
#include "rcl/visibility_control.h"

typedef enum rcl_publisher_event_type_e
{
  RCL_PUBLISHER_OFFERED_DEADLINE_MISSED,
  RCL_PUBLISHER_LIVELINESS_LOST,
  RCL_PUBLISHER_OFFERED_INCOMPATIBLE_QOS,
  RCL_PUBLISHER_INCOMPATIBLE_TYPE,
  RCL_PUBLISHER_MATCHED,
} rcl_publisher_event_type_t;

typedef enum rcl_subscription_event_type_e
{
  RCL_SUBSCRIPTION_REQUESTED_DEADLINE_MISSED,
  RCL_SUBSCRIPTION_LIVELINESS_CHANGED,
  RCL_SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS,
  RCL_SUBSCRIPTION_MESSAGE_LOST,
  RCL_SUBSCRIPTION_INCOMPATIBLE_TYPE,
  RCL_SUBSCRIPTION_MATCHED,
} rcl_subscription_event_type_t;

typedef struct rcl_event_impl_s rcl_event_impl_t;

typedef struct rcl_event_s
{
  rcl_event_impl_t * impl;
} rcl_event_t;


RCL_PUBLIC
RCL_WARN_UNUSED
rcl_event_t
rcl_get_zero_initialized_event(void);


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);


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);

// Take event using the event handle.
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_take_event(
  const rcl_event_t * event,
  void * event_info);

// Finalize an event.
RCL_PUBLIC
RCL_WARN_UNUSED
rcl_ret_t
rcl_event_fini(rcl_event_t * event);


RCL_PUBLIC
RCL_WARN_UNUSED
rmw_event_t *
rcl_event_get_rmw_handle(const rcl_event_t * event);


RCL_PUBLIC
bool
rcl_event_is_valid(const rcl_event_t * event);


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);

#ifdef __cplusplus
}
#endif

#endif  // RCL__EVENT_H_