]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/OperationTable.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / OperationTable.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.procore.cluster;
13
14 import org.simantics.db.exception.DatabaseException;
15 import org.simantics.db.impl.ClusterI.Procedure;
16 import org.simantics.db.impl.ClusterSupport;
17 import org.simantics.db.impl.Modifier;
18 import org.simantics.db.impl.Table;
19 import org.simantics.db.impl.TableFactory;
20 import org.simantics.db.impl.TableSizeListener;
21
22 public class OperationTable extends Table<int[]> {
23
24             OperationTable(TableSizeListener sizeListener, int[] header, int headerBase, int[] ints) {
25                 super(TableFactory.getIntFactory(), sizeListener, header, headerBase, ints);
26             }
27                 int getOperationCount() {
28                         return getTableCount();
29                 }
30                 int createOperation(int type, int argIndex, int valIndex, int valSize) {
31                         int tableIndex = createNewElement(4);
32                     int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);
33                         int[] table = getTable();
34                         table[realIndex] = type;
35                         table[++realIndex] = argIndex;
36                         table[++realIndex] = valIndex;
37                         table[++realIndex] = valSize;
38                     return tableIndex - ZERO_SHIFT; // operation index is zero based
39                 }
40                 int getOperationType(int opIndex) {
41                         int tableIndex = ZERO_SHIFT + opIndex*4;
42                     int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);
43                         int[] table = getTable();
44                         return table[realIndex];
45                 }
46                 int getOperationArgumentIndex(int opIndex) {
47                         int tableIndex = ZERO_SHIFT + opIndex*4;
48                     int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);
49                         int[] table = getTable();
50                         return table[++realIndex];
51                 }
52                 int getValueIndex(int opIndex) {
53                         int tableIndex = ZERO_SHIFT + opIndex*4;
54                     int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);
55                         int[] table = getTable();
56                         return table[realIndex+2];
57                 }
58                 int getValueSize(int opIndex) {
59                         int tableIndex = ZERO_SHIFT + opIndex*4;
60                     int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);
61                         int[] table = getTable();
62                         return table[realIndex+3];
63                 }
64         @Override
65         public <Context> boolean foreach(int setIndex, Procedure procedure, Context context,
66                 ClusterSupport support, Modifier modifier) throws DatabaseException {
67             throw new UnsupportedOperationException();
68         }
69 }