ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
future_return_code.cpp
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 #include <iostream>
16 #include <string>
17 #include <type_traits>
18 
19 #include "rclcpp/future_return_code.hpp"
20 
21 namespace rclcpp
22 {
23 
24 std::ostream &
25 operator<<(std::ostream & os, const rclcpp::FutureReturnCode & future_return_code)
26 {
27  return os << to_string(future_return_code);
28 }
29 
30 std::string
31 to_string(const rclcpp::FutureReturnCode & future_return_code)
32 {
33  using enum_type = std::underlying_type<FutureReturnCode>::type;
34  std::string prefix = "Unknown enum value (";
35  std::string ret_as_string = std::to_string(static_cast<enum_type>(future_return_code));
36  switch (future_return_code) {
37  case FutureReturnCode::SUCCESS:
38  prefix = "SUCCESS (";
39  break;
40  case FutureReturnCode::INTERRUPTED:
41  prefix = "INTERRUPTED (";
42  break;
43  case FutureReturnCode::TIMEOUT:
44  prefix = "TIMEOUT (";
45  break;
46  }
47  return prefix + ret_as_string + ")";
48 }
49 
50 } // namespace rclcpp
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
RCLCPP_PUBLIC std::string to_string(const FutureReturnCode &future_return_code)
String conversion function for FutureReturnCode.
RCLCPP_PUBLIC std::ostream & operator<<(std::ostream &os, const FutureReturnCode &future_return_code)
Stream operator for FutureReturnCode.
FutureReturnCode
Return codes to be used with spin_until_future_complete.