blob: 2d72ff270ddb050d6bf94dfbced2c6a1a693179b [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.operation;
import org.eclipse.viatra2.gtasm.patternmatcher.exceptions.PatternMatcherRuntimeException;
import org.eclipse.viatra2.gtasm.patternmatcher.impl.patternmatcher.internal.MatchingFrame;
abstract public class CheckOperation extends SearchPlanOperation {
private boolean hasBeenExecuted;
public CheckOperation() {
hasBeenExecuted = false;
}
public void preprocess(MatchingFrame frame) {
hasBeenExecuted = false;
}
final public boolean execute(MatchingFrame frame)
throws PatternMatcherRuntimeException {
hasBeenExecuted = (hasBeenExecuted ? false : check(frame));
return hasBeenExecuted;
}
public void postprocess(MatchingFrame frame) {
return;
}
abstract protected boolean check(MatchingFrame frame)
throws PatternMatcherRuntimeException;
public boolean update(MatchingFrame frame) throws PatternMatcherRuntimeException{
try {
hasBeenExecuted = false;
return execute(frame);
} catch (PatternMatcherRuntimeException e) {
e.printStackTrace();
return false;
}
}
}