]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ArgumentTable.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db.procore / src / org / simantics / db / procore / cluster / ArgumentTable.java
diff --git a/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ArgumentTable.java b/bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ArgumentTable.java
new file mode 100644 (file)
index 0000000..7a59172
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************\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 ArgumentTable extends Table<long[]> {\r
+    ArgumentTable(TableSizeListener sizeListener, int[] header, int headerBase, long[] longs) {\r
+        super(TableFactory.getLongFactory(), sizeListener, header, headerBase, longs);\r
+    }\r
+       int createArgument(long a1) {\r
+               int tableIndex = createNewElement(1);\r
+           int realIndex = checkIndexAndGetRealIndex(tableIndex, 1);\r
+               long[] table = getTable();\r
+               table[realIndex] = a1;\r
+               return tableIndex;\r
+       }\r
+       int createArgument(long a1, long a2) {\r
+               int tableIndex = createNewElement(2);\r
+           int realIndex = checkIndexAndGetRealIndex(tableIndex, 2);\r
+               long[] table = getTable();\r
+               table[realIndex] = a1;\r
+               table[++realIndex] = a2;\r
+               return tableIndex;\r
+       }\r
+       int createArgument(long a1, long a2, long a3, long a4, long a5) {\r
+               int tableIndex = createNewElement(5);\r
+           int realIndex = checkIndexAndGetRealIndex(tableIndex, 5);\r
+               long[] table = getTable();\r
+               table[realIndex] = a1;\r
+               table[++realIndex] = a2;\r
+               table[++realIndex] = a3;\r
+               table[++realIndex] = a4;\r
+               table[++realIndex] = a5;\r
+               return tableIndex;\r
+       }\r
+       long[] getArguments(int argIndex, int size) {\r
+           int realIndex = checkIndexAndGetRealIndex(argIndex, size);\r
+               long[] table = getTable();\r
+               long[] dest = new long[size];\r
+               System.arraycopy(table, realIndex, dest, 0, size);\r
+               return dest;\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