Virtual Testbed
Ship dynamics simulator for extreme conditions
timestamp.hh
1 #ifndef VTESTBED_IGES_TIMESTAMP_HH
2 #define VTESTBED_IGES_TIMESTAMP_HH
3 
4 #include <chrono>
5 #include <iosfwd>
6 
7 #include <vtestbed/iges/types.hh>
8 
9 namespace vtb {
10 
11  namespace iges {
12 
14  struct timestamp: public std::chrono::system_clock::time_point {
15 
17  typedef clock::time_point time_point;
18  typedef clock::duration duration;
19  using time_point::time_point;
20 
21  struct iges_date_pp {
22  const timestamp& date;
23  };
24 
25  timestamp() = default;
26  ~timestamp() = default;
27 
28  inline
29  timestamp(const time_point& tp):
30  time_point(tp) {}
31 
32  timestamp&
33  operator=(const time_point& rhs) {
34  time_point::operator=(rhs);
35  return *this;
36  }
37 
38  inline void
39  clear() {
40  *this = time_point{duration::zero()};
41  }
42 
43  inline bool
44  empty() const noexcept {
45  return *this == time_point{duration::zero()};
46  }
47 
48  inline iges_date_pp
49  print() const {
50  return {*this};
51  }
52 
53  };
54 
56  operator<<(std::ostream& out, const timestamp& rhs);
57 
59  operator>>(std::istream& in, timestamp& rhs);
60 
62  operator<<(std::ostream& out, const timestamp::iges_date_pp& rhs);
63 
64  iges_ostream&
65  operator<<(iges_ostream& out, const timestamp& rhs);
66 
67  }
68 
69 }
70 
71 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9
IGES timestamp.
Definition: timestamp.hh:14