rclcpp  master
C++ ROS Client Library API
duration.hpp
Go to the documentation of this file.
1 // Copyright 2017 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 #ifndef RCLCPP__DURATION_HPP_
16 #define RCLCPP__DURATION_HPP_
17 
18 #include <chrono>
19 
20 #include "builtin_interfaces/msg/duration.hpp"
21 #include "rcl/time.h"
23 
24 namespace rclcpp
25 {
26 class Duration
27 {
28 public:
30  Duration(int32_t seconds, uint32_t nanoseconds);
31 
33  explicit Duration(
35 
37  explicit Duration(
39 
41  Duration(
42  const builtin_interfaces::msg::Duration & duration_msg);
43 
45  explicit Duration(const rcl_duration_t & duration);
46 
48  Duration(const Duration & rhs);
49 
51  virtual ~Duration();
52 
54  operator builtin_interfaces::msg::Duration() const;
55 
57  Duration &
58  operator=(const Duration & rhs);
59 
61  Duration &
62  operator=(const builtin_interfaces::msg::Duration & Duration_msg);
63 
65  bool
66  operator==(const rclcpp::Duration & rhs) const;
67 
69  bool
70  operator<(const rclcpp::Duration & rhs) const;
71 
73  bool
74  operator<=(const rclcpp::Duration & rhs) const;
75 
77  bool
78  operator>=(const rclcpp::Duration & rhs) const;
79 
81  bool
82  operator>(const rclcpp::Duration & rhs) const;
83 
85  Duration
86  operator+(const rclcpp::Duration & rhs) const;
87 
89  Duration
90  operator-(const rclcpp::Duration & rhs) const;
91 
93  Duration
94  operator*(double scale) const;
95 
98  nanoseconds() const;
99 
100 private:
101  rcl_duration_t rcl_duration_;
102 };
103 
104 } // namespace rclcpp
105 
106 #endif // RCLCPP__DURATION_HPP_
bool operator==(const rclcpp::Duration &rhs) const
bool operator<(const rclcpp::Duration &rhs) const
bool operator>(const rclcpp::Duration &rhs) const
Duration operator+(const rclcpp::Duration &rhs) const
Duration(int32_t seconds, uint32_t nanoseconds)
Definition: allocator_common.hpp:24
Definition: duration.hpp:26
Duration operator*(double scale) const
Duration operator-(const rclcpp::Duration &rhs) const
rcutils_duration_value_t rcl_duration_value_t
bool operator>=(const rclcpp::Duration &rhs) const
Duration & operator=(const Duration &rhs)
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
bool operator<=(const rclcpp::Duration &rhs) const
virtual ~Duration()
rcl_duration_value_t nanoseconds() const