| USRP Hardware Driver and Device Manual Version: 4.10.0.0 UHD and USRP Manual |

Loading...
Searching...
No Matches
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
22 class UHD_API range_t
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
94 //
95 // For backward-compatibility reasons, we allow the user to initialize
96 // a range like this:
97 // ```cpp
98 // meta_range_t r1{0.0, 2.0};
99 // // Same as:
100 // meta_range_t r2(0.0, 2.0);
101 // ```
102 // Note that for longer initializer lists, this creates a list of ranges:
103 // ```cpp
104 // meta_range_t r1{0.0, 1.0, 2.0, 3.0};
105 // // Same as:
106 // meta_range_t r2{range_t(0.0), range_t(1.0), range_t(2.0), range_t(3.0)};
107 // ```
108 meta_range_t(std::initializer_list<double> il);
109
111 //
112 // This can be used to create a meta_range_t object from a list of ranges
113 // by using initializer list notation:
114 // ```cpp
115 // meta_range_t mr{range_t(0.0, 1.0), range_t(2.0), range_t(3.0, 4.0)};
116 // ```
117 //
118 // A double-braced initializer list is also allowed, but is only recommended
119 // when it is really clear what is meant:
120 // ```cpp
121 // meta_range_t mr{{0.0, 1.0}, range_t(2.0), {3.0, 4.0}};
122 // ```
123 meta_range_t(std::initializer_list<range_t> il) : std::vector<range_t>(il)
124 {
125 /* NOP */
126 }
127
135 meta_range_t(double start, double stop, double step = 0);
136
138 double start(void) const;
139
141 double stop(void) const;
142
144 double step(void) const;
145
152 double clip(double value, bool clip_step = false) const;
153
164 meta_range_t as_monotonic() const;
165
167 std::string to_pp_string(void) const;
168};
169
170 typedef meta_range_t gain_range_t;
171 typedef meta_range_t freq_range_t;
172
173} // namespace uhd
uhd::range_t
Definition ranges.hpp:23
uhd::range_t::range_t
range_t(double value=0)
uhd::range_t::operator!=
bool operator!=(const range_t &other) const
Inequality operator.
uhd::range_t::to_pp_string
std::string to_pp_string(void) const
Convert this range to a printable string.
uhd::range_t::stop
double stop(void) const
Get the stop value for this range.
uhd::range_t::start
double start(void) const
Get the start value for this range.
uhd::range_t::range_t
range_t(double start, double stop, double step=0)
uhd::range_t::operator==
bool operator==(const range_t &other) const
Equality operator.
uhd::range_t::step
double step(void) const
Get the step value for this range.
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
std
STL namespace.
uhd
Definition build_info.hpp:12
uhd::freq_range_t
meta_range_t freq_range_t
Definition ranges.hpp:171
uhd::gain_range_t
meta_range_t gain_range_t
Definition ranges.hpp:170
uhd::meta_range_t
Definition ranges.hpp:67
uhd::meta_range_t::stop
double stop(void) const
Get the overall stop value for this meta-range.
uhd::meta_range_t::as_monotonic
meta_range_t as_monotonic() const
uhd::meta_range_t::step
double step(void) const
Get the overall step value for this meta-range.
uhd::meta_range_t::meta_range_t
meta_range_t(InputIterator first, InputIterator last)
Definition ranges.hpp:82
uhd::meta_range_t::to_pp_string
std::string to_pp_string(void) const
Convert this meta-range to a printable string.
uhd::meta_range_t::meta_range_t
meta_range_t(double start, double stop, double step=0)
uhd::meta_range_t::meta_range_t
meta_range_t(void)
A default constructor for an empty meta-range.
uhd::meta_range_t::meta_range_t
meta_range_t(std::initializer_list< double > il)
Initializer list constructor.
uhd::meta_range_t::start
double start(void) const
Get the overall start value for this meta-range.
uhd::meta_range_t::clip
double clip(double value, bool clip_step=false) const
uhd::meta_range_t::meta_range_t
meta_range_t(std::initializer_list< range_t > il)
Initializer list constructor.
Definition ranges.hpp:123