ROS 2 rclcpp + rcl - rolling  rolling-e7363f10
ROS 2 C++ Client Library with ROS Client Library
common.c
1 // Copyright 2015 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 
15 #ifdef __cplusplus
16 extern "C"
17 {
18 #endif
19 
20 #include "./common.h" // NOLINT
21 
22 #include "rcl/types.h"
23 
24 #include "rcutils/types/rcutils_ret.h"
25 
26 #include "rmw/ret_types.h"
27 
29 rcl_convert_rmw_ret_to_rcl_ret(rmw_ret_t rmw_ret)
30 {
31  switch (rmw_ret) {
32  case RMW_RET_OK:
33  return RCL_RET_OK;
34  case RMW_RET_INVALID_ARGUMENT:
36  case RMW_RET_BAD_ALLOC:
37  return RCL_RET_BAD_ALLOC;
38  case RMW_RET_UNSUPPORTED:
39  return RCL_RET_UNSUPPORTED;
40  case RMW_RET_NODE_NAME_NON_EXISTENT:
42  default:
43  return RCL_RET_ERROR;
44  }
45 }
46 
48 rcl_convert_rcutils_ret_to_rcl_ret(rcutils_ret_t rcutils_ret)
49 {
50  switch (rcutils_ret) {
51  case RCUTILS_RET_OK:
52  return RCL_RET_OK;
53  case RCUTILS_RET_ERROR:
54  return RCL_RET_ERROR;
55  case RCUTILS_RET_BAD_ALLOC:
56  return RCL_RET_BAD_ALLOC;
57  case RCUTILS_RET_INVALID_ARGUMENT:
59  case RCUTILS_RET_NOT_INITIALIZED:
60  return RCL_RET_NOT_INIT;
61  case RCUTILS_RET_NOT_FOUND:
62  return RCL_RET_NOT_FOUND;
63  default:
64  return RCL_RET_ERROR;
65  }
66 }
67 
68 #ifdef __cplusplus
69 }
70 #endif
#define RCL_RET_UNSUPPORTED
Unsupported return code.
Definition: types.h:38
#define RCL_RET_NOT_FOUND
Resource not found.
Definition: types.h:56
#define RCL_RET_NOT_INIT
rcl_init() not yet called return code.
Definition: types.h:44
#define RCL_RET_NODE_NAME_NON_EXISTENT
Failed to find node name.
Definition: types.h:66
#define RCL_RET_OK
Success return code.
Definition: types.h:28
#define RCL_RET_BAD_ALLOC
Failed to allocate memory return code.
Definition: types.h:34
#define RCL_RET_INVALID_ARGUMENT
Invalid argument return code.
Definition: types.h:36
#define RCL_RET_ERROR
Unspecified error return code.
Definition: types.h:30
rmw_ret_t rcl_ret_t
The type that holds an rcl return code.
Definition: types.h:25