-
+#ifndef NEWKEY_H
+#define NEWKEY_H
+#include "common.h"
+#include "Entry.h"
/**
* This Entry records the abort sent by a given machine.
* @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