From f08b0160686709a45b0c4ee4a478f4ee016a5798 Mon Sep 17 00:00:00 2001 From: Vidush Date: Wed, 6 Jun 2018 15:57:07 -0700 Subject: Time_spec: Add Operators --- host/lib/types/time_spec.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'host/lib/types') diff --git a/host/lib/types/time_spec.cpp b/host/lib/types/time_spec.cpp index aae6a6121..124b08ac9 100644 --- a/host/lib/types/time_spec.cpp +++ b/host/lib/types/time_spec.cpp @@ -6,6 +6,7 @@ // #include +#include using namespace uhd; @@ -81,6 +82,32 @@ 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; +} + +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; +} + +time_spec_t &time_spec_t::operator+(const time_spec_t &rhs){ + time_spec_init( + this->get_full_secs() + rhs.get_full_secs(), + this->get_frac_secs() + rhs.get_frac_secs() + ); + return *this; +} + time_spec_t &time_spec_t::operator-=(const time_spec_t &rhs){ time_spec_init( this->get_full_secs() - rhs.get_full_secs(), -- cgit v1.2.3