package org.simantics.graph.compiler.internal.templates; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TObjectIntHashMap; import java.util.Arrays; import java.util.Collection; import org.simantics.graph.compiler.ExternalFileLoader; import org.simantics.graph.compiler.internal.store.LocationStore; import org.simantics.graph.query.IGraph; import org.simantics.graph.representation.External; import org.simantics.graph.representation.Identity; import org.simantics.graph.representation.Root; import org.simantics.graph.representation.TransferableGraph1; import org.simantics.graph.representation.Value; import org.simantics.graph.store.GraphStore; import org.simantics.graph.store.IdentityStore; import org.simantics.graph.store.StatementStore; import org.simantics.graph.store.ValueStore; import org.simantics.ltk.Location; import org.simantics.ltk.Problem; public class GraphTemplate implements ITemplate { int[] prototypeResources; int[] parameterMapping; int[] statements; Value[] values; public GraphTemplate(GraphStore store, String[] parameters, TransferableGraph1 tg) { prototypeResources = new int[tg.resourceCount]; Arrays.fill(prototypeResources, -1); this.values = tg.values; this.statements = tg.statements; this.parameterMapping = new int[parameters.length]; TObjectIntHashMap pmap = new TObjectIntHashMap(); for(int i=0;i problems) { if(parameters.length != parameterMapping.length) { Location location = store.getStore(LocationStore.class) .getLocation(parameters[0]); problems.add(new Problem(location, "A template applied with wrong number of parameters.")); return; } int[] resources = Arrays.copyOf(prototypeResources, prototypeResources.length); for(int i=0;i= 0 && map.contains(temp)) prototypeResources[i] = map.get(temp); } } }