Loading...
Searching...
No Matches
compat_check.hpp
Go to the documentation of this file.
//
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/config.hpp>
#include <cstddef>
#include <cstdint>
#include <string>
namespace uhd {
template <typename major_type, typename minor_type>
class UHD_API_HEADER compat_num
{
public:
constexpr compat_num(major_type major, minor_type minor)
: _major(major), _minor(minor)
{
}
major_type get_major() const
{
return _major;
}
major_type get_minor() const
{
return _minor;
}
bool operator==(const compat_num<major_type, minor_type>& rhs) const
{
return _major == rhs.get_major() && _minor == rhs.get_minor();
}
bool operator!=(const compat_num<major_type, minor_type>& rhs) const
{
return !(*this == rhs);
}
bool operator<(const compat_num<major_type, minor_type>& rhs) const
{
return _major < rhs.get_major()
|| (_major == rhs.get_major() && _minor < rhs.get_minor());
}
bool operator<=(const compat_num<major_type, minor_type>& rhs) const
{
return *this == rhs || *this < rhs;
}
bool operator>(const compat_num<major_type, minor_type>& rhs) const
{
return _major > rhs.get_major()
|| (_major == rhs.get_major() && _minor > rhs.get_minor());
}
bool operator>=(const compat_num<major_type, minor_type>& rhs) const
{
return *this == rhs || *this > rhs;
}
std::string to_string() const
{
return std::to_string(_major) + ":" + std::to_string(_minor);
}
protected:
major_type _major;
minor_type _minor;
};
class UHD_API_HEADER compat_num16 : public compat_num<uint8_t, uint8_t>
{
public:
compat_num16(const uint16_t compat_val)
: compat_num<uint8_t, uint8_t>((compat_val >> 8) & 0xFF, compat_val & 0xFF)
{
}
compat_num16(const uint8_t major, const uint8_t minor)
: compat_num<uint8_t, uint8_t>(major, minor)
{
}
uint16_t get() const
{
return static_cast<uint16_t>(_major) << 8 | _minor;
};
};
class UHD_API_HEADER compat_num32 : public compat_num<uint16_t, uint16_t>
{
public:
constexpr compat_num32(const uint32_t compat_val)
: compat_num<uint16_t, uint16_t>((compat_val >> 16) & 0xFFFF, compat_val & 0xFFFF)
{
}
constexpr compat_num32(const uint16_t major, const uint16_t minor)
: compat_num<uint16_t, uint16_t>(major, minor)
{
}
uint32_t get() const
{
return static_cast<uint32_t>(_major) << 16 | _minor;
};
};
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);
void UHD_API assert_fpga_compat(const size_t uhd_major,
const size_t uhd_minor,
const uint32_t fpga_compat,
const std::string& fpga_component,
const std::string& log_component,
const bool fail_on_minor_behind = false);
} /* 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)