_1wire_id.h
Go to the documentation of this file.
#ifndef __utl_com_1wire_id_h__
#define __utl_com_1wire_id_h__
#include <utl/core/impl.h>
#include <utl/container/id.h>
namespace utl {
class _1wire_id_t : public id_t<uint8_t, 8> {
public:
_1wire_id_t () noexcept
: id_t<uint8_t, 8> {0, 0, 0, 0, 0, 0, 0, 0} { }
_1wire_id_t (const _1wire_id_t& id) noexcept {
std::copy(id.begin(), id.end(), this->begin());
}
static constexpr const _1wire_id_t& nullDev () { return nullDev_; }
uint8_t& family() noexcept { return front(); }
const uint8_t& family() const noexcept { return front(); }
uint8_t& crc8() noexcept { return back(); }
const uint8_t& crc8() const noexcept { return back(); }
static int compare (const _1wire_id_t& lhs, const _1wire_id_t& rhs) noexcept {
auto p = std::mismatch (lhs.rbegin(), lhs.rend(), rhs.rbegin());
if (p.first == lhs.rend()) return 0;
else if (*p.first < *p.second) return -1;
else return 1;
}
private:
static const _1wire_id_t nullDev_;
};
// Init static member
const _1wire_id_t _1wire_id_t::nullDev_ { };
} // namespace tbx
#endif /* __utl_com_1wire_id_h__ */
utl::id_t< uint8_t, 8 >::back
reference back() noexcept
Definition: id.h:184
utl::id_t< uint8_t, 8 >::end
iterator end() noexcept
Definition: id.h:109
utl::_1wire_id_t::_1wire_id_t
_1wire_id_t(const _1wire_id_t &id) noexcept
Definition: _1wire_id.h:41
utl::_1wire_id_t::compare
static int compare(const _1wire_id_t &lhs, const _1wire_id_t &rhs) noexcept
Full compare two dev_ids.
Definition: _1wire_id.h:72
utl::id_t< uint8_t, 8 >::front
reference front() noexcept
Definition: id.h:176
utl::_1wire_id_t::crc8
uint8_t & crc8() noexcept
Definition: _1wire_id.h:60
id.h
A container for device IDs.
utl::_1wire_id_t
Definition: _1wire_id.h:32
utl::_1wire_id_t::family
uint8_t & family() noexcept
Definition: _1wire_id.h:54
utl::_1wire_id_t::family
const uint8_t & family() const noexcept
Definition: _1wire_id.h:55
utl::_1wire_id_t::crc8
const uint8_t & crc8() const noexcept
Definition: _1wire_id.h:61
utl
STL&#39;s core language concepts.
Definition: _1wire.h:30
utl::_1wire_id_t::nullDev_
static const _1wire_id_t nullDev_
Definition: _1wire_id.h:83
utl::id_t
A standard container for storing IDs as a fixed size sequence of bytes. This type is based on etl::ar...
Definition: id.h:78
utl::_1wire_id_t::nullDev
static constexpr const _1wire_id_t & nullDev()
Return nullDev reference.
Definition: _1wire_id.h:50
utl::_1wire_id_t::_1wire_id_t
_1wire_id_t() noexcept
Definition: _1wire_id.h:39
utl::id_t< uint8_t, 8 >::begin
iterator begin() noexcept
Definition: id.h:107
impl.h
Implementation detail main forward header.