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