Goby3 3.2.3
2025.05.13
Loading...
Searching...
No Matches
system_clock.h
Go to the documentation of this file.
1// Copyright 2019-2021:
2// GobySoft, LLC (2013-)
3// Community contributors (see AUTHORS file)
4// File authors:
5// Toby Schneider <toby@gobysoft.org>
6//
7//
8// This file is part of the Goby Underwater Autonomy Project Libraries
9// ("The Goby Libraries").
10//
11// The Goby Libraries are free software: you can redistribute them and/or modify
12// them under the terms of the GNU Lesser General Public License as published by
13// the Free Software Foundation, either version 2.1 of the License, or
14// (at your option) any later version.
15//
16// The Goby Libraries are distributed in the hope that they will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public License
22// along with Goby. If not, see <http://www.gnu.org/licenses/>.
23
24#ifndef GOBY_TIME_SYSTEM_CLOCK_H
25#define GOBY_TIME_SYSTEM_CLOCK_H
26
27#include <chrono>
28#include <cstdint>
29
31
32namespace goby
33{
35
36
44namespace time
45{
48{
52 typedef std::chrono::microseconds duration;
53 typedef duration::rep rep;
54 typedef duration::period period;
55 typedef std::chrono::time_point<SystemClock> time_point;
56 static const bool is_steady = false;
57
63 static time_point now() noexcept
64 {
65 using namespace std::chrono;
66 auto now = system_clock::now();
67
69 return time_point(duration_cast<duration>(now.time_since_epoch()));
70 else
71 return warp(now);
72 }
73
75 template <typename TimeType> static TimeType now();
76
78 warp(const std::chrono::system_clock::time_point& real_time);
79
80 static std::chrono::system_clock::time_point
82};
83
84} // namespace time
85
87
88} // namespace goby
89
90#endif
unit< time_dimension, si::system > time
Definition time.hpp:22
The global namespace for the Goby project.
static bool using_sim_time
Enables simulation time if true (if false, none of the remaining parameters are used)
Definition simulation.h:38
Essentially the same as std::chrono::system_clock except the time returned by SystemClock::now() can ...
static const bool is_steady
std::chrono::time_point< SystemClock > time_point
duration::period period
static time_point now() noexcept
Returns the current system time unless SimulatorSettings::using_sim_time is set to true,...
static goby::time::SystemClock::time_point warp(const std::chrono::system_clock::time_point &real_time)
std::chrono::microseconds duration
Duration type.
static std::chrono::system_clock::time_point unwarp(const goby::time::SystemClock::time_point &sim_time)