AskSin++
HMID.h
1
//- -----------------------------------------------------------------------------------------------------------------------
2
// AskSin++
3
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
4
//- -----------------------------------------------------------------------------------------------------------------------
5
6
#ifndef __HMID_H__
7
#define __HMID_H__
8
9
#include "Atomic.h"
10
#include "Debug.h"
11
12
namespace
as {
13
14
class
HMID
{
15
uint8_t
id
[3];
16
public
:
17
HMID
() {
18
id
[0]=
id
[1]=
id
[2]=0;
19
}
20
HMID
(uint8_t i1, uint8_t i2, uint8_t i3) {
21
id
[0]=i1;
22
id
[1]=i2;
23
id
[2]=i3;
24
}
25
HMID
(uint8_t* ptr) {
26
id
[0]=*ptr;
27
id
[1]=*(ptr+1);
28
id
[2]=*(ptr+2);
29
}
30
HMID
(
const
HMID
& other) {
31
id
[0]=other.id[0];
32
id
[1]=other.id[1];
33
id
[2]=other.id[2];
34
}
35
HMID
& operator = (
const
HMID
& other) {
36
id
[0]=other.id[0];
37
id
[1]=other.id[1];
38
id
[2]=other.id[2];
39
return
*
this
;
40
}
41
bool
operator == (
const
HMID
& other)
const
{
42
return
id
[0]==other.id[0] &&
id
[1]==other.id[1] &&
id
[2]==other.id[2];
43
}
44
bool
operator != (
const
HMID
& other)
const
{
45
return
(
operator
== (other)) ==
false
;
46
}
47
bool
valid()
const
{
48
return
id
[0]!=0 ||
id
[1]!=0 ||
id
[2]!=0;
49
}
50
uint8_t id0 ()
const
{
return
id
[0]; };
51
uint8_t id1 ()
const
{
return
id
[1]; };
52
uint8_t id2 ()
const
{
return
id
[2]; };
53
54
operator
uint32_t ()
const
{
55
return
(uint32_t)
id
[0] << 16 | (uint16_t)
id
[1] << 8 |
id
[2];
56
}
57
58
void
dump ()
const
{
59
DHEX(id0());
60
DHEX(id1());
61
DHEX(id2());
62
}
63
64
static
HMID
broadcast;
65
};
66
67
}
68
69
#endif
as::HMID
Definition:
HMID.h:14
Generated by
1.8.20