X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.graph.db%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fdb%2FTransferableGraphSource.java;fp=bundles%2Forg.simantics.graph.db%2Fsrc%2Forg%2Fsimantics%2Fgraph%2Fdb%2FTransferableGraphSource.java;h=615001e30cbaf255de4cf7aa01f4ef09df5e3060;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphSource.java b/bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphSource.java new file mode 100644 index 000000000..615001e30 --- /dev/null +++ b/bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphSource.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.graph.db; + +import java.io.Closeable; +import java.io.DataInput; +import java.util.TreeMap; + +import org.simantics.databoard.binding.mutable.Variant; +import org.simantics.databoard.container.DataContainer; +import org.simantics.databoard.type.Datatype; +import org.simantics.db.ReadGraph; +import org.simantics.graph.representation.Identity; +import org.simantics.graph.representation.Value; + +/* + * NOTE: Current constraints + * + * §1 The following methods shall be called exactly once in the following order: + * -getIdentityCount + * -forIdentities + * -getStatementCount + * -forStatements + * -getValueCount + * -forValues + * + */ + +public interface TransferableGraphSource extends Closeable { + + public static final byte TAG_RAW_COPY_VARIANT_VALUE = 1; + public static final byte TAG_POTENTIALLY_MODIFIED_VARIANT_VALUE = 2; + + @FunctionalInterface + public interface TransferableGraphSourceProcedure { + void execute(T value) throws Exception; + } + + public interface TransferableGraphSourceValueProcedure { + void execute(int resource, Datatype type, DataInput input) throws Exception; + void rawCopy(int resource, int length, DataInput input) throws Exception; + } + + public DataContainer getHeader() throws Exception; + + public TreeMap getExtensions() throws Exception; + + public int getResourceCount() throws Exception; + + public int getIdentityCount() throws Exception; + public void forIdentities(ReadGraph graph, TransferableGraphSourceProcedure procedure) throws Exception; + + public int getStatementCount() throws Exception; + public void forStatements(ReadGraph graph, TransferableGraphSourceProcedure procedure) throws Exception; + + public int getValueCount() throws Exception; + public void forValues(ReadGraph graph, TransferableGraphSourceProcedure procedure) throws Exception; + public void forValues2(ReadGraph graph, TransferableGraphSourceValueProcedure procedure) throws Exception; + + public void reset() throws Exception; + +}