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