All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
time_spec.hpp
Go to the documentation of this file.
//
// Copyright 2010-2012 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef INCLUDED_UHD_TYPES_TIME_SPEC_HPP
#define INCLUDED_UHD_TYPES_TIME_SPEC_HPP
#include <uhd/config.hpp>
#include <boost/operators.hpp>
#include <ctime>
namespace uhd{
class UHD_API time_spec_t : boost::additive<time_spec_t>, boost::totally_ordered<time_spec_t>{
public:
static time_spec_t get_system_time(void);
time_spec_t(double secs = 0);
time_spec_t(time_t full_secs, double frac_secs = 0);
time_spec_t(time_t full_secs, long tick_count, double tick_rate);
static time_spec_t from_ticks(long long ticks, double tick_rate);
long get_tick_count(double tick_rate) const;
long long to_ticks(const double tick_rate) const;
double get_real_secs(void) const;
time_t get_full_secs(void) const;
double get_frac_secs(void) const;
time_spec_t &operator+=(const time_spec_t &);
time_spec_t &operator-=(const time_spec_t &);
//private time storage details
private: time_t _full_secs; double _frac_secs;
};
UHD_API bool operator==(const time_spec_t &, const time_spec_t &);
UHD_API bool operator<(const time_spec_t &, const time_spec_t &);
UHD_INLINE time_t time_spec_t::get_full_secs(void) const{
return this->_full_secs;
}
UHD_INLINE double time_spec_t::get_frac_secs(void) const{
return this->_frac_secs;
}
} //namespace uhd
#endif /* INCLUDED_UHD_TYPES_TIME_SPEC_HPP */