edits
[iotcloud.git] / version2 / src / C / NewKey.h
1
2
3 /**
4  * This Entry records the abort sent by a given machine.
5  * @author Ali Younis <ayounis@uci.edu>
6  * @version 1.0
7  */
8
9
10 class NewKey extends Entry {
11         private IoTString key;
12         private int64_t machineid;
13
14         public NewKey(Slot slot, IoTString _key, int64_t _machineid) {
15                 super(slot);
16                 key = _key;
17                 machineid = _machineid;
18         }
19
20         public int64_t getMachineID() {
21                 return machineid;
22         }
23
24         public IoTString getKey() {
25                 return key;
26         }
27
28         public void setSlot(Slot s) {
29                 parentslot = s;
30         }
31
32         static Entry decode(Slot slot, ByteBuffer bb) {
33                 int keylength = bb.getInt();
34                 char[] key = new char[keylength];
35                 bb.get(key);
36                 int64_t machineid = bb.getLong();
37
38                 return new NewKey(slot, IoTString.shallow(key), machineid);
39         }
40
41         public void encode(ByteBuffer bb) {
42                 bb.put(Entry.TypeNewKey);
43                 bb.putInt(key.length());
44                 bb.put(key.internalBytes());
45                 bb.putLong(machineid);
46         }
47
48         public int getSize() {
49                 return sizeof(int64_t) + sizeof(char) + sizeof(int32_t) + key.length();
50         }
51
52         public char getType() {
53                 return Entry.TypeNewKey;
54         }
55
56         public Entry getCopy(Slot s) {
57                 return new NewKey(s, key, machineid);
58         }
59 }