obu-firmware builds against the vanetza-idf C-ITS library, which until now came from the colleague's microbu-esp32c5 tree beside the repository and was not tracked here, so a clone of this repository could not build the firmware it ships. The library alone is now part of obu-firmware, as obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from there by default; -DVANETZA_IDF_DIR still points the build elsewhere. The rest of the colleague's tree (their own VAM firmware, PKI tooling, station-link Python tools, the V2X2MAP bridge) stays out of this repository and gitignored; nothing is pushed to their repository. NOTES.md, docs/06, TODO.md and the pcap verifier's usage line point at the new location.
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#ifndef BIT_NUMBER_HPP_H3ODBQR7
|
|
#define BIT_NUMBER_HPP_H3ODBQR7
|
|
|
|
#include <boost/operators.hpp>
|
|
#include <cstddef>
|
|
#include <type_traits>
|
|
|
|
namespace vanetza {
|
|
|
|
/**
|
|
* BitNumber restricts the value range by the given width
|
|
*
|
|
* \tparam T underlying integral type
|
|
* \tparam WIDTH number of bits used to represent a number
|
|
*/
|
|
template<typename T, std::size_t WIDTH>
|
|
class BitNumber : public boost::totally_ordered<BitNumber<T, WIDTH>>
|
|
{
|
|
static_assert(std::is_integral<T>::value == true,
|
|
"only integral types are supported");
|
|
static_assert(sizeof(T) * 8 > WIDTH,
|
|
"width has to be less than size of underlying type");
|
|
|
|
public:
|
|
static constexpr T mask = (1 << WIDTH) - 1; /**< excessive bits are masked */
|
|
static constexpr std::size_t bits = WIDTH; /**< number of bits used */
|
|
typedef T value_type; /**< underlying (integral) value type */
|
|
|
|
BitNumber() : mValue(0) {}
|
|
BitNumber(T value) : mValue(value & mask) {}
|
|
BitNumber& operator=(T value) { mValue = value & mask; return *this; }
|
|
T raw() const { return mValue; }
|
|
|
|
bool operator<(BitNumber other) const { return mValue < other.mValue; }
|
|
bool operator==(BitNumber other) const { return mValue == other.mValue; }
|
|
|
|
private:
|
|
T mValue;
|
|
};
|
|
|
|
} // namespace vanetza
|
|
|
|
#endif /* BIT_NUMBER_HPP_H3ODBQR7 */
|
|
|