]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.acorn/src/org/simantics/acorn/internal/ClusterChange2.java
Sharing org.simantics.acorn for everyone to use
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / internal / ClusterChange2.java
1 package org.simantics.acorn.internal;
2
3
4 public class ClusterChange2 {
5     public static final int VERSION = 2;
6     public static final byte SET_IMMUTABLE_OPERATION = 1; // <byte : 0 = false>
7     public static final byte UNDO_VALUE_OPERATION = 2; // <int : resource index>
8     private static final int INCREMENT = 1<<10;
9 //    private boolean dirty = false;
10 //    private byte[] bytes;
11 //    private int byteIndex;
12 //    private ClusterUID clusterUID;
13 //    private ClusterImpl cluster;
14 //    ClusterChange2(ClusterUID clusterUID, ClusterImpl cluster) {
15 //        this.clusterUID = clusterUID;
16 //        this.cluster = cluster;
17 //        init();
18 //    }
19 //    void init() {
20 ////        System.err.println("clusterChange2 dirty " + cluster.clusterId);
21 //        dirty = false;
22 //        bytes = new byte[INCREMENT];
23 //        byteIndex = 0;
24 //        addInt(0); // Size of byte vector. Set by flush.
25 //        addInt(VERSION);
26 //        byteIndex = clusterUID.toByte(bytes, 8);
27 //    }
28 //    boolean isDirty() {
29 //        return dirty;
30 //    }
31 //    void flush(GraphSession graphSession) {
32 ////        System.err.println("flush2 clusterChange2 " + dirty + this);
33 //        if (!dirty)
34 //            return;
35 //        Bytes.writeLE(bytes, 0, byteIndex - 4);
36 //        byte[] ops = Arrays.copyOf(bytes, byteIndex);
37 ////        System.err.println("flush2 clusterChange2 " + cluster.clusterId + " " + ops.length + " bytes.");
38 //        graphSession.updateCluster(new UpdateClusterFunction(ops));
39 //        init();
40 //    }
41 //    void setImmutable(boolean immutable) {
42 //        dirty = true;
43 //        addByte(SET_IMMUTABLE_OPERATION);
44 //        addByte((byte)(immutable ? -1 : 0));
45 //    }
46 //    void undoValueEx(int resourceIndex) {
47 //        dirty = true;
48 //        addByte(UNDO_VALUE_OPERATION);
49 //        addInt(resourceIndex);
50 //    }
51 //    private final void checkSpace(int len) {
52 //        if (bytes.length - byteIndex > len)
53 //            return;
54 //       bytes = Arrays.copyOf(bytes, bytes.length + len + INCREMENT);
55 //    }
56 //    private final void addByte(byte value) {
57 //        checkSpace(1);
58 //        bytes[byteIndex++] = value;
59 //    }
60 //    private final void addInt(int value) {
61 //        checkSpace(4);
62 //        Bytes.writeLE(bytes, byteIndex, value);
63 //        byteIndex += 4;
64 //    }
65 ////    private void addLong(long value) {
66 ////        checkSpace(8);
67 ////        Bytes.writeLE(bytes, byteIndex, value);
68 ////        byteIndex += 8;
69 ////    }
70 }