ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
network_flow_endpoint.cpp
1 // Copyright 2020 Ericsson AB
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 <string>
16 
17 #include "rclcpp/network_flow_endpoint.hpp"
18 
19 namespace rclcpp
20 {
21 
22 const std::string &
24 {
25  return transport_protocol_;
26 }
27 
28 const std::string &
30 {
31  return internet_protocol_;
32 }
33 
35 {
36  return transport_port_;
37 }
38 
40 {
41  return flow_label_;
42 }
43 
45 {
46  return dscp_;
47 }
48 
49 const std::string &
51 {
52  return internet_address_;
53 }
54 
55 bool operator==(const NetworkFlowEndpoint & left, const NetworkFlowEndpoint & right)
56 {
57  return left.transport_protocol_ == right.transport_protocol_ &&
58  left.internet_protocol_ == right.internet_protocol_ &&
59  left.transport_port_ == right.transport_port_ &&
60  left.flow_label_ == right.flow_label_ &&
61  left.dscp_ == right.dscp_ &&
62  left.internet_address_ == right.internet_address_;
63 }
64 
65 bool operator!=(const NetworkFlowEndpoint & left, const NetworkFlowEndpoint & right)
66 {
67  return !(left == right);
68 }
69 
70 std::ostream & operator<<(std::ostream & os, const NetworkFlowEndpoint & network_flow_endpoint)
71 {
72  // Stream out in JSON-like format
73  os << "{" <<
74  "\"transportProtocol\": \"" << network_flow_endpoint.transport_protocol_ << "\", " <<
75  "\"internetProtocol\": \"" << network_flow_endpoint.internet_protocol_ << "\", " <<
76  "\"transportPort\": \"" << network_flow_endpoint.transport_port_ << "\", " <<
77  "\"flowLabel\": \"" << std::to_string(network_flow_endpoint.flow_label_) << "\", " <<
78  "\"dscp\": \"" << std::to_string(network_flow_endpoint.dscp_) << "\", " <<
79  "\"internetAddress\": \"" << network_flow_endpoint.internet_address_ << "\"" <<
80  "}";
81  return os;
82 }
83 
84 } // namespace rclcpp
RCLCPP_PUBLIC uint32_t flow_label() const
Get flow label.
RCLCPP_PUBLIC const std::string & internet_protocol() const
Get internet protocol.
RCLCPP_PUBLIC uint16_t transport_port() const
Get transport port.
RCLCPP_PUBLIC const std::string & transport_protocol() const
Get transport protocol.
RCLCPP_PUBLIC const std::string & internet_address() const
Get internet address.
RCLCPP_PUBLIC uint8_t dscp() const
Get DSCP.
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
RCLCPP_PUBLIC bool operator==(const NetworkFlowEndpoint &left, const NetworkFlowEndpoint &right)
Check if two NetworkFlowEndpoint instances are equal.
RCLCPP_PUBLIC std::ostream & operator<<(std::ostream &os, const FutureReturnCode &future_return_code)
Stream operator for FutureReturnCode.
RCLCPP_PUBLIC bool operator!=(const NetworkFlowEndpoint &left, const NetworkFlowEndpoint &right)
Check if two NetworkFlowEndpoint instances are not equal.