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 namespace rclcpp
25 {
26 
27 class Time
28 {
29 public:
31  static
32  Time
34 
36  Time(int32_t seconds, uint32_t nanoseconds, rcl_time_source_type_t clock = RCL_SYSTEM_TIME);
37 
39  explicit Time(uint64_t nanoseconds, rcl_time_source_type_t clock = RCL_SYSTEM_TIME);
40 
42  Time(const Time & rhs);
43 
45  Time(const builtin_interfaces::msg::Time & time_msg); // NOLINT
46 
48  virtual ~Time();
49 
51  operator builtin_interfaces::msg::Time() const;
52 
54  void
55  operator=(const Time & rhs);
56 
58  void
59  operator=(const builtin_interfaces::msg::Time & time_msg);
60 
62  bool
63  operator==(const rclcpp::Time & rhs) const;
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  Time
83  operator+(const rclcpp::Time & rhs) const;
84 
86  Time
87  operator-(const rclcpp::Time & rhs) const;
88 
90  uint64_t
91  nanoseconds() const;
92 
93 private:
94  rcl_time_source_t rcl_time_source_;
95  rcl_time_point_t rcl_time_;
96 };
97 
98 } // namespace rclcpp
99 
100 #endif // RCLCPP__TIME_HPP_
bool operator>=(const rclcpp::Time &rhs) const
Time operator-(const rclcpp::Time &rhs) const
uint64_t nanoseconds() const
bool operator>(const rclcpp::Time &rhs) const
virtual ~Time()
Definition: allocator_common.hpp:24
bool operator<=(const rclcpp::Time &rhs) const
rcl_time_source_type_t
static Time now(rcl_time_source_type_t clock=RCL_SYSTEM_TIME)
bool operator==(const rclcpp::Time &rhs) const
Time(int32_t seconds, uint32_t nanoseconds, rcl_time_source_type_t clock=RCL_SYSTEM_TIME)
bool operator<(const rclcpp::Time &rhs) const
Time operator+(const rclcpp::Time &rhs) const
#define RCLCPP_PUBLIC
Definition: visibility_control.hpp:50
Definition: time.hpp:27
void operator=(const Time &rhs)
RCL_SYSTEM_TIME