edits
[iotcloud.git] / version2 / src / C / SlotBuffer.h
1 #ifndef SLOTBUFFER_H
2 #define SLOTBUFFER_H
3
4 #include "common.h"
5
6 /**
7  * Circular buffer that holds the live set of slots.
8  * @author Brian Demsky
9  * @version 1.0
10  */
11
12 #define SlotBuffer_DEFAULT_SIZE 16
13
14 class SlotBuffer {
15 private:
16         Array<Slot *> *array;
17         int32_t head;
18         int32_t tail;
19         void incrementHead();
20         void incrementTail();
21
22 public:
23         int64_t oldestseqn;
24
25         SlotBuffer();
26         int32_t size();
27         int32_t capacity();
28         void resize(int newsize);
29         void putSlot(Slot *s);
30         Slot *getSlot(int64_t seqnum);
31         int64_t getOldestSeqNum() { return oldestseqn; }
32         int64_t getNewestSeqNum() { return oldestseqn + size() - 1;}
33 };
34 #endif