ROS 2 rclcpp + rcl - rolling  rolling-d1a7896a
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 <ostream>
16 #include <string>
17 
18 #include "rclcpp/network_flow_endpoint.hpp"
19 
20 namespace rclcpp
21 {
22 
23 const std::string &
25 {
26  return transport_protocol_;
27 }
28 
29 const std::string &
31 {
32  return internet_protocol_;
33 }
34 
36 {
37  return transport_port_;
38 }
39 
41 {
42  return flow_label_;
43 }
44 
46 {
47  return dscp_;
48 }
49 
50 const std::string &
52 {
53  return internet_address_;
54 }
55 
56 bool operator==(const NetworkFlowEndpoint & left, const NetworkFlowEndpoint & right)
57 {
58  return left.transport_protocol_ == right.transport_protocol_ &&
59  left.internet_protocol_ == right.internet_protocol_ &&
60  left.transport_port_ == right.transport_port_ &&
61  left.flow_label_ == right.flow_label_ &&
62  left.dscp_ == right.dscp_ &&
63  left.internet_address_ == right.internet_address_;
64 }
65 
66 bool operator!=(const NetworkFlowEndpoint & left, const NetworkFlowEndpoint & right)
67 {
68  return !(left == right);
69 }
70 
71 std::ostream & operator<<(std::ostream & os, const NetworkFlowEndpoint & network_flow_endpoint)
72 {
73  // Stream out in JSON-like format
74  os << "{" <<
75  "\"transportProtocol\": \"" << network_flow_endpoint.transport_protocol_ << "\", " <<
76  "\"internetProtocol\": \"" << network_flow_endpoint.internet_protocol_ << "\", " <<
77  "\"transportPort\": \"" << network_flow_endpoint.transport_port_ << "\", " <<
78  "\"flowLabel\": \"" << std::to_string(network_flow_endpoint.flow_label_) << "\", " <<
79  "\"dscp\": \"" << std::to_string(network_flow_endpoint.dscp_) << "\", " <<
80  "\"internetAddress\": \"" << network_flow_endpoint.internet_address_ << "\"" <<
81  "}";
82  return os;
83 }
84 
85 } // 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.