libfranka 0.15.0
FCI C++ API
Loading...
Searching...
No Matches
duration.h
Go to the documentation of this file.
1// Copyright (c) 2023 Franka Robotics GmbH
2// Use of this source code is governed by the Apache-2.0 license, see LICENSE
3#pragma once
4
5#include <chrono>
6#include <cstdint>
7#include <ratio>
8
14namespace franka {
15
19class Duration {
20 public:
24 Duration() noexcept;
25
31 explicit Duration(uint64_t milliseconds) noexcept;
32
38 Duration(std::chrono::duration<uint64_t, std::milli> duration) noexcept;
39
43 Duration(const Duration&) = default;
44
50 Duration& operator=(const Duration&) = default;
51
57 operator std::chrono::duration<uint64_t, std::milli>() const noexcept;
58
64 double toSec() const noexcept;
65
71 uint64_t toMSec() const noexcept;
72
85 Duration operator+(const Duration& rhs) const noexcept;
93 Duration& operator+=(const Duration& rhs) noexcept;
94
102 Duration operator-(const Duration& rhs) const noexcept;
110 Duration& operator-=(const Duration& rhs) noexcept;
111
119 Duration operator*(uint64_t rhs) const noexcept;
127 Duration& operator*=(uint64_t rhs) noexcept;
128
136 uint64_t operator/(const Duration& rhs) const noexcept;
144 Duration operator/(uint64_t rhs) const noexcept;
152 Duration& operator/=(uint64_t rhs) noexcept;
153
161 Duration operator%(const Duration& rhs) const noexcept;
169 Duration operator%(uint64_t rhs) const noexcept;
177 Duration& operator%=(const Duration& rhs) noexcept;
185 Duration& operator%=(uint64_t rhs) noexcept;
186
203 bool operator==(const Duration& rhs) const noexcept;
211 bool operator!=(const Duration& rhs) const noexcept;
212
220 bool operator<(const Duration& rhs) const noexcept;
228 bool operator<=(const Duration& rhs) const noexcept;
229
237 bool operator>(const Duration& rhs) const noexcept;
245 bool operator>=(const Duration& rhs) const noexcept;
246
251 private:
252 std::chrono::duration<uint64_t, std::milli> duration_;
253};
254
263Duration operator*(uint64_t lhs, const Duration& rhs) noexcept;
264
265} // namespace franka
Represents a duration with millisecond resolution.
Definition duration.h:19
uint64_t toMSec() const noexcept
Returns the stored duration in .
double toSec() const noexcept
Returns the stored duration in .
Duration() noexcept
Creates a new Duration instance with zero milliseconds.