USRP Hardware Driver and Device Manual Version: 4.10.0.0_release
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
16namespace uhd {
17
23{
24public:
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
59private:
60 double _start, _stop, _step;
61};
62
66struct UHD_API meta_range_t : public std::vector<range_t>
67{
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
165
167 std::string to_pp_string(void) const;
168};
169
172
173} // 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
STL namespace.
Definition build_info.hpp:12
meta_range_t freq_range_t
Definition ranges.hpp:171
meta_range_t gain_range_t
Definition ranges.hpp:170
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:123