1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.procore.cluster;
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;
22 public class OperationTable extends Table<int[]> {
24 OperationTable(TableSizeListener sizeListener, int[] header, int headerBase, int[] ints) {
25 super(TableFactory.getIntFactory(), sizeListener, header, headerBase, ints);
27 int getOperationCount() {
28 return getTableCount();
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
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];
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];
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];
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];
65 public <Context> boolean foreach(int setIndex, Procedure procedure, Context context,
66 ClusterSupport support, Modifier modifier) throws DatabaseException {
67 throw new UnsupportedOperationException();