Adding Fidelius manual.
[iotcloud.git] / version2 / src / C / TransactionPart.h
1 #ifndef TRANSACTIONPART_H
2 #define TRANSACTIONPART_H
3 #include "common.h"
4 #include "Entry.h"
5 #include "Pair.h"
6
7 // Max size of the part excluding the fixed size header
8 #define TransactionPart_MAX_NON_HEADER_SIZE 512
9
10 class TransactionPart : public Entry {
11 private:
12         int64_t sequenceNumber;
13         int64_t machineId;
14         int64_t arbitratorId;
15         int64_t clientLocalSequenceNumber;              // Sequence number of the transaction that this is a part of
16         int32_t partNumber;     // Parts position in the
17         bool fldisLastPart;
18         int32_t refCount;
19         Pair<int64_t, int64_t> transactionId;
20         Pair<int64_t, int32_t> partId;
21
22         Array<char> *data;
23         
24 public:
25         TransactionPart(Slot *s, int64_t _machineId, int64_t _arbitratorId, int64_t _clientLocalSequenceNumber, int _partNumber, Array<char> *_data, bool _isLastPart) : Entry(s),
26                 sequenceNumber(-1),
27                 machineId( _machineId),
28                 arbitratorId(_arbitratorId),
29                 clientLocalSequenceNumber(_clientLocalSequenceNumber),
30                 partNumber(_partNumber),
31                 fldisLastPart(_isLastPart),
32                 refCount(1),
33                 transactionId(Pair<int64_t, int64_t>(machineId, clientLocalSequenceNumber)),
34                 partId(Pair<int64_t, int32_t>(clientLocalSequenceNumber, partNumber)),
35                 data(_data) {
36         }
37         ~TransactionPart();
38         int getSize();
39         Pair<int64_t, int64_t> getTransactionId();
40         int64_t getArbitratorId();
41         Pair<int64_t, int32_t> * getPartId();
42         int getPartNumber();
43         int getDataSize();
44         Array<char> *getData();
45         bool isLastPart();
46         int64_t getMachineId();
47         int64_t getClientLocalSequenceNumber();
48         int64_t getSequenceNumber();
49         void setSequenceNumber(int64_t _sequenceNumber);
50         void encode(ByteBuffer *bb);
51         char getType();
52         void releaseRef() {if ((--refCount)==0) delete this;}   
53         void acquireRef() {refCount++;}
54         Entry *getCopy(Slot *s);
55 };
56
57 Entry *TransactionPart_decode(Slot *s, ByteBuffer *bb);
58 #endif