1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
|
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2020 - 2022 by Apex.AI Inc. All rights reserved.
//
// 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.
//
// SPDX-License-Identifier: Apache-2.0
#include "iceoryx_binding_c/internal/cpp2c_enum_translation.hpp"
#include "iceoryx_binding_c/enums.h"
using namespace iox;
using namespace iox::popo;
namespace cpp2c
{
iox_SubscribeState subscribeState(const iox::SubscribeState value) noexcept
{
switch (value)
{
case iox::SubscribeState::NOT_SUBSCRIBED:
return iox_SubscribeState::SubscribeState_NOT_SUBSCRIBED;
case iox::SubscribeState::SUBSCRIBE_REQUESTED:
return iox_SubscribeState::SubscribeState_SUBSCRIBE_REQUESTED;
case iox::SubscribeState::SUBSCRIBED:
return iox_SubscribeState::SubscribeState_SUBSCRIBED;
case iox::SubscribeState::UNSUBSCRIBE_REQUESTED:
return iox_SubscribeState::SubscribeState_UNSUBSCRIBE_REQUESTED;
case iox::SubscribeState::WAIT_FOR_OFFER:
return iox_SubscribeState::SubscribeState_WAIT_FOR_OFFER;
}
return iox_SubscribeState::SubscribeState_UNDEFINED_ERROR;
}
iox_ChunkReceiveResult chunkReceiveResult(const iox::popo::ChunkReceiveResult value) noexcept
{
switch (value)
{
case iox::popo::ChunkReceiveResult::NO_CHUNK_AVAILABLE:
return ChunkReceiveResult_NO_CHUNK_AVAILABLE;
case iox::popo::ChunkReceiveResult::TOO_MANY_CHUNKS_HELD_IN_PARALLEL:
return ChunkReceiveResult_TOO_MANY_CHUNKS_HELD_IN_PARALLEL;
}
return ChunkReceiveResult_UNDEFINED_ERROR;
}
iox_AllocationResult allocationResult(const iox::popo::AllocationError value) noexcept
{
switch (value)
{
case AllocationError::UNDEFINED_ERROR:
return AllocationResult_UNDEFINED_ERROR;
case AllocationError::NO_MEMPOOLS_AVAILABLE:
return AllocationResult_NO_MEMPOOLS_AVAILABLE;
case AllocationError::RUNNING_OUT_OF_CHUNKS:
return AllocationResult_RUNNING_OUT_OF_CHUNKS;
case AllocationError::TOO_MANY_CHUNKS_ALLOCATED_IN_PARALLEL:
return AllocationResult_TOO_MANY_CHUNKS_ALLOCATED_IN_PARALLEL;
case AllocationError::INVALID_PARAMETER_FOR_USER_PAYLOAD_OR_USER_HEADER:
return AllocationResult_INVALID_PARAMETER_FOR_USER_PAYLOAD_OR_USER_HEADER;
case AllocationError::INVALID_PARAMETER_FOR_REQUEST_HEADER:
return AllocationResult_INVALID_PARAMETER_FOR_REQUEST_HEADER;
}
return AllocationResult_UNDEFINED_ERROR;
}
iox_ClientSendResult clientSendResult(const iox::popo::ClientSendError value) noexcept
{
switch (value)
{
case ClientSendError::NO_CONNECT_REQUESTED:
return ClientSendResult_NO_CONNECT_REQUESTED;
case ClientSendError::SERVER_NOT_AVAILABLE:
return ClientSendResult_SERVER_NOT_AVAILABLE;
case ClientSendError::INVALID_REQUEST:
return ClientSendResult_INVALID_REQUEST;
}
return ClientSendResult_UNDEFINED_ERROR;
}
iox_ServerSendResult serverSendResult(const iox::popo::ServerSendError value) noexcept
{
switch (value)
{
case ServerSendError::NOT_OFFERED:
return ServerSendResult_NOT_OFFERED;
case ServerSendError::CLIENT_NOT_AVAILABLE:
return ServerSendResult_CLIENT_NOT_AVAILABLE;
case ServerSendError::INVALID_RESPONSE:
return ServerSendResult_INVALID_RESPONSE;
}
return ServerSendResult_UNDEFINED_ERROR;
}
iox_WaitSetResult waitSetResult(const iox::popo::WaitSetError value) noexcept
{
switch (value)
{
case WaitSetError::WAIT_SET_FULL:
return WaitSetResult_WAIT_SET_FULL;
case WaitSetError::ALREADY_ATTACHED:
return WaitSetResult_ALREADY_ATTACHED;
}
return WaitSetResult_UNDEFINED_ERROR;
}
iox_ListenerResult listenerResult(const iox::popo::ListenerError value) noexcept
{
switch (value)
{
case ListenerError::EVENT_ALREADY_ATTACHED:
return ListenerResult_EVENT_ALREADY_ATTACHED;
case ListenerError::LISTENER_FULL:
return ListenerResult_LISTENER_FULL;
case ListenerError::EMPTY_EVENT_CALLBACK:
return ListenerResult_EMPTY_EVENT_CALLBACK;
case ListenerError::EMPTY_INVALIDATION_CALLBACK:
return ListenerResult_EMPTY_INVALIDATION_CALLBACK;
}
return ListenerResult_UNDEFINED_ERROR;
}
iox_ConsumerTooSlowPolicy consumerTooSlowPolicy(const iox::popo::ConsumerTooSlowPolicy policy) noexcept
{
switch (policy)
{
case ConsumerTooSlowPolicy::WAIT_FOR_CONSUMER:
return ConsumerTooSlowPolicy_WAIT_FOR_CONSUMER;
case ConsumerTooSlowPolicy::DISCARD_OLDEST_DATA:
return ConsumerTooSlowPolicy_DISCARD_OLDEST_DATA;
}
return ConsumerTooSlowPolicy_DISCARD_OLDEST_DATA;
}
iox_ConsumerTooSlowPolicy subscriberTooSlowPolicy(const iox::popo::ConsumerTooSlowPolicy policy) noexcept
{
return consumerTooSlowPolicy(policy);
}
iox_QueueFullPolicy queueFullPolicy(const iox::popo::QueueFullPolicy policy) noexcept
{
switch (policy)
{
case QueueFullPolicy::BLOCK_PRODUCER:
return QueueFullPolicy_BLOCK_PRODUCER;
case QueueFullPolicy::DISCARD_OLDEST_DATA:
return QueueFullPolicy_DISCARD_OLDEST_DATA;
}
return QueueFullPolicy_DISCARD_OLDEST_DATA;
}
iox_ClientEvent clientEvent(const iox::popo::ClientEvent value) noexcept
{
switch (value)
{
case ClientEvent::RESPONSE_RECEIVED:
return ClientEvent_RESPONSE_RECEIVED;
}
return ClientEvent_RESPONSE_RECEIVED;
}
iox_ClientState clientState(const iox::popo::ClientState value) noexcept
{
switch (value)
{
case ClientState::HAS_RESPONSE:
return ClientState_HAS_RESPONSE;
}
return ClientState_HAS_RESPONSE;
}
iox_ServerEvent serverEvent(const iox::popo::ServerEvent value) noexcept
{
switch (value)
{
case ServerEvent::REQUEST_RECEIVED:
return ServerEvent_REQUEST_RECEIVED;
}
return ServerEvent_REQUEST_RECEIVED;
}
iox_ServerState serverState(const iox::popo::ServerState value) noexcept
{
switch (value)
{
case ServerState::HAS_REQUEST:
return ServerState_HAS_REQUEST;
}
return ServerState_HAS_REQUEST;
}
iox_ConnectionState connectionState(const iox::ConnectionState value) noexcept
{
switch (value)
{
case iox::ConnectionState::CONNECTED:
return ConnectionState_CONNECTED;
case iox::ConnectionState::NOT_CONNECTED:
return ConnectionState_NOT_CONNECTED;
case iox::ConnectionState::CONNECT_REQUESTED:
return ConnectionState_CONNECT_REQUESTED;
case iox::ConnectionState::DISCONNECT_REQUESTED:
return ConnectionState_DISCONNECT_REQUESTED;
case iox::ConnectionState::WAIT_FOR_OFFER:
return ConnectionState_WAIT_FOR_OFFER;
}
return ConnectionState_NOT_CONNECTED;
}
iox_ServerRequestResult serverRequestResult(const iox::popo::ServerRequestResult value) noexcept
{
switch (value)
{
case iox::popo::ServerRequestResult::TOO_MANY_REQUESTS_HELD_IN_PARALLEL:
return ServerRequestResult_TOO_MANY_REQUESTS_HELD_IN_PARALLEL;
case iox::popo::ServerRequestResult::NO_PENDING_REQUESTS:
return ServerRequestResult_NO_PENDING_REQUESTS;
case iox::popo::ServerRequestResult::UNDEFINED_CHUNK_RECEIVE_ERROR:
return ServerRequestResult_UNDEFINED_CHUNK_RECEIVE_ERROR;
case iox::popo::ServerRequestResult::NO_PENDING_REQUESTS_AND_SERVER_DOES_NOT_OFFER:
return ServerRequestResult_NO_PENDING_REQUESTS_AND_SERVER_DOES_NOT_OFFER;
}
return ServerRequestResult_SUCCESS;
}
} // namespace cpp2c
|