Goby3 3.3.0
2025.07.10
Loading...
Searching...
No Matches
asio.h
Go to the documentation of this file.
1// Copyright 2020-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_ASIO_H
25#define GOBY_TIME_ASIO_H
26
27#include <boost/asio/time_traits.hpp>
28#include <boost/date_time.hpp>
29
30namespace goby
31{
32namespace time
33{
34// dummy struct for use with boost::asio::time_traits
36{
37};
38
39} // namespace time
40} // namespace goby
41
42namespace boost
43{
44namespace asio
45{
47template <> struct time_traits<goby::time::ASIOGobyTime>
48{
50 typedef boost::posix_time::ptime time_type;
51
53 typedef boost::posix_time::time_duration duration_type;
54
56 static time_type now() { return goby::time::SystemClock::now<boost::posix_time::ptime>(); }
57
59 static time_type add(const time_type& t, const duration_type& d) { return t + d; }
60
62 static duration_type subtract(const time_type& t1, const time_type& t2) { return t1 - t2; }
63
65 static bool less_than(const time_type& t1, const time_type& t2) { return t1 < t2; }
66
68 static boost::posix_time::time_duration to_posix_duration(const duration_type& d)
69 {
71 }
72};
73} // namespace asio
74} // namespace boost
75
76#endif
The global namespace for the Goby project.
static time_type add(const time_type &t, const duration_type &d)
Add a duration to a time.
Definition asio.h:59
boost::posix_time::time_duration duration_type
The duration type.
Definition asio.h:53
static boost::posix_time::time_duration to_posix_duration(const duration_type &d)
Convert to POSIX duration type.
Definition asio.h:68
static bool less_than(const time_type &t1, const time_type &t2)
Test whether one time is less than another.
Definition asio.h:65
static duration_type subtract(const time_type &t1, const time_type &t2)
Subtract one time from another.
Definition asio.h:62
static time_type now()
Get the current time.
Definition asio.h:56
boost::posix_time::ptime time_type
The time type.
Definition asio.h:50
static int warp_factor
Warp factor to speed up (or slow time) the time values returned by SteadyClock::now() and SystemClock...
Definition simulation.h:40