Cleaned up git
[iotcloud.git] / version1 / src / js / iotjs / src / entry.js
diff --git a/version1/src/js/iotjs/src/entry.js b/version1/src/js/iotjs/src/entry.js
new file mode 100644 (file)
index 0000000..e4a47a3
--- /dev/null
@@ -0,0 +1,72 @@
+"use strict";
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var Entry = function () {
+    function Entry(slot) {
+        _classCallCheck(this, Entry);
+
+        if (slot && slot instanceof Slot) {
+
+            this.TypeKeyValue = 1;
+            this.TypeLastmessage = 2;
+            this.TypeRejectedMessage = 3;
+            this.TypeTableStatus = 4;
+            this.liveStatus = true;
+            this.parentslot = slot;
+        }
+    }
+
+    _createClass(Entry, [{
+        key: "isLive",
+        value: function isLive() {
+            return this.liveStatus;
+        }
+    }, {
+        key: "setDead",
+        value: function setDead() {
+            this.liveStatus = false;
+            parentslot.decrementLiveCount();
+        }
+
+        //must be overriden.
+
+    }, {
+        key: "encode",
+        value: function encode(bytebuffer) {}
+    }, {
+        key: "getSize",
+        value: function getSize() {}
+    }, {
+        key: "getType",
+        value: function getType() {}
+    }, {
+        key: "getCopy",
+        value: function getCopy(slot) {
+            if (slot && slot instanceof Slot) {}
+        }
+    }], [{
+        key: "decode",
+        value: function decode(slot, bytebuffer) {
+            if (slot instanceof Slot && bytebuffer instanceof ByteBuffer) {
+                var type = bytebuffer.readByte();
+                switch (type) {
+                    case this.TypeKeyValue:
+                        return KeyValue.decode(slot, bytebuffer);
+                    case this.TypeLastmessage:
+                        return LastMessage.decode(slot, bytebuffer);
+                    case this.TypeRejectedMessage:
+                        return RejectedMessage.decode(slot, bytebuffer);
+                    case this.TypeTableStatus:
+                        return TableStatus.decode(slot, bytebuffer);
+                    default:
+                        throw new Error("Unrecognized Entry Type: " + type);
+                }
+            }
+        }
+    }]);
+
+    return Entry;
+}();
\ No newline at end of file