]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/OperationTable.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / OperationTable.java
diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/OperationTable.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/OperationTable.java
new file mode 100644 (file)
index 0000000..d912a11
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.procore.cluster;\r
+\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.impl.ClusterI.Procedure;\r
+import org.simantics.db.impl.ClusterSupport;\r
+import org.simantics.db.impl.Modifier;\r
+import org.simantics.db.impl.Table;\r
+import org.simantics.db.impl.TableFactory;\r
+import org.simantics.db.impl.TableSizeListener;\r
+\r
+public class OperationTable extends Table<int[]> {\r
+\r
+           OperationTable(TableSizeListener sizeListener, int[] header, int headerBase, int[] ints) {\r
+               super(TableFactory.getIntFactory(), sizeListener, header, headerBase, ints);\r
+           }\r
+               int getOperationCount() {\r
+                       return getTableCount();\r
+               }\r
+               int createOperation(int type, int argIndex, int valIndex, int valSize) {\r
+                       int tableIndex = createNewElement(4);\r
+                   int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);\r
+                       int[] table = getTable();\r
+                       table[realIndex] = type;\r
+                       table[++realIndex] = argIndex;\r
+                       table[++realIndex] = valIndex;\r
+                       table[++realIndex] = valSize;\r
+                   return tableIndex - ZERO_SHIFT; // operation index is zero based\r
+               }\r
+               int getOperationType(int opIndex) {\r
+                       int tableIndex = ZERO_SHIFT + opIndex*4;\r
+                   int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);\r
+                       int[] table = getTable();\r
+                       return table[realIndex];\r
+               }\r
+               int getOperationArgumentIndex(int opIndex) {\r
+                       int tableIndex = ZERO_SHIFT + opIndex*4;\r
+                   int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);\r
+                       int[] table = getTable();\r
+                       return table[++realIndex];\r
+               }\r
+               int getValueIndex(int opIndex) {\r
+                       int tableIndex = ZERO_SHIFT + opIndex*4;\r
+                   int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);\r
+                       int[] table = getTable();\r
+                       return table[realIndex+2];\r
+               }\r
+               int getValueSize(int opIndex) {\r
+                       int tableIndex = ZERO_SHIFT + opIndex*4;\r
+                   int realIndex = checkIndexAndGetRealIndex(tableIndex, 4);\r
+                       int[] table = getTable();\r
+                       return table[realIndex+3];\r
+               }\r
+        @Override\r
+        public <Context> boolean foreach(int setIndex, Procedure procedure, Context context,\r
+                ClusterSupport support, Modifier modifier) throws DatabaseException {\r
+            throw new UnsupportedOperationException();\r
+        }\r
+}\r