From a32f6debc27fadaaaaba44eed144e4196ea58416 Mon Sep 17 00:00:00 2001 From: dgelessus <dgelessus@users.noreply.github.com> Date: Mon, 5 Dec 2022 14:30:46 +0100 Subject: [PATCH] Remove (Get|Set)PrologRandomSeed which do nothing The predicates on the Prolog side don't do anything anymore since 2012. --- .../core/command/ClearMachineCommand.java | 33 ++--------- .../core/command/GetPrologRandomSeed.java | 58 ------------------- .../core/command/SetPrologRandomSeed.java | 44 -------------- 3 files changed, 4 insertions(+), 131 deletions(-) delete mode 100644 de.prob.core/src/de/prob/core/command/GetPrologRandomSeed.java delete mode 100644 de.prob.core/src/de/prob/core/command/SetPrologRandomSeed.java diff --git a/de.prob.core/src/de/prob/core/command/ClearMachineCommand.java b/de.prob.core/src/de/prob/core/command/ClearMachineCommand.java index 2cd93def..74b12d91 100644 --- a/de.prob.core/src/de/prob/core/command/ClearMachineCommand.java +++ b/de.prob.core/src/de/prob/core/command/ClearMachineCommand.java @@ -13,15 +13,7 @@ import de.prob.prolog.output.IPrologTermOutput; import de.prob.prolog.term.PrologTerm; public class ClearMachineCommand implements IComposableCommand { - - private static final ClearCmd CLEAR_CMD = new ClearCmd(); - private final GetPrologRandomSeed getRandomSeed; - private final ComposedCommand cmd; - - public ClearMachineCommand() { - this.getRandomSeed = new GetPrologRandomSeed(); - this.cmd = new ComposedCommand(getRandomSeed, CLEAR_CMD); - } + public ClearMachineCommand() {} public static void clearMachine(final Animator animator) throws ProBException { @@ -30,26 +22,9 @@ public class ClearMachineCommand implements IComposableCommand { public void processResult( final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - cmd.processResult(bindings); - final Animator animator = Animator.getAnimator(); - animator.setRandomSeed(getRandomSeed.getSeed()); - } + throws CommandException {} - public void writeCommand(final IPrologTermOutput pto) - throws CommandException { - cmd.writeCommand(pto); + public void writeCommand(final IPrologTermOutput pto) { + pto.openTerm("clear_loaded_machines").closeTerm(); } - - private final static class ClearCmd implements IComposableCommand { - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - } - - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("clear_loaded_machines").closeTerm(); - } - } - } diff --git a/de.prob.core/src/de/prob/core/command/GetPrologRandomSeed.java b/de.prob.core/src/de/prob/core/command/GetPrologRandomSeed.java deleted file mode 100644 index 53b952d6..00000000 --- a/de.prob.core/src/de/prob/core/command/GetPrologRandomSeed.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.core.command; - -import java.math.BigInteger; - -import de.prob.core.Animator; -import de.prob.core.domainobjects.RandomSeed; -import de.prob.exceptions.ProBException; -import de.prob.parser.BindingGenerator; -import de.prob.parser.ISimplifiedROMap; -import de.prob.parser.ResultParserException; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.PrologTerm; - -public final class GetPrologRandomSeed implements IComposableCommand { - - private RandomSeed randomSeed; - - public static RandomSeed getSeed(final Animator a) throws ProBException { - final GetPrologRandomSeed cmd = new GetPrologRandomSeed(); - a.execute(cmd); - return cmd.getSeed(); - } - - public RandomSeed getSeed() { - return randomSeed; - } - - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - BigInteger x, y, z, b; - try { - x = BindingGenerator.getInteger(bindings.get("X")).getValue(); - y = BindingGenerator.getInteger(bindings.get("Y")).getValue(); - z = BindingGenerator.getInteger(bindings.get("Z")).getValue(); - b = BindingGenerator.getInteger(bindings.get("B")).getValue(); - } catch (ResultParserException e) { - CommandException commandException = new CommandException( - e.getLocalizedMessage(), e); - commandException.notifyUserOnce(); - throw commandException; - } - - randomSeed = new RandomSeed(x, y, z, b); - } - - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("get_rand").printVariable("X").printVariable("Y") - .printVariable("Z").printVariable("B").closeTerm(); - } - -} diff --git a/de.prob.core/src/de/prob/core/command/SetPrologRandomSeed.java b/de.prob.core/src/de/prob/core/command/SetPrologRandomSeed.java deleted file mode 100644 index 3bed4b72..00000000 --- a/de.prob.core/src/de/prob/core/command/SetPrologRandomSeed.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen, Heinrich - * Heine Universitaet Duesseldorf This software is licenced under EPL 1.0 - * (http://www.eclipse.org/org/documents/epl-v10.html) - * */ - -package de.prob.core.command; - -import de.prob.core.Animator; -import de.prob.core.domainobjects.RandomSeed; -import de.prob.exceptions.ProBException; -import de.prob.parser.ISimplifiedROMap; -import de.prob.prolog.output.IPrologTermOutput; -import de.prob.prolog.term.PrologTerm; - -public final class SetPrologRandomSeed implements IComposableCommand { - - private final RandomSeed seed; - - public SetPrologRandomSeed(final RandomSeed seed) { - this.seed = seed; - } - - public static void setSeed(final Animator a, final RandomSeed seed) - throws ProBException { - SetPrologRandomSeed cmd = new SetPrologRandomSeed(seed); - a.execute(cmd); - } - - public void processResult( - final ISimplifiedROMap<String, PrologTerm> bindings) - throws CommandException { - // no result, nothing to do - } - - public void writeCommand(final IPrologTermOutput pto) { - pto.openTerm("set_rand"); - pto.printNumber(seed.getSeedX()); - pto.printNumber(seed.getSeedY()); - pto.printNumber(seed.getSeedZ()); - pto.printNumber(seed.getSeedB()); - pto.closeTerm(); - } -} -- GitLab