| /******************************************************************************* |
| * Copyright (c) 2004-2008 Akos Horvath, Gergely Varro 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: |
| * Akos Horvath, Gergely Varro - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.rgg;
|
|
|
| import java.util.Iterator;
|
| import java.util.Queue;
|
| |
| import org.eclipse.viatra2.gtasm.patternmatcher.exceptions.PatternMatcherRuntimeException; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.MatchingFrame; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.SearchPlan; |
| import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.operation.SearchPlanOperation; |
|
|
|
|
| public class LocalGoal extends Goal {
|
| private SearchPlan searchPlan;
|
|
|
| public LocalGoal(SearchPlanOperation[] operations) {
|
| this.searchPlan = new SearchPlan(operations);
|
| }
|
|
|
| public void calculateAllDeltas(UnindexedRule parent, Queue<MatchingFrame> output)
|
| throws PatternMatcherRuntimeException {
|
| Queue<MatchingFrame> input = parent.getQueue();
|
| for (Iterator<MatchingFrame> i = input.iterator(); i.hasNext();) {
|
| MatchingFrame frame = i.next();
|
| while (searchPlan.execute(frame)) {
|
| MatchingFrame newFrame = (MatchingFrame) frame.clone();
|
| output.offer(newFrame);
|
| }
|
| i.remove();
|
| }
|
| }
|
|
|
| public boolean calculateDelta(MatchingFrame frame) throws PatternMatcherRuntimeException {
|
| return searchPlan.execute(frame);
|
| }
|
| }
|