Adding test for encrypted cloud storage; Adding preparation timing test for Fidelius...
[iotcloud.git] / version2 / src / C / Entry.h
1 #ifndef ENTRY_H
2 #define ENTRY_H
3 /**
4  * Generic class that wraps all the different types of information
5  * that can be stored in a Slot.
6  * @author Brian Demsky <bdemsky@uci.edu>
7  * @version 1.0
8  */
9
10 #include "Liveness.h"
11 #include "common.h"
12
13 #define TypeCommitPart 1
14 #define TypeAbort 2
15 #define TypeTransactionPart 3
16 #define TypeNewKey 4
17 #define TypeLastMessage 5
18 #define TypeRejectedMessage 6
19 #define TypeTableStatus 7
20 #define TypeSlot 8
21
22 class Entry : public Liveness {
23         /* Records whether the information is still live or has been
24            superceded by a newer update.  */
25 private:
26         bool islive;
27 protected:
28         Slot *parentslot;
29
30 public:
31         Entry(Slot *_parentslot) : islive(true), parentslot(_parentslot) {}
32         virtual ~Entry() {}
33         /**
34          * Returns true if the Entry object is still live.
35          */
36         bool isLive() { return islive; }
37
38         /**
39          * Flags the entry object as dead.  Also decrements the live count
40          * of the parent slot.
41          */
42         void setDead();
43
44         /**
45          * Serializes the Entry object into the char buffer.
46          */
47         virtual void encode(ByteBuffer *bb) = 0;
48
49         /**
50          * Returns the size in chars the entry object will take in the char
51          * array.
52          */
53         virtual int getSize() = 0;
54         virtual void releaseRef() {delete this;}
55         virtual void acquireRef() {}
56
57         /**
58          * Returns a copy of the Entry that can be added to a different slot.
59          */
60         virtual Entry *getCopy(Slot *s) = 0;
61         friend Entry *Entry_decode(Slot *slot, ByteBuffer *bb);
62 };
63
64 /**
65  * Static method for decoding char array into Entry objects.  First
66  * char tells the type of entry.
67  */
68 Entry *Entry_decode(Slot *slot, ByteBuffer *bb);
69
70 #endif