rclcpp  master
C++ ROS Client Library API
time.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__TIME_HPP_
16 #define RCLCPP__TIME_HPP_
17 
18 #include "builtin_interfaces/msg/time.hpp"
19 
21 
22 #include "rcl/time.h"
23 
24 #include "rclcpp/duration.hpp"
25 
26 namespace rclcpp
27 {
28 
29 class Clock;
30 
31 class Time
32 {
33 public:
35  Time(int32_t seconds, uint32_t nanoseconds, rcl_clock_type_t clock_type = RCL_SYSTEM_TIME);
36 
38  explicit Time(int64_t nanoseconds = 0, rcl_clock_type_t clock = RCL_SYSTEM_TIME);
39 
41  Time(const Time & rhs);
42 
44  Time(
45  const builtin_interfaces::msg::Time & time_msg,
46  rcl_clock_type_t ros_time = RCL_ROS_TIME);
47 
49  explicit Time(const rcl_time_point_t & time_point);
50 
52  virtual ~Time();
53 
55  operator builtin_interfaces::msg::Time() const;
56 
58  Time &
59  operator=(const Time & rhs);
60 
62  Time &
63  operator=(const builtin_interfaces::msg::Time & time_msg);
64 
66  bool
67  operator==(const rclcpp::Time & rhs) const;
68 
70  bool
71  operator!=(const rclcpp::Time & rhs) const;
72 
74  bool
75  operator<(const rclcpp::Time & rhs) const;
76 
78  bool
79  operator<=(const rclcpp::Time & rhs) const;
80 
82  bool
83  operator>=(const rclcpp::Time & rhs) const;
84 
86  bool
87  operator>(const rclcpp::Time & rhs) const;
88 
90  Time
91  operator+(const rclcpp::Duration & rhs) const;
92 
94  Duration
95  operator-(const rclcpp::Time & rhs) const;
96 
98  Time
99  operator-(const rclcpp::Duration & rhs) const;
100 
103  nanoseconds() const;
104 
107  get_clock_type() const;
108 
109 private:
110  rcl_time_point_t rcl_time_;
111  friend Clock; // Allow clock to manipulate internal data
112 };
113 
114 Time
115 operator+(const rclcpp::Duration & lhs, const rclcpp::Time & rhs);
116 
117 } // namespace rclcpp
118 
119 #endif // RCLCPP__TIME_HPP_
virtual ~Time()
rcl_clock_type_t get_clock_type() const
Definition: clock.hpp:83
rcl_time_point_value_t nanoseconds() const
rcl_clock_type_t
Definition: allocator_common.hpp:24
Definition: duration.hpp:26
bool operator>(const rclcpp::Time &rhs) const
bool operator<=(const rclcpp::Time &rhs) const
bool operator>=(const rclcpp::Time &rhs) const
rcutils_time_point_value_t rcl_time_point_value_t
bool operator!=(const rclcpp::Time &rhs) const
RCL_SYSTEM_TIME
Duration operator-(const rclcpp::Time &rhs) const
Time & operator=(const Time &rhs)
RCL_ROS_TIME
Time operator+(const rclcpp::Duration &rhs) const
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Time(int32_t seconds, uint32_t nanoseconds, rcl_clock_type_t clock_type=RCL_SYSTEM_TIME)
bool operator==(const rclcpp::Time &rhs) const
bool operator<(const rclcpp::Time &rhs) const
Time operator+(const rclcpp::Duration &lhs, const rclcpp::Time &rhs)
Definition: time.hpp:31