duration.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Franka Emika 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 
14 namespace franka {
15 
19 class 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 
263 Duration operator*(uint64_t lhs, const Duration& rhs) noexcept;
264 
265 } // namespace franka
bool operator==(const Duration &rhs) const noexcept
Compares two durations for equality.
bool operator<=(const Duration &rhs) const noexcept
Compares two durations.
Duration & operator*=(uint64_t rhs) noexcept
Performs multiplication.
Duration() noexcept
Creates a new Duration instance with zero milliseconds.
double toSec() const noexcept
Returns the stored duration in .
Duration & operator=(const Duration &)=default
Assigns the contents of one Duration to another.
std::chrono::duration< uint64_t, std::milli > duration_
Definition: duration.h:252
bool operator<(const Duration &rhs) const noexcept
Compares two durations.
Duration operator+(const Duration &rhs) const noexcept
Performs addition.
bool operator>(const Duration &rhs) const noexcept
Compares two durations.
Duration & operator-=(const Duration &rhs) noexcept
Performs subtraction.
Represents a duration with millisecond resolution.
Definition: duration.h:19
bool operator!=(const Duration &rhs) const noexcept
Compares two durations for inequality.
Duration & operator%=(const Duration &rhs) noexcept
Performs the modulo operation.
Duration operator*(uint64_t rhs) const noexcept
Performs multiplication.
uint64_t operator/(const Duration &rhs) const noexcept
Performs division.
Duration & operator/=(uint64_t rhs) noexcept
Performs division.
Duration operator%(const Duration &rhs) const noexcept
Performs the modulo operation.
uint64_t toMSec() const noexcept
Returns the stored duration in .
bool operator>=(const Duration &rhs) const noexcept
Compares two durations.
Duration operator-(const Duration &rhs) const noexcept
Performs subtraction.
Duration & operator+=(const Duration &rhs) noexcept
Performs addition.


libfranka
Author(s): Franka Emika GmbH
autogenerated on Tue Jul 9 2019 03:32:01