Added slotindexer and table status constructor
[iotcloud.git] / src / js / iotjs / orig / tablestatus.js
diff --git a/src/js/iotjs/orig/tablestatus.js b/src/js/iotjs/orig/tablestatus.js
new file mode 100644 (file)
index 0000000..06f8f25
--- /dev/null
@@ -0,0 +1,34 @@
+class TableStatus extends Entry{
+       constructor(slot,_maxslots){
+               super(slot);
+               this.maxslots = _maxslots;
+       }
+       getMaxSlots(){
+               return this.maxslots;
+       }
+       static decode(slot,bb){
+               //bb is an object of the type bytebuffer See main.js file and its require section 
+               //for more details
+               if(!(bb instanceof ByteBuffer && slot instanceof Slot)){
+                       throw new Error('Argument Error: bb is not an instanceof Bytebuffer');
+               }
+               this.maxslots = bb.readByte();
+               return new TableStatus(slot,this.maxslots);
+       }
+       encode(bb){
+               bb.writeByte(Entry.TypeTableStatus);
+               bb.writeInt8(this.maxslots);
+       }
+       getSize(){
+               return 4+1;
+       }
+       getType(){
+               return Entry.TypeTableStatus;
+       }
+       getcopy(s){
+               if(!(s instanceof Slot)){
+                       throw new Error('Argument Error: s is not an instanceof Slot');
+               }
+               return new TableStatus(s,this.maxslots);
+       }
+}
\ No newline at end of file