diff options
author | Mark Meserve <mark.meserve@ni.com> | 2018-09-26 16:24:35 -0500 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2018-09-28 08:57:55 +0200 |
commit | 35de0467ca9ff44d24f3387df065313c6efc7545 (patch) | |
tree | 2f6e469b56132bc3afaf1d7b6fb1c4ba519bb274 /host | |
parent | 30a6f954e2405b6e580b9beb2ce1761866641ec2 (diff) | |
download | uhd-35de0467ca9ff44d24f3387df065313c6efc7545.tar.gz uhd-35de0467ca9ff44d24f3387df065313c6efc7545.tar.bz2 uhd-35de0467ca9ff44d24f3387df065313c6efc7545.zip |
uhd: reconcile time_spec operators with boost concepts
- Removes operator+ which was ambiguously defined in some cases
- Adds additive concept for time_spec_t and double operators
- Remove unnecessary ctime header
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/types/time_spec.hpp | 9 | ||||
-rw-r--r-- | host/lib/types/time_spec.cpp | 23 |
2 files changed, 14 insertions, 18 deletions
diff --git a/host/include/uhd/types/time_spec.hpp b/host/include/uhd/types/time_spec.hpp index 54fd9d379..8c0a2568d 100644 --- a/host/include/uhd/types/time_spec.hpp +++ b/host/include/uhd/types/time_spec.hpp @@ -10,7 +10,6 @@ #include <uhd/config.hpp> #include <boost/operators.hpp> -#include <ctime> namespace uhd{ @@ -26,7 +25,10 @@ namespace uhd{ * This gives the fractional seconds enough precision to unambiguously * specify a clock-tick/sample-count up to rates of several petahertz. */ - class UHD_API time_spec_t : boost::additive<time_spec_t>, boost::totally_ordered<time_spec_t>{ + class UHD_API time_spec_t : + boost::additive<time_spec_t>, + boost::additive<time_spec_t, double>, + boost::totally_ordered<time_spec_t>{ public: /*! @@ -98,10 +100,9 @@ namespace uhd{ //! Implement addable interface time_spec_t &operator+=(const time_spec_t &); time_spec_t &operator+=(double &); - time_spec_t operator+(double &); - time_spec_t operator+(const time_spec_t &); //! Implement subtractable interface time_spec_t &operator-=(const time_spec_t &); + time_spec_t &operator-=(double &); //private time storage details private: diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp index 403c3336c..c07ab8525 100644 --- a/host/lib/types/time_spec.cpp +++ b/host/lib/types/time_spec.cpp @@ -91,20 +91,6 @@ time_spec_t &time_spec_t::operator+=(double &rhs){ return *this; } -time_spec_t time_spec_t::operator+(double &rhs){ - double full_secs = std::trunc(rhs); - time_spec_t toRet(this->get_full_secs() + full_secs, - this->get_frac_secs() + rhs - full_secs); - return toRet; -} - -time_spec_t time_spec_t::operator+(const time_spec_t &rhs){ - time_spec_t toRet( - this->get_full_secs() + rhs.get_full_secs(), - this->get_frac_secs() + rhs.get_frac_secs()); - return toRet; -} - time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){ time_spec_init( this->get_full_secs() - rhs.get_full_secs(), @@ -113,6 +99,15 @@ time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){ return *this; } +time_spec_t &time_spec_t::operator-=(double &rhs) { + double full_secs = std::trunc(rhs); + time_spec_init( + this->get_full_secs() - full_secs, + this->get_frac_secs() - (rhs - full_secs) + ); + return *this; +} + bool uhd::operator==(const time_spec_t &lhs, const time_spec_t &rhs){ return lhs.get_full_secs() == rhs.get_full_secs() and |