diff options
| author | Vidush <vidush.vishwanath@ettus.com> | 2018-06-06 15:57:07 -0700 | 
|---|---|---|
| committer | Martin Braun <martin.braun@ettus.com> | 2018-06-07 10:17:26 -0700 | 
| commit | f08b0160686709a45b0c4ee4a478f4ee016a5798 (patch) | |
| tree | 1fcfaf965a03b0f130ea6cbe3e662559b2a7c604 | |
| parent | 682feb3f6c18fc0780528adfeb8fc59368f9e48e (diff) | |
| download | uhd-f08b0160686709a45b0c4ee4a478f4ee016a5798.tar.gz uhd-f08b0160686709a45b0c4ee4a478f4ee016a5798.tar.bz2 uhd-f08b0160686709a45b0c4ee4a478f4ee016a5798.zip | |
Time_spec: Add Operators
| -rw-r--r-- | host/include/uhd/types/time_spec.hpp | 4 | ||||
| -rw-r--r-- | host/lib/types/time_spec.cpp | 27 | 
2 files changed, 30 insertions, 1 deletions
| diff --git a/host/include/uhd/types/time_spec.hpp b/host/include/uhd/types/time_spec.hpp index 8b05f53b5..a8173d471 100644 --- a/host/include/uhd/types/time_spec.hpp +++ b/host/include/uhd/types/time_spec.hpp @@ -97,7 +97,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 &); 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 <uhd/types/time_spec.hpp> +#include <cmath>   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(), | 
