From 74f371fcd3ec126d132fdf69b4f504e6157a6147 Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Wed, 9 Mar 2022 14:54:31 -0600 Subject: host: Create meta_range_t::as_monotonic In order to perform certain operations (start/stop/step), meta_range_t objects must be "monotonic", meaning that the subranges composing it are sorted and non-overlapping. This commit creates a method which takes a non-monotonic meta_range_t containing no non-continuous subranges and converts it into a monotonic meta_range_t. --- host/include/uhd/types/ranges.hpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'host/include') diff --git a/host/include/uhd/types/ranges.hpp b/host/include/uhd/types/ranges.hpp index 05aa0fa7c..72eaa0221 100644 --- a/host/include/uhd/types/ranges.hpp +++ b/host/include/uhd/types/ranges.hpp @@ -62,7 +62,7 @@ private: /*! * A meta-range object holds a list of individual ranges. */ -struct UHD_API meta_range_t : std::vector +struct UHD_API meta_range_t : public std::vector { //! A default constructor for an empty meta-range meta_range_t(void); @@ -113,6 +113,18 @@ struct UHD_API meta_range_t : std::vector */ double clip(double value, bool clip_step = false) const; + /*! + * A method for converting an arbitrary meta_range_t into a monotonic + * meta_range_t which has no overlapping ranges, and where all ranges + * are sorted. + * + * Requires that all subranges have a step size of zero, or else it + * throws uhd::value_error. + * + * \return a monotonic meta_range_t + */ + meta_range_t as_monotonic() const; + //! Convert this meta-range to a printable string const std::string to_pp_string(void) const; }; -- cgit v1.2.3