Program Listing for File event.h

Return to documentation for file (include/rmw/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 RMW__EVENT_H_
#define RMW__EVENT_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdint.h>

#include "rcutils/allocator.h"

#include "rmw/macros.h"
#include "rmw/types.h"
#include "rmw/ret_types.h"
#include "rmw/visibility_control.h"

typedef enum rmw_event_type_e
{
  // subscription events
  RMW_EVENT_LIVELINESS_CHANGED,
  RMW_EVENT_REQUESTED_DEADLINE_MISSED,
  RMW_EVENT_REQUESTED_QOS_INCOMPATIBLE,
  RMW_EVENT_MESSAGE_LOST,
  RMW_EVENT_SUBSCRIPTION_INCOMPATIBLE_TYPE,
  RMW_EVENT_SUBSCRIPTION_MATCHED,

  // publisher events
  RMW_EVENT_LIVELINESS_LOST,
  RMW_EVENT_OFFERED_DEADLINE_MISSED,
  RMW_EVENT_OFFERED_QOS_INCOMPATIBLE,
  RMW_EVENT_PUBLISHER_INCOMPATIBLE_TYPE,
  RMW_EVENT_PUBLICATION_MATCHED,

  // sentinel value
  RMW_EVENT_INVALID
} rmw_event_type_t;

typedef struct RMW_PUBLIC_TYPE rmw_event_s
{
  const char * implementation_identifier;
  void * data;
  rmw_event_type_t event_type;
} rmw_event_t;

RMW_PUBLIC
RMW_WARN_UNUSED
rmw_event_t
rmw_get_zero_initialized_event(void);


RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_publisher_event_init(
  rmw_event_t * rmw_event,
  const rmw_publisher_t * publisher,
  rmw_event_type_t event_type);


RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_subscription_event_init(
  rmw_event_t * rmw_event,
  const rmw_subscription_t * subscription,
  rmw_event_type_t event_type);


RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_take_event(
  const rmw_event_t * event_handle,
  void * event_info,
  bool * taken);


RMW_PUBLIC
RMW_WARN_UNUSED
rmw_ret_t
rmw_event_fini(rmw_event_t * event);

#ifdef __cplusplus
}
#endif

#endif  // RMW__EVENT_H_