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(
34  rcl_duration_value_t nanoseconds);
35 
37  explicit Duration(
38  std::chrono::nanoseconds nanoseconds);
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  static Duration
94  max();
95 
97  Duration
98  operator*(double scale) const;
99 
102  nanoseconds() const;
103 
108  double
109  seconds() const;
110 
111 private:
112  rcl_duration_t rcl_duration_;
113 };
114 
115 } // namespace rclcpp
116 
117 #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
Definition: allocator_common.hpp:24
static Duration max()
rcl_duration_value_t nanoseconds() const
Definition: duration.hpp:26
Duration operator-(const rclcpp::Duration &rhs) const
bool operator>(const rclcpp::Duration &rhs) const
Duration & operator=(const Duration &rhs)
Duration(int32_t seconds, uint32_t nanoseconds)
rcutils_duration_value_t rcl_duration_value_t
virtual ~Duration()
Duration operator+(const rclcpp::Duration &rhs) const
double seconds() const
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
bool operator<=(const rclcpp::Duration &rhs) const
Duration operator*(double scale) const