Adding Fidelius manual.
[iotcloud.git] / version2 / src / C / PendingTransaction.h
1 #ifndef PENDINGTRANSACTION_H
2 #define PENDINGTRANSACTION_H
3
4 #include "common.h"
5
6 class PendingTransaction {
7 private:
8         Hashset<KeyValue *> *keyValueUpdateSet;
9         Hashset<KeyValue *> *keyValueGuardSet;
10         int64_t arbitrator;
11         int64_t clientLocalSequenceNumber;
12         int64_t machineId;
13         int32_t currentDataSize;
14
15 public:
16         PendingTransaction(int64_t _machineId);
17         ~PendingTransaction();
18         /**
19          * Add a new key value to the updates
20          *
21          */
22         void addKV(KeyValue *newKV);
23         /**
24          * Add a new key value to the guard set
25          *
26          */
27         void addKVGuard(KeyValue *newKV);
28         /**
29          * Checks if the arbitrator is the same
30          */
31         bool checkArbitrator(int64_t arb);
32         /**
33          * Get the transaction arbitrator
34          */
35         int64_t getArbitrator() {return arbitrator;}
36         /**
37          * Get the key value update set
38          */
39         Hashset<KeyValue *> *getKVUpdates() { return keyValueUpdateSet; }
40
41         /**
42          * Get the key value update set
43          */
44         Hashset<KeyValue *> *getKVGuard() { return keyValueGuardSet; }
45
46         void setClientLocalSequenceNumber(int64_t _clientLocalSequenceNumber) { clientLocalSequenceNumber = _clientLocalSequenceNumber; }
47
48         int64_t getClientLocalSequenceNumber() { return clientLocalSequenceNumber; }
49
50         int64_t getMachineId() { return machineId; }
51
52         bool evaluateGuard(Hashtable<IoTString *, KeyValue *> *keyValTableCommitted, Hashtable<IoTString *, KeyValue *> *keyValTableSpeculative, Hashtable<IoTString *, KeyValue *> *keyValTablePendingTransSpeculative);
53
54         Transaction *createTransaction();
55
56         Array<char> *convertDataToBytes();
57 };
58 #endif