USRP Hardware Driver and USRP Manual  Version: 4.7.0.0
UHD and USRP Manual
time_spec.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2012 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #pragma once
9 
10 #include <uhd/config.hpp>
11 #include <stdint.h>
12 #include <boost/operators.hpp>
13 
14 namespace uhd {
15 
28 class UHD_API time_spec_t : boost::additive<time_spec_t>,
29  boost::additive<time_spec_t, double>,
30  boost::totally_ordered<time_spec_t>
31 {
32 public:
33  // A special value that signifies immediate execution
34  static constexpr double ASAP = 0.0;
35 
40  time_spec_t(double secs = 0);
41 
47  time_spec_t(int64_t full_secs, double frac_secs = 0);
48 
56  time_spec_t(int64_t full_secs, long tick_count, double tick_rate);
57 
64  static time_spec_t from_ticks(long long ticks, double tick_rate);
65 
72  long get_tick_count(double tick_rate) const;
73 
80  long long to_ticks(const double tick_rate) const;
81 
88  double get_real_secs(void) const;
89 
94  int64_t get_full_secs(void) const;
95 
100  double get_frac_secs(void) const;
101 
103  time_spec_t& operator+=(const time_spec_t&);
104  time_spec_t& operator+=(double&);
106  time_spec_t& operator-=(const time_spec_t&);
107  time_spec_t& operator-=(double&);
108 
109  // private time storage details
110 private:
111  int64_t _full_secs;
112  double _frac_secs;
113 };
114 
116 UHD_API bool operator==(const time_spec_t&, const time_spec_t&);
117 
119 UHD_API bool operator<(const time_spec_t&, const time_spec_t&);
120 
122 {
123  return this->_full_secs;
124 }
125 
127 {
128  return this->_frac_secs;
129 }
130 
131 } // namespace uhd
Definition: time_spec.hpp:28
Definition: build_info.hpp:12
#define UHD_INLINE
Definition: config.h:65
UHD_API bool operator<(const time_spec_t &, const time_spec_t &)
Implement less_than_comparable interface.
#define UHD_API
Definition: config.h:87
double get_frac_secs(void) const
Definition: time_spec.hpp:126
UHD_API bool operator==(const time_spec_t &, const time_spec_t &)
Implement equality_comparable interface.
int64_t get_full_secs(void) const
Definition: time_spec.hpp:121