]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphSource.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graph.db / src / org / simantics / graph / db / TransferableGraphSource.java
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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.graph.db;\r
13 \r
14 import java.io.Closeable;\r
15 import java.io.DataInput;\r
16 import java.util.TreeMap;\r
17 \r
18 import org.simantics.databoard.binding.mutable.Variant;\r
19 import org.simantics.databoard.container.DataContainer;\r
20 import org.simantics.databoard.type.Datatype;\r
21 import org.simantics.db.ReadGraph;\r
22 import org.simantics.graph.representation.Identity;\r
23 import org.simantics.graph.representation.Value;\r
24 \r
25 /*\r
26  * NOTE: Current constraints\r
27  * \r
28  *  ยง1 The following methods shall be called exactly once in the following order:\r
29  *     -getIdentityCount\r
30  *     -forIdentities\r
31  *     -getStatementCount\r
32  *     -forStatements\r
33  *     -getValueCount\r
34  *     -forValues\r
35  * \r
36  */\r
37 \r
38 public interface TransferableGraphSource extends Closeable {\r
39 \r
40         public static final byte TAG_RAW_COPY_VARIANT_VALUE = 1;\r
41         public static final byte TAG_POTENTIALLY_MODIFIED_VARIANT_VALUE = 2;\r
42 \r
43         @FunctionalInterface\r
44         public interface TransferableGraphSourceProcedure<T> {\r
45                 void execute(T value) throws Exception;\r
46         }\r
47 \r
48         public interface TransferableGraphSourceValueProcedure {\r
49                 void execute(int resource, Datatype type, DataInput input) throws Exception;\r
50                 void rawCopy(int resource, int length, DataInput input) throws Exception;\r
51         }\r
52 \r
53         public DataContainer getHeader() throws Exception;\r
54         \r
55         public TreeMap<String, Variant> getExtensions() throws Exception;\r
56         \r
57         public int getResourceCount() throws Exception;\r
58 \r
59         public int getIdentityCount() throws Exception;\r
60         public void forIdentities(ReadGraph graph, TransferableGraphSourceProcedure<Identity> procedure) throws Exception;\r
61 \r
62         public int getStatementCount() throws Exception;\r
63         public void forStatements(ReadGraph graph, TransferableGraphSourceProcedure<int[]> procedure) throws Exception;\r
64         \r
65         public int getValueCount() throws Exception;\r
66         public void forValues(ReadGraph graph, TransferableGraphSourceProcedure<Value> procedure) throws Exception;\r
67         public void forValues2(ReadGraph graph, TransferableGraphSourceValueProcedure procedure) throws Exception;\r
68         \r
69         public void reset() throws Exception;\r
70         \r
71 }\r