Adding benchmark file for encrypted cloud storage.
[iotcloud.git] / version2 / src / C / NewKey.h
index 73c6400e7f78a075a2b7a4208137c6b4329b01cd..2abb1be0707bc8e70418c686af80da2ba7eaf004 100644 (file)
@@ -1,4 +1,7 @@
-
+#ifndef NEWKEY_H
+#define NEWKEY_H
+#include "common.h"
+#include "Entry.h"
 
 /**
  * This Entry records the abort sent by a given machine.
@@ -6,54 +9,22 @@
  * @version 1.0
  */
 
-
-class NewKey extends Entry {
-       private IoTString key;
-       private int64_t machineid;
-
-       public NewKey(Slot slot, IoTString _key, int64_t _machineid) {
-               super(slot);
-               key = _key;
-               machineid = _machineid;
-       }
-
-       public int64_t getMachineID() {
-               return machineid;
-       }
-
-       public IoTString getKey() {
-               return key;
-       }
-
-       public void setSlot(Slot s) {
-               parentslot = s;
-       }
-
-       static Entry decode(Slot slot, ByteBuffer bb) {
-               int keylength = bb.getInt();
-               char[] key = new char[keylength];
-               bb.get(key);
-               int64_t machineid = bb.getLong();
-
-               return new NewKey(slot, IoTString.shallow(key), machineid);
-       }
-
-       public void encode(ByteBuffer bb) {
-               bb.put(Entry.TypeNewKey);
-               bb.putInt(key.length());
-               bb.put(key.internalBytes());
-               bb.putLong(machineid);
-       }
-
-       public int getSize() {
-               return sizeof(int64_t) + sizeof(char) + sizeof(int32_t) + key.length();
-       }
-
-       public char getType() {
-               return Entry.TypeNewKey;
-       }
-
-       public Entry getCopy(Slot s) {
-               return new NewKey(s, key, machineid);
-       }
-}
+class NewKey : public Entry {
+private:
+       IoTString *key;
+       int64_t machineid;
+
+public:
+       NewKey(Slot *slot, IoTString *_key, int64_t _machineid);
+       ~NewKey();
+       int64_t getMachineID() { return machineid; }
+       IoTString *getKey() { return key; }
+       void setSlot(Slot *s) { parentslot = s; }
+       void encode(ByteBuffer *bb);
+       int getSize();
+       char getType() { return TypeNewKey; }
+       Entry *getCopy(Slot *s);
+};
+
+Entry *NewKey_decode(Slot *slot, ByteBuffer *bb);
+#endif