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