USRP Hardware Driver and Device Manual  Version: 4.11.0.0-0-g0d7ed3b1
UHD and USRP Manual
ranges.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2012 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #pragma once
9 
10 #include <uhd/config.hpp>
11 #include <initializer_list>
12 #include <type_traits>
13 #include <string>
14 #include <vector>
15 
16 namespace uhd {
17 
23 {
24 public:
30  range_t(double value = 0);
31 
39  range_t(double start, double stop, double step = 0);
40 
42  double start(void) const;
43 
45  double stop(void) const;
46 
48  double step(void) const;
49 
51  std::string to_pp_string(void) const;
52 
54  bool operator==(const range_t& other) const;
55 
57  bool operator!=(const range_t& other) const;
58 
59 private:
60  double _start, _stop, _step;
61 };
62 
66 struct UHD_API meta_range_t : public std::vector<range_t>
67 {
69  meta_range_t(void);
70 
81  template <typename InputIterator>
82  meta_range_t(InputIterator first, InputIterator last)
83  : std::vector<range_t>(first, last)
84  { /* NOP */
85  // This is to avoid people accidentally doing silly things like:
86  // meta_range_t(0, 0)
87  // which probably was supposed to call meta_range_t(double, double, double)
88  // but actually calls this constructor.
89  static_assert(!std::is_integral<typename std::decay<InputIterator>::type>::value,
90  "You can't pass integers to meta_range_t's constructor!");
91  }
92 
109  meta_range_t(std::initializer_list<double> il);
110 
125  meta_range_t(std::initializer_list<range_t> il) : std::vector<range_t>(il)
126  {
127  /* NOP */
128  }
129 
137  meta_range_t(double start, double stop, double step = 0);
138 
140  double start(void) const;
141 
143  double stop(void) const;
144 
146  double step(void) const;
147 
154  double clip(double value, bool clip_step = false) const;
155 
167 
169  std::string to_pp_string(void) const;
170 };
171 
174 
175 } // namespace uhd
Definition: ranges.hpp:23
range_t(double value=0)
bool operator!=(const range_t &other) const
Inequality operator.
std::string to_pp_string(void) const
Convert this range to a printable string.
double stop(void) const
Get the stop value for this range.
double start(void) const
Get the start value for this range.
range_t(double start, double stop, double step=0)
bool operator==(const range_t &other) const
Equality operator.
double step(void) const
Get the step value for this range.
#define UHD_API
Definition: config.h:87
Definition: build_info.hpp:12
meta_range_t freq_range_t
Definition: ranges.hpp:173
meta_range_t gain_range_t
Definition: ranges.hpp:172
Definition: ranges.hpp:67
double stop(void) const
Get the overall stop value for this meta-range.
meta_range_t as_monotonic() const
double step(void) const
Get the overall step value for this meta-range.
meta_range_t(InputIterator first, InputIterator last)
Definition: ranges.hpp:82
std::string to_pp_string(void) const
Convert this meta-range to a printable string.
meta_range_t(double start, double stop, double step=0)
meta_range_t(void)
A default constructor for an empty meta-range.
meta_range_t(std::initializer_list< double > il)
Initializer list constructor.
double start(void) const
Get the overall start value for this meta-range.
double clip(double value, bool clip_step=false) const
meta_range_t(std::initializer_list< range_t > il)
Initializer list constructor.
Definition: ranges.hpp:125