blob: f8532e6e43c64b702f951fb31b7044f86bc22658 [file] [log] [blame]
/*******************************************************************************
* 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.LinkedList;
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.callgraph.FlattenedPattern;
public class UnindexedRule extends Rule {
private LocalGoal right;
private LinkedList<MatchingFrame> leftInputQueue;
public UnindexedRule(FlattenedPattern pattern,
IQueueContentProvider left,
LocalGoal right) {
super(pattern, left);
this.right = right;
this.leftInputQueue = new LinkedList<MatchingFrame>();
}
public void traverseAll(Queue<MatchingFrame> resultQueue, MatchingFrame template)
throws PatternMatcherRuntimeException {
left.traverseAll(leftInputQueue, template);
right.calculateAllDeltas(this, resultQueue);
}
public Queue<MatchingFrame> getQueue() {
return leftInputQueue;
}
@Override
public void synchronize() {
left.synchronize();
leftInputQueue.clear();
}
@Override
public void init() {
left.init();
}
/*
public void initalizeSingleTraversal(Queue<MatchingFrame> queue, MatchingFrame template) {
left.initalizeSingleTraversal(leftInputQueue, template);
}
public MatchingFrame traverse() throws PatternMatcherRuntimeException {
return null;
// return new MatchingFrameMemo();
}
private class MatchingFrameMemo {
private MatchingFrame lastReturned;
MatchingFrameMemo() throws PatternMatcherRuntimeException {
this.lastReturned = left.traverse();
}
public boolean hasNext() {
return lastReturned != null;
}
public MatchingFrame next() throws PatternMatcherRuntimeException {
MatchingFrame result = lastReturned;
while (lastReturned != null) {
if (right.calculateDelta(lastReturned)) {
return result;
} else {
lastReturned = left.traverse();
}
}
return null;
}
}
*/
public void debug() {
System.out.println(" Unindexed Rule left input queue size: "+leftInputQueue.size());
}
}