tabbing
[iotcloud.git] / version2 / src / C / Slot.h
1 #ifndef SLOT_H
2 #define SLOT_H
3
4 #define SLOT_SIZE 2048
5 #define HMAC_SIZE 32
6
7 class Slot : public Liveness {
8 private:
9         /** Sequence number of the slot. */
10         int64_t seqnum;
11         /** HMAC of previous slot. */
12         char *prevhmac;
13         /** HMAC of this slot. */
14         char *hmac;
15         /** Machine that sent this slot. */
16         int64_t machineid;
17         /** Vector of entries in this slot. */
18         Vector<Entry *> *entries;
19         /** Pieces of information that are live. */
20         int livecount;
21         /** Flag that indicates whether this slot is still live for
22          * recording the machine that sent it. */
23         bool seqnumlive;
24         /** Number of chars of free space. */
25         int freespace;
26         /** Reference to Table */
27         Table *table;
28
29         int64_t localSequenceNumber;
30         void addShallowEntry(Entry *e);
31
32 public:
33         Slot(Table *_table, int64_t _seqnum, int64_t _machineid, char *_prevhmac, char *_hmac, int64_t _localSequenceNumber);
34         Slot(Table _table, int64_t _seqnum, int64_t _machineid, char *_prevhmac, int64_t _localSequenceNumber);
35         Slot(Table _table, int64_t _seqnum, int64_t _machineid, int64_t _localSequenceNumber);
36
37         char *getHMAC() { return hmac; }
38         char *getPrevHMAC() { return prevhmac; }
39         Entry *addEntry(Entry *e);
40         void removeEntry(Entry *e);
41         bool hasSpace(Entry *e);
42         Vector<Entry *> *getEntries();
43         char *encode(Mac *mac);
44         int getBaseSize() { return 2 * HMAC_SIZE + 2 * sizeof(int64_t) + sizeof(int); }
45         Vector<Entry *> *getLiveEntries(bool resize);
46         int64_t getSequenceNumber() { return seqnum; }
47         int64_t getMachineID() { return machineid; }
48         void setDead();
49         void decrementLiveCount();
50         bool isLive() { return livecount > 0; }
51         char *getSlotCryptIV();
52 };
53
54 Slot *Slotdecode(Table *table, char *array, Mac *mac);
55 #endif