USRP Hardware Driver and USRP Manual  Version: 003.009.006-0-g122d5f8e
UHD and USRP Manual
time_spec.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2012 Ettus Research LLC
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 //
17 
18 #ifndef INCLUDED_UHD_TYPES_TIME_SPEC_HPP
19 #define INCLUDED_UHD_TYPES_TIME_SPEC_HPP
20 
21 #include <uhd/config.hpp>
22 #include <boost/operators.hpp>
23 #include <ctime>
24 
25 namespace uhd{
26 
39  class UHD_API time_spec_t : boost::additive<time_spec_t>, boost::totally_ordered<time_spec_t>{
40  public:
41 
47  static time_spec_t get_system_time(void);
48 
53  time_spec_t(double secs = 0);
54 
60  time_spec_t(time_t full_secs, double frac_secs = 0);
61 
69  time_spec_t(time_t full_secs, long tick_count, double tick_rate);
70 
77  static time_spec_t from_ticks(long long ticks, double tick_rate);
78 
85  long get_tick_count(double tick_rate) const;
86 
93  long long to_ticks(const double tick_rate) const;
94 
101  double get_real_secs(void) const;
102 
107  time_t get_full_secs(void) const;
108 
113  double get_frac_secs(void) const;
114 
116  time_spec_t &operator+=(const time_spec_t &);
117 
119  time_spec_t &operator-=(const time_spec_t &);
120 
121  //private time storage details
122  private: time_t _full_secs; double _frac_secs;
123  };
124 
126  UHD_API bool operator==(const time_spec_t &, const time_spec_t &);
127 
129  UHD_API bool operator<(const time_spec_t &, const time_spec_t &);
130 
132  return this->_full_secs;
133  }
134 
136  return this->_frac_secs;
137  }
138 
139 } //namespace uhd
140 
141 #endif /* INCLUDED_UHD_TYPES_TIME_SPEC_HPP */
Definition: time_spec.hpp:39
Definition: convert.hpp:28
#define UHD_INLINE
Definition: config.h:56
UHD_API bool operator<(const time_spec_t &, const time_spec_t &)
Implement less_than_comparable interface.
#define UHD_API
Definition: config.h:66
double get_frac_secs(void) const
Definition: time_spec.hpp:135
UHD_API bool operator==(const time_spec_t &, const time_spec_t &)
Implement equality_comparable interface.
time_t get_full_secs(void) const
Definition: time_spec.hpp:131