-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathRfKey.cpp
50 lines (36 loc) · 901 Bytes
/
RfKey.cpp
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
/*
RfKey.cpp - rf data foreach key of device
Saul bertuccio 11 mar 2017
Released into the public domain.
*/
#include "RfKey.h"
const String RfKey::props_names[] = { "name", "length", "code" };
const IsValidFnc RfKey::validations[] = {
&Validation::isValidDeviceName,
&Validation::isValidDeviceKeyLen,
&Validation::isValidDeviceKeyCode
};
RfKey::RfKey(const String & key_name, int len, long int code)
: Key(key_name),
len(len),
code(code)
{}
int RfKey::getLength() {
return len;
}
long int RfKey::getCode() {
return code;
}
String RfKey::getPropertyById(int id) {
switch (id) {
case (0): return getName();
case (1): return String(len);
case (2): return String(code);
default: return String("");
}
}
String RfKey::getPropertyNameById(int id) {
if (id < 0 || id >= RfKey::props_num)
return String("");
return RfKey::props_names[id];
}