| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
compat_check.hpp
Go to the documentation of this file.
1//
2// Copyright 2018 Ettus Research, a National Instruments Company
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7#pragma once
8
9#include <uhd/config.hpp>
10#include <cstddef>
11#include <cstdint>
12#include <string>
13
14 namespace uhd {
15
17 template <typename major_type, typename minor_type>
18 class UHD_API_HEADER compat_num
19{
20 public:
21 constexpr compat_num(major_type major, minor_type minor)
22 : _major(major), _minor(minor)
23 {
24 }
25
26 major_type get_major() const
27 {
28 return _major;
29 }
30 major_type get_minor() const
31 {
32 return _minor;
33 }
34
35 bool operator==(const compat_num<major_type, minor_type>& rhs) const
36 {
37 return _major == rhs.get_major() && _minor == rhs.get_minor();
38 }
39
40 bool operator!=(const compat_num<major_type, minor_type>& rhs) const
41 {
42 return !(*this == rhs);
43 }
44
45 bool operator<(const compat_num<major_type, minor_type>& rhs) const
46 {
47 return _major < rhs.get_major()
48 || (_major == rhs.get_major() && _minor < rhs.get_minor());
49 }
50
51 bool operator<=(const compat_num<major_type, minor_type>& rhs) const
52 {
53 return *this == rhs || *this < rhs;
54 }
55
56 bool operator>(const compat_num<major_type, minor_type>& rhs) const
57 {
58 return _major > rhs.get_major()
59 || (_major == rhs.get_major() && _minor > rhs.get_minor());
60 }
61
62 bool operator>=(const compat_num<major_type, minor_type>& rhs) const
63 {
64 return *this == rhs || *this > rhs;
65 }
66
67 std::string to_string() const
68 {
69 return std::to_string(_major) + ":" + std::to_string(_minor);
70 }
71
72 protected:
73 major_type _major;
74 minor_type _minor;
75};
76
78 class UHD_API_HEADER compat_num16 : public compat_num<uint8_t, uint8_t>
79{
80 public:
81 compat_num16(const uint16_t compat_val)
82 : compat_num<uint8_t, uint8_t>((compat_val >> 8) & 0xFF, compat_val & 0xFF)
83 {
84 }
85
86 compat_num16(const uint8_t major, const uint8_t minor)
87 : compat_num<uint8_t, uint8_t>(major, minor)
88 {
89 }
90
91 uint16_t get() const
92 {
93 return static_cast<uint16_t>(_major) << 8 | _minor;
94 };
95};
96
98 class UHD_API_HEADER compat_num32 : public compat_num<uint16_t, uint16_t>
99{
100 public:
101 constexpr compat_num32(const uint32_t compat_val)
102 : compat_num<uint16_t, uint16_t>((compat_val >> 16) & 0xFFFF, compat_val & 0xFFFF)
103 {
104 }
105
106 constexpr compat_num32(const uint16_t major, const uint16_t minor)
107 : compat_num<uint16_t, uint16_t>(major, minor)
108 {
109 }
110
111 uint32_t get() const
112 {
113 return static_cast<uint32_t>(_major) << 16 | _minor;
114 };
115};
116
121 void UHD_API assert_fpga_compat(const size_t uhd_major,
122 const size_t uhd_minor,
123 const uint64_t fpga_compat,
124 const std::string& fpga_component,
125 const std::string& log_component,
126 const bool fail_on_minor_behind = false);
127
132 void UHD_API assert_fpga_compat(const size_t uhd_major,
133 const size_t uhd_minor,
134 const uint32_t fpga_compat,
135 const std::string& fpga_component,
136 const std::string& log_component,
137 const bool fail_on_minor_behind = false);
138
139} /* namespace uhd */
uhd::compat_num16::compat_num16
compat_num16(const uint8_t major, const uint8_t minor)
Definition compat_check.hpp:86
uhd::compat_num16::compat_num16
compat_num16(const uint16_t compat_val)
Definition compat_check.hpp:81
uhd::compat_num16::get
uint16_t get() const
Definition compat_check.hpp:91
uhd::compat_num32::get
uint32_t get() const
Definition compat_check.hpp:111
uhd::compat_num32::compat_num32
constexpr compat_num32(const uint16_t major, const uint16_t minor)
Definition compat_check.hpp:106
uhd::compat_num32::compat_num32
constexpr compat_num32(const uint32_t compat_val)
Definition compat_check.hpp:101
uhd::compat_num::_major
major_type _major
Definition compat_check.hpp:73
uhd::compat_num::compat_num
constexpr compat_num(major_type major, minor_type minor)
Definition compat_check.hpp:21
uhd::compat_num::operator>
bool operator>(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:56
uhd::compat_num::get_major
major_type get_major() const
Definition compat_check.hpp:26
uhd::compat_num::_minor
minor_type _minor
Definition compat_check.hpp:74
uhd::compat_num::operator>=
bool operator>=(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:62
uhd::compat_num::operator<
bool operator<(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:45
uhd::compat_num::operator==
bool operator==(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:35
uhd::compat_num::operator<=
bool operator<=(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:51
uhd::compat_num::operator!=
bool operator!=(const compat_num< major_type, minor_type > &rhs) const
Definition compat_check.hpp:40
uhd::compat_num::get_minor
major_type get_minor() const
Definition compat_check.hpp:30
uhd::compat_num::to_string
std::string to_string() const
Definition compat_check.hpp:67
UHD_API_HEADER
#define UHD_API_HEADER
Definition config.h:88
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
uhd
Definition build_info.hpp:12
uhd::assert_fpga_compat
void UHD_API assert_fpga_compat(const size_t uhd_major, const size_t uhd_minor, const uint64_t fpga_compat, const std::string &fpga_component, const std::string &log_component, const bool fail_on_minor_behind=false)