-
Notifications
You must be signed in to change notification settings - Fork 0
/
AlphaPacket.h
48 lines (38 loc) · 893 Bytes
/
AlphaPacket.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
/*
* AlphaProtocol.h
*
* Created on: Nov 21, 2012
* Author: nathan
*/
#ifndef ALPHAPACKET_H_
#define ALPHAPACKET_H_
#include "Field.h"
class AlphaPacket : public Field
{
private:
char mode;
public:
AlphaPacket();
//default: Z- appears to refer to "All Signs"
AlphaPacket& updateTypeCode(char code = 'Z');
//default: 00. appears to be broadcast address.
AlphaPacket& updateAddress(char first = '0', char second = '0');
//Gets the command and data field. These shouldn't be used directly- the
//various interfaces manage these themselves.
Field& commandCode();
Field& dataField();
//Gets an interface to a mode. Switches to and initializes that mode, if
//necessary
template<class T>
T command()
{
T command(*this);
if(mode != T::commandCode)
{
mode = T::commandCode;
command.initCommand();
}
return command;
}
};
#endif /* ALPHAPACKET_H_ */