Goby3  3.1.4
2024.02.22
io.h
Go to the documentation of this file.
1 // Copyright 2009-2021:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 //
8 //
9 // This file is part of the Goby Underwater Autonomy Project Libraries
10 // ("The Goby Libraries").
11 //
12 // The Goby Libraries are free software: you can redistribute them and/or modify
13 // them under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation, either version 2.1 of the License, or
15 // (at your option) any later version.
16 //
17 // The Goby Libraries are distributed in the hope that they will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
24 
25 #ifndef GOBY_TIME_IO_H
26 #define GOBY_TIME_IO_H
27 
28 #include "goby/time/convert.h"
29 #include "goby/time/steady_clock.h"
30 #include "goby/time/system_clock.h"
31 
32 namespace goby
33 {
34 namespace time
35 {
36 inline std::ostream& operator<<(std::ostream& out, const goby::time::SystemClock::time_point& time)
37 {
38  return (out << goby::time::convert<boost::posix_time::ptime>(time));
39 }
40 inline std::ostream& operator<<(std::ostream& out, const goby::time::SteadyClock::time_point& time)
41 {
42  return (out << std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch())
43  .count()
44  << " us");
45 }
46 
47 inline std::ostream& operator<<(std::ostream& out,
48  const goby::time::SystemClock::duration& duration)
49 {
50  return (out << std::chrono::duration_cast<std::chrono::microseconds>(duration).count()
51  << " us");
52 }
53 
54 } // namespace time
55 } // namespace goby
56 
57 using goby::time::operator<<;
58 
59 #endif
system_clock.h
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::time::SystemClock::duration
std::chrono::microseconds duration
Duration type.
Definition: system_clock.h:52
goby::time::SteadyClock::time_point
std::chrono::time_point< SteadyClock > time_point
Definition: steady_clock.h:45
goby::time::SystemClock::time_point
std::chrono::time_point< SystemClock > time_point
Definition: system_clock.h:55
steady_clock.h
convert.h
boost::units::si::time
unit< time_dimension, si::system > time
Definition: time.hpp:22
goby::time::operator<<
std::ostream & operator<<(std::ostream &out, const goby::time::SystemClock::time_point &time)
Definition: io.h:36