edits
[iotcloud.git] / version2 / src / C / Entry.cc
1 #include "Entry.h"
2 #include "Slot.h"
3 #include "ByteBuffer.h"
4 #include "Abort.h"
5 #include "CommitPart.h"
6 #include "NewKey.h"
7 #include "LastMessage.h"
8 #include "RejectedMessage.h"
9 #include "TableStatus.h"
10 #include "TransactionPart.h"
11 /**
12  * Generic class that wraps all the different types of information
13  * that can be stored in a Slot.
14  * @author Brian Demsky <bdemsky@uci.edu>
15  * @version 1.0
16  */
17
18 Entry *Entry_decode(Slot *slot, ByteBuffer *bb) {
19         char type = bb->get();
20         switch (type) {
21
22         case TypeCommitPart:
23                 return CommitPart_decode(slot, bb);
24
25         case TypeAbort:
26                 return Abort_decode(slot, bb);
27
28         case TypeTransactionPart:
29                 return TransactionPart_decode(slot, bb);
30
31         case TypeNewKey:
32                 return NewKey_decode(slot, bb);
33
34         case TypeLastMessage:
35                 return LastMessage_decode(slot, bb);
36
37         case TypeRejectedMessage:
38                 return RejectedMessage_decode(slot, bb);
39         case TypeTableStatus:
40                 return TableStatus_decode(slot, bb);
41
42         default:
43                 ASSERT(0);
44         }
45 }
46
47 void Entry::setDead() {
48
49         if (!islive ) {
50                 return; // already dead
51         }
52
53         islive = false;
54
55         if (parentslot != NULL) {
56                 parentslot->decrementLiveCount();
57         }
58 }