more edits
[iotcloud.git] / version2 / src / C / NewKey.h
index 73c6400e7f78a075a2b7a4208137c6b4329b01cd..53a8f8c37d272d23cc8537a16d25f752d0146c36 100644 (file)
@@ -1,4 +1,5 @@
-
+#ifndef NEWKEY_H
+#define NEWKEY_H
 
 /**
  * This Entry records the abort sent by a given machine.
@@ -7,53 +8,30 @@
  */
 
 
-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) :
+       Entry(slot),
+               key(_key),
+               machineid(_machineid) {
+               }
+       
+       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) { return new NewKey(s, key, machineid); }
+};
+
+Entry * NewKey_decode(Slot *slot, ByteBuffer *bb);
+