more edits
[iotcloud.git] / version2 / src / C / SlotIndexer.h
index b69a8b89f0a2f9f3485ae67f27be55831a0a0457..c4f54eb35a7a4d8052565c8af725e95e2759ab04 100644 (file)
@@ -1,4 +1,6 @@
-
+#ifndef SLOTINDEXER_H
+#define SLOTINDEXER_H
+#include "common.h"
 /**
  * Slot indexer allows slots in both the slot buffer and the new
  * server response to looked up in a consistent fashion.
@@ -7,24 +9,13 @@
  */
 
 class SlotIndexer {
-       private Slot[] updates;
-       private SlotBuffer buffer;
-       private int64_t firstslotseqnum;
-
-       SlotIndexer(Slot[] _updates, SlotBuffer _buffer) {
-               buffer = _buffer;
-               updates = _updates;
-               firstslotseqnum = updates[0].getSequenceNumber();
-       }
+ private:
+       Array<Slot*> * updates;
+       SlotBuffer * buffer;
+       int64_t firstslotseqnum;
 
-       Slot getSlot(int64_t seqnum) {
-               if (seqnum >= firstslotseqnum) {
-                       int offset = (int) (seqnum - firstslotseqnum);
-                       if (offset >= updates.length)
-                               throw new Error("Invalid Slot Sequence Number Reference");
-                       else
-                               return updates[offset];
-               } else
-                       return buffer.getSlot(seqnum);
-       }
-}
+ public:
+       SlotIndexer(Array<Slot*> * _updates, SlotBuffer * _buffer);
+       Slot* getSlot(int64_t seqnum);
+};
+#endif;