]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/Change.java
Declare asyncCount volatile since it is accessed from multiple threads
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / Change.java
1 package fi.vtt.simantics.procore.internal;
2
3 import org.simantics.db.service.ClusterUID;
4
5 final public class Change {
6     
7     byte op0;
8     int key0;
9     int key1;
10     int key2;
11     ClusterUID clusterUID1;
12     ClusterUID clusterUID2;
13     byte[] lookup1;
14     byte[] lookup2;
15     byte lookIndex1;
16     byte lookIndex2;
17     int lastArg = 0;
18
19     @Override
20     public String toString() {
21         return "Change " + (key0&0xffff) + " " + (key1&0xffff) + " " + (key2&0xffff) + " " + clusterUID2 + " " + clusterUID2;
22     }
23     
24     public final void init() {
25         lastArg = 0;
26     }
27
28     public final void initValue() {
29         lastArg = 0;
30     }
31
32     final void addStatementIndex0(int key, byte op) {
33         assert (op != 0);
34         key0 = key;
35         op0 = op;
36     }
37
38     final void addStatementIndex1(int key, ClusterUID clusterUID, byte lookIndex, byte[] lookup) {
39         key1 = key;
40         clusterUID1 = clusterUID;
41         lookIndex1 = lookIndex;
42         lookup1 = lookup;
43 //        if(lookIndex > 0)
44 //            System.err.println("statementIndex1 " + pos + " " + lookIndex);
45     }
46
47     final void addStatementIndex2(int key, ClusterUID clusterUID, byte lookIndex, byte[] lookup) {
48         key2 = key;
49         clusterUID2 = clusterUID;
50         lookIndex2 = lookIndex;
51         lookup2 = lookup;
52     }
53
54     final void addStatementIndex(int key, ClusterUID clusterUID, byte op) {
55
56         // new Exception("lastArg=" + lastArg).printStackTrace();
57
58         assert (lastArg < 3);
59
60         if (0 == lastArg)
61             addStatementIndex0(key, op);
62         else if (1 == lastArg)
63             addStatementIndex1(key, clusterUID, (byte)0, null);
64         else if (2 == lastArg)
65             addStatementIndex2(key, clusterUID, (byte)0, null);
66
67         lastArg++;
68
69     }
70 }