/******************************************************************************* | |
* Copyright (c) 2004-2008 Gabor Bergmann and Daniel Varro | |
* 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: | |
* Gabor Bergmann - initial API and implementation | |
*******************************************************************************/ | |
package org.eclipse.viatra2.gtasm.patternmatcher.incremental.adapters; | |
import java.util.Map; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.boundary.PredicateEvaluatorNode; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.ReteContainerBuildable; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.RetePatternBuildException; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.construction.Stub; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.matcher.ReteEngine; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.Receiver; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.ReteContainer; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.network.Supplier; | |
import org.eclipse.viatra2.gtasm.patternmatcher.incremental.rete.remote.Address; | |
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.terms.Term; | |
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.gt.GTPattern; | |
/** | |
* @author Bergmann Gábor | |
* | |
*/ | |
public class ReteContainerGTASMBuildable extends ReteContainerBuildable<GTPattern> implements GTASMBuildable<Address<? extends Supplier>, Address<? extends Receiver>> { | |
/** | |
* @param engine | |
* @param targetContainer | |
*/ | |
public ReteContainerGTASMBuildable(ReteEngine<GTPattern> engine, ReteContainer targetContainer) { | |
super(engine, targetContainer); | |
} | |
public Stub<Address<? extends Supplier>> buildGTASMTermChecker( | |
Term term, | |
Map<String, Integer> variableIndices, | |
Map<String, String> variableEquivalence, | |
Integer rhsIndex, | |
Stub<Address<? extends Supplier>> stub | |
) throws RetePatternBuildException | |
{ | |
int[] affectedIndices = new int[variableIndices.values().size()]; | |
int k = 0; | |
for (Integer index : variableIndices.values()) affectedIndices[k++] = index; | |
PredicateEvaluatorNode ten = new GTASMTermEvaluatorNode(engine, | |
targetContainer, term, rhsIndex, variableIndices, | |
variableEquivalence, affectedIndices, stub.getVariablesTuple().getSize()); | |
Address<PredicateEvaluatorNode> checker = Address.of(ten); | |
reteNet.connectRemoteNodes(stub.getHandle(), checker, true); | |
Stub<Address<? extends Supplier>> result = new Stub<Address<? extends Supplier>>(stub, checker); | |
return result; | |
} | |
@Override | |
public ReteContainerGTASMBuildable getNextContainer() { | |
return new ReteContainerGTASMBuildable(engine, engine.getReteNet().getNextContainer()); | |
} | |
/** | |
* No need to distinguish | |
*/ | |
@Override | |
public ReteContainerGTASMBuildable putOnTab(GTPattern effort) { | |
return this; | |
} | |
} |