MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
descriptor_id.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 
6 namespace mip
7 {
8 
15 {
16 public:
17  DescriptorId() : m_key(0) {}
18  DescriptorId(uint8_t desc_set, uint8_t field_desc, uint16_t index=0) : DescriptorId({desc_set, field_desc}, index) {}
19  DescriptorId(CompositeDescriptor desc, uint16_t index=0) : m_key(uint32_t(desc.as_u16() << 16) | index) {}
20  //DescriptorId(uint16_t index) : m_key(index) {}
21  DescriptorId(uint32_t id) : m_key(id) {}
22 
23  bool isNull() const { return m_key == 0x00000000; }
24 
25  bool isMip() const { return descriptor().as_u16() != 0x0000; }
26  bool isNonMip() const { return !isMip(); }
27 
28  CompositeDescriptor descriptor() const { return m_key >> 16; }
29  uint16_t index() const { return m_key & 0xFFFF; }
30  uint32_t asU32() const { return m_key; }
31 
32  bool operator==(const DescriptorId& other) const { return m_key == other.m_key; }
33  bool operator!=(const DescriptorId& other) const { return m_key != other.m_key; }
34  bool operator<=(const DescriptorId& other) const { return m_key <= other.m_key; }
35  bool operator>=(const DescriptorId& other) const { return m_key >= other.m_key; }
36  bool operator< (const DescriptorId& other) const { return m_key < other.m_key; }
37  bool operator> (const DescriptorId& other) const { return m_key > other.m_key; }
38 
39 private:
40  uint32_t m_key;
41 };
42 
43 } // namespace mip
mip
A collection of C++ classes and functions covering the full mip api.
Definition: commands_3dm.c:11
mip_descriptors.hpp
mip::DescriptorId::isMip
bool isMip() const
Definition: descriptor_id.hpp:25
mip::DescriptorId::index
uint16_t index() const
Definition: descriptor_id.hpp:29
mip::DescriptorId::DescriptorId
DescriptorId()
Definition: descriptor_id.hpp:17
mip::DescriptorId::DescriptorId
DescriptorId(uint8_t desc_set, uint8_t field_desc, uint16_t index=0)
Definition: descriptor_id.hpp:18
mip::DescriptorId::descriptor
CompositeDescriptor descriptor() const
Definition: descriptor_id.hpp:28
mip::DescriptorId::operator>
bool operator>(const DescriptorId &other) const
Definition: descriptor_id.hpp:37
mip::DescriptorId
A combination of a MIP descriptor pair and u16 ID value.
Definition: descriptor_id.hpp:14
mip::DescriptorId::operator<
bool operator<(const DescriptorId &other) const
Definition: descriptor_id.hpp:36
mip::DescriptorId::isNonMip
bool isNonMip() const
Definition: descriptor_id.hpp:26
mip::DescriptorId::operator!=
bool operator!=(const DescriptorId &other) const
Definition: descriptor_id.hpp:33
mip::CompositeDescriptor::as_u16
constexpr uint16_t as_u16() const
Definition: mip_descriptors.hpp:32
mip::DescriptorId::asU32
uint32_t asU32() const
Definition: descriptor_id.hpp:30
mip::DescriptorId::DescriptorId
DescriptorId(uint32_t id)
Definition: descriptor_id.hpp:21
mip::CompositeDescriptor
Convenience struct holding both descriptor set and field descriptor.
Definition: mip_descriptors.hpp:22
mip::DescriptorId::operator==
bool operator==(const DescriptorId &other) const
Definition: descriptor_id.hpp:32
mip::DescriptorId::DescriptorId
DescriptorId(CompositeDescriptor desc, uint16_t index=0)
Definition: descriptor_id.hpp:19
mip::DescriptorId::isNull
bool isNull() const
Definition: descriptor_id.hpp:23
mip::DescriptorId::operator>=
bool operator>=(const DescriptorId &other) const
Definition: descriptor_id.hpp:35
mip::DescriptorId::operator<=
bool operator<=(const DescriptorId &other) const
Definition: descriptor_id.hpp:34