// generated from rosidl_typesupport_fastrtps_c/resource/idl__type_support_c.cpp.em
// with input from interface_protocol:msg/JointMotionPlanRequest.idl
// generated code does not contain a copyright notice
#include "interface_protocol/msg/detail/joint_motion_plan_request__rosidl_typesupport_fastrtps_c.h"


#include <cassert>
#include <limits>
#include <string>
#include "rosidl_typesupport_fastrtps_c/identifier.h"
#include "rosidl_typesupport_fastrtps_c/wstring_conversion.hpp"
#include "rosidl_typesupport_fastrtps_cpp/message_type_support.h"
#include "interface_protocol/msg/rosidl_typesupport_fastrtps_c__visibility_control.h"
#include "interface_protocol/msg/detail/joint_motion_plan_request__struct.h"
#include "interface_protocol/msg/detail/joint_motion_plan_request__functions.h"
#include "fastcdr/Cdr.h"

#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wunused-parameter"
# ifdef __clang__
#  pragma clang diagnostic ignored "-Wdeprecated-register"
#  pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
# endif
#endif
#ifndef _WIN32
# pragma GCC diagnostic pop
#endif

// includes and forward declarations of message dependencies and their conversion functions

#if defined(__cplusplus)
extern "C"
{
#endif

#include "rosidl_runtime_c/primitives_sequence.h"  // damping, joint_indices, stiffness, target_positions, target_velocities
#include "rosidl_runtime_c/primitives_sequence_functions.h"  // damping, joint_indices, stiffness, target_positions, target_velocities

// forward declare type support functions


using _JointMotionPlanRequest__ros_msg_type = interface_protocol__msg__JointMotionPlanRequest;

static bool _JointMotionPlanRequest__cdr_serialize(
  const void * untyped_ros_message,
  eprosima::fastcdr::Cdr & cdr)
{
  if (!untyped_ros_message) {
    fprintf(stderr, "ros message handle is null\n");
    return false;
  }
  const _JointMotionPlanRequest__ros_msg_type * ros_message = static_cast<const _JointMotionPlanRequest__ros_msg_type *>(untyped_ros_message);
  // Field name: request_id
  {
    cdr << ros_message->request_id;
  }

  // Field name: request_type
  {
    cdr << ros_message->request_type;
  }

  // Field name: use_gravity_compensation
  {
    cdr << (ros_message->use_gravity_compensation ? true : false);
  }

  // Field name: joint_indices
  {
    size_t size = ros_message->joint_indices.size;
    auto array_ptr = ros_message->joint_indices.data;
    cdr << static_cast<uint32_t>(size);
    cdr.serializeArray(array_ptr, size);
  }

  // Field name: target_positions
  {
    size_t size = ros_message->target_positions.size;
    auto array_ptr = ros_message->target_positions.data;
    cdr << static_cast<uint32_t>(size);
    cdr.serializeArray(array_ptr, size);
  }

  // Field name: target_velocities
  {
    size_t size = ros_message->target_velocities.size;
    auto array_ptr = ros_message->target_velocities.data;
    cdr << static_cast<uint32_t>(size);
    cdr.serializeArray(array_ptr, size);
  }

  // Field name: execution_time
  {
    cdr << ros_message->execution_time;
  }

  // Field name: stiffness
  {
    size_t size = ros_message->stiffness.size;
    auto array_ptr = ros_message->stiffness.data;
    cdr << static_cast<uint32_t>(size);
    cdr.serializeArray(array_ptr, size);
  }

  // Field name: damping
  {
    size_t size = ros_message->damping.size;
    auto array_ptr = ros_message->damping.data;
    cdr << static_cast<uint32_t>(size);
    cdr.serializeArray(array_ptr, size);
  }

  return true;
}

static bool _JointMotionPlanRequest__cdr_deserialize(
  eprosima::fastcdr::Cdr & cdr,
  void * untyped_ros_message)
{
  if (!untyped_ros_message) {
    fprintf(stderr, "ros message handle is null\n");
    return false;
  }
  _JointMotionPlanRequest__ros_msg_type * ros_message = static_cast<_JointMotionPlanRequest__ros_msg_type *>(untyped_ros_message);
  // Field name: request_id
  {
    cdr >> ros_message->request_id;
  }

  // Field name: request_type
  {
    cdr >> ros_message->request_type;
  }

  // Field name: use_gravity_compensation
  {
    uint8_t tmp;
    cdr >> tmp;
    ros_message->use_gravity_compensation = tmp ? true : false;
  }

  // Field name: joint_indices
  {
    uint32_t cdrSize;
    cdr >> cdrSize;
    size_t size = static_cast<size_t>(cdrSize);
    if (ros_message->joint_indices.data) {
      rosidl_runtime_c__int32__Sequence__fini(&ros_message->joint_indices);
    }
    if (!rosidl_runtime_c__int32__Sequence__init(&ros_message->joint_indices, size)) {
      fprintf(stderr, "failed to create array for field 'joint_indices'");
      return false;
    }
    auto array_ptr = ros_message->joint_indices.data;
    cdr.deserializeArray(array_ptr, size);
  }

  // Field name: target_positions
  {
    uint32_t cdrSize;
    cdr >> cdrSize;
    size_t size = static_cast<size_t>(cdrSize);
    if (ros_message->target_positions.data) {
      rosidl_runtime_c__double__Sequence__fini(&ros_message->target_positions);
    }
    if (!rosidl_runtime_c__double__Sequence__init(&ros_message->target_positions, size)) {
      fprintf(stderr, "failed to create array for field 'target_positions'");
      return false;
    }
    auto array_ptr = ros_message->target_positions.data;
    cdr.deserializeArray(array_ptr, size);
  }

  // Field name: target_velocities
  {
    uint32_t cdrSize;
    cdr >> cdrSize;
    size_t size = static_cast<size_t>(cdrSize);
    if (ros_message->target_velocities.data) {
      rosidl_runtime_c__double__Sequence__fini(&ros_message->target_velocities);
    }
    if (!rosidl_runtime_c__double__Sequence__init(&ros_message->target_velocities, size)) {
      fprintf(stderr, "failed to create array for field 'target_velocities'");
      return false;
    }
    auto array_ptr = ros_message->target_velocities.data;
    cdr.deserializeArray(array_ptr, size);
  }

  // Field name: execution_time
  {
    cdr >> ros_message->execution_time;
  }

  // Field name: stiffness
  {
    uint32_t cdrSize;
    cdr >> cdrSize;
    size_t size = static_cast<size_t>(cdrSize);
    if (ros_message->stiffness.data) {
      rosidl_runtime_c__double__Sequence__fini(&ros_message->stiffness);
    }
    if (!rosidl_runtime_c__double__Sequence__init(&ros_message->stiffness, size)) {
      fprintf(stderr, "failed to create array for field 'stiffness'");
      return false;
    }
    auto array_ptr = ros_message->stiffness.data;
    cdr.deserializeArray(array_ptr, size);
  }

  // Field name: damping
  {
    uint32_t cdrSize;
    cdr >> cdrSize;
    size_t size = static_cast<size_t>(cdrSize);
    if (ros_message->damping.data) {
      rosidl_runtime_c__double__Sequence__fini(&ros_message->damping);
    }
    if (!rosidl_runtime_c__double__Sequence__init(&ros_message->damping, size)) {
      fprintf(stderr, "failed to create array for field 'damping'");
      return false;
    }
    auto array_ptr = ros_message->damping.data;
    cdr.deserializeArray(array_ptr, size);
  }

  return true;
}  // NOLINT(readability/fn_size)

ROSIDL_TYPESUPPORT_FASTRTPS_C_PUBLIC_interface_protocol
size_t get_serialized_size_interface_protocol__msg__JointMotionPlanRequest(
  const void * untyped_ros_message,
  size_t current_alignment)
{
  const _JointMotionPlanRequest__ros_msg_type * ros_message = static_cast<const _JointMotionPlanRequest__ros_msg_type *>(untyped_ros_message);
  (void)ros_message;
  size_t initial_alignment = current_alignment;

  const size_t padding = 4;
  const size_t wchar_size = 4;
  (void)padding;
  (void)wchar_size;

  // field.name request_id
  {
    size_t item_size = sizeof(ros_message->request_id);
    current_alignment += item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }
  // field.name request_type
  {
    size_t item_size = sizeof(ros_message->request_type);
    current_alignment += item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }
  // field.name use_gravity_compensation
  {
    size_t item_size = sizeof(ros_message->use_gravity_compensation);
    current_alignment += item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }
  // field.name joint_indices
  {
    size_t array_size = ros_message->joint_indices.size;
    auto array_ptr = ros_message->joint_indices.data;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);
    (void)array_ptr;
    size_t item_size = sizeof(array_ptr[0]);
    current_alignment += array_size * item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }
  // field.name target_positions
  {
    size_t array_size = ros_message->target_positions.size;
    auto array_ptr = ros_message->target_positions.data;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);
    (void)array_ptr;
    size_t item_size = sizeof(array_ptr[0]);
    current_alignment += array_size * item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }
  // field.name target_velocities
  {
    size_t array_size = ros_message->target_velocities.size;
    auto array_ptr = ros_message->target_velocities.data;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);
    (void)array_ptr;
    size_t item_size = sizeof(array_ptr[0]);
    current_alignment += array_size * item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }
  // field.name execution_time
  {
    size_t item_size = sizeof(ros_message->execution_time);
    current_alignment += item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }
  // field.name stiffness
  {
    size_t array_size = ros_message->stiffness.size;
    auto array_ptr = ros_message->stiffness.data;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);
    (void)array_ptr;
    size_t item_size = sizeof(array_ptr[0]);
    current_alignment += array_size * item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }
  // field.name damping
  {
    size_t array_size = ros_message->damping.size;
    auto array_ptr = ros_message->damping.data;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);
    (void)array_ptr;
    size_t item_size = sizeof(array_ptr[0]);
    current_alignment += array_size * item_size +
      eprosima::fastcdr::Cdr::alignment(current_alignment, item_size);
  }

  return current_alignment - initial_alignment;
}

static uint32_t _JointMotionPlanRequest__get_serialized_size(const void * untyped_ros_message)
{
  return static_cast<uint32_t>(
    get_serialized_size_interface_protocol__msg__JointMotionPlanRequest(
      untyped_ros_message, 0));
}

ROSIDL_TYPESUPPORT_FASTRTPS_C_PUBLIC_interface_protocol
size_t max_serialized_size_interface_protocol__msg__JointMotionPlanRequest(
  bool & full_bounded,
  bool & is_plain,
  size_t current_alignment)
{
  size_t initial_alignment = current_alignment;

  const size_t padding = 4;
  const size_t wchar_size = 4;
  size_t last_member_size = 0;
  (void)last_member_size;
  (void)padding;
  (void)wchar_size;

  full_bounded = true;
  is_plain = true;

  // member: request_id
  {
    size_t array_size = 1;

    last_member_size = array_size * sizeof(uint32_t);
    current_alignment += array_size * sizeof(uint32_t) +
      eprosima::fastcdr::Cdr::alignment(current_alignment, sizeof(uint32_t));
  }
  // member: request_type
  {
    size_t array_size = 1;

    last_member_size = array_size * sizeof(uint8_t);
    current_alignment += array_size * sizeof(uint8_t);
  }
  // member: use_gravity_compensation
  {
    size_t array_size = 1;

    last_member_size = array_size * sizeof(uint8_t);
    current_alignment += array_size * sizeof(uint8_t);
  }
  // member: joint_indices
  {
    size_t array_size = 0;
    full_bounded = false;
    is_plain = false;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);

    last_member_size = array_size * sizeof(uint32_t);
    current_alignment += array_size * sizeof(uint32_t) +
      eprosima::fastcdr::Cdr::alignment(current_alignment, sizeof(uint32_t));
  }
  // member: target_positions
  {
    size_t array_size = 0;
    full_bounded = false;
    is_plain = false;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);

    last_member_size = array_size * sizeof(uint64_t);
    current_alignment += array_size * sizeof(uint64_t) +
      eprosima::fastcdr::Cdr::alignment(current_alignment, sizeof(uint64_t));
  }
  // member: target_velocities
  {
    size_t array_size = 0;
    full_bounded = false;
    is_plain = false;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);

    last_member_size = array_size * sizeof(uint64_t);
    current_alignment += array_size * sizeof(uint64_t) +
      eprosima::fastcdr::Cdr::alignment(current_alignment, sizeof(uint64_t));
  }
  // member: execution_time
  {
    size_t array_size = 1;

    last_member_size = array_size * sizeof(uint64_t);
    current_alignment += array_size * sizeof(uint64_t) +
      eprosima::fastcdr::Cdr::alignment(current_alignment, sizeof(uint64_t));
  }
  // member: stiffness
  {
    size_t array_size = 0;
    full_bounded = false;
    is_plain = false;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);

    last_member_size = array_size * sizeof(uint64_t);
    current_alignment += array_size * sizeof(uint64_t) +
      eprosima::fastcdr::Cdr::alignment(current_alignment, sizeof(uint64_t));
  }
  // member: damping
  {
    size_t array_size = 0;
    full_bounded = false;
    is_plain = false;
    current_alignment += padding +
      eprosima::fastcdr::Cdr::alignment(current_alignment, padding);

    last_member_size = array_size * sizeof(uint64_t);
    current_alignment += array_size * sizeof(uint64_t) +
      eprosima::fastcdr::Cdr::alignment(current_alignment, sizeof(uint64_t));
  }

  size_t ret_val = current_alignment - initial_alignment;
  if (is_plain) {
    // All members are plain, and type is not empty.
    // We still need to check that the in-memory alignment
    // is the same as the CDR mandated alignment.
    using DataType = interface_protocol__msg__JointMotionPlanRequest;
    is_plain =
      (
      offsetof(DataType, damping) +
      last_member_size
      ) == ret_val;
  }

  return ret_val;
}

static size_t _JointMotionPlanRequest__max_serialized_size(char & bounds_info)
{
  bool full_bounded;
  bool is_plain;
  size_t ret_val;

  ret_val = max_serialized_size_interface_protocol__msg__JointMotionPlanRequest(
    full_bounded, is_plain, 0);

  bounds_info =
    is_plain ? ROSIDL_TYPESUPPORT_FASTRTPS_PLAIN_TYPE :
    full_bounded ? ROSIDL_TYPESUPPORT_FASTRTPS_BOUNDED_TYPE : ROSIDL_TYPESUPPORT_FASTRTPS_UNBOUNDED_TYPE;
  return ret_val;
}


static message_type_support_callbacks_t __callbacks_JointMotionPlanRequest = {
  "interface_protocol::msg",
  "JointMotionPlanRequest",
  _JointMotionPlanRequest__cdr_serialize,
  _JointMotionPlanRequest__cdr_deserialize,
  _JointMotionPlanRequest__get_serialized_size,
  _JointMotionPlanRequest__max_serialized_size
};

static rosidl_message_type_support_t _JointMotionPlanRequest__type_support = {
  rosidl_typesupport_fastrtps_c__identifier,
  &__callbacks_JointMotionPlanRequest,
  get_message_typesupport_handle_function,
};

const rosidl_message_type_support_t *
ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_fastrtps_c, interface_protocol, msg, JointMotionPlanRequest)() {
  return &_JointMotionPlanRequest__type_support;
}

#if defined(__cplusplus)
}
#endif
