[jsoar] push by alex.nic...@soartech.com - Cleaned up implementation of cmd RHS function. As per Dave's advice, i... on 2014-06-12 17:48 GMT

2 views
Skip to first unread message

js...@googlecode.com

unread,
Jun 12, 2014, 1:48:22 PM6/12/14
to jsoa...@googlegroups.com
Revision: 9205a79a2c6a
Author: bob.marinier <bob.ma...@soartech.com>
Date: Thu Jun 12 17:18:13 2014 UTC
Log: Cleaned up implementation of cmd RHS function. As per Dave's
advice, it was unnecessary to modify the RhsFunctionContext to pass in the
agent -- the agent can just be passed into the CmdRhsFunction's constructor.

So most of these files are essentially being reverted to how they were.

http://code.google.com/p/jsoar/source/detail?r=9205a79a2c6a

Modified:
/jsoar-core/src/main/java/org/jsoar/kernel/memory/RecognitionMemory.java
/jsoar-core/src/main/java/org/jsoar/kernel/rete/SimpleMatcher.java

/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/CmdRhsFunction.java

/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/RhsFunctionContext.java

/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/StandardFunctions.java
/jsoar-core/src/test/java/org/jsoar/JSoarTest.java
/jsoar-tcl/src/main/java/org/jsoar/tcl/SoarTclInterface.java

=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/memory/RecognitionMemory.java
Thu Jun 12 13:38:41 2014 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/memory/RecognitionMemory.java
Thu Jun 12 17:18:13 2014 UTC
@@ -1765,14 +1765,6 @@
{
return production_being_fired;
}
-
- /* (non-Javadoc)
- * @see
org.jsoar.kernel.rhs.functions.RhsFunctionContext#getAgent()
- */
- @Override
- public Agent getAgent() {
- return RecognitionMemory.this.context;
- }

}
}
=======================================
--- /jsoar-core/src/main/java/org/jsoar/kernel/rete/SimpleMatcher.java Thu
Jun 12 13:38:41 2014 UTC
+++ /jsoar-core/src/main/java/org/jsoar/kernel/rete/SimpleMatcher.java Thu
Jun 12 17:18:13 2014 UTC
@@ -290,13 +290,6 @@
return null;
}

- /* (non-Javadoc)
- * @see
org.jsoar.kernel.rhs.functions.RhsFunctionContext#getAgent()
- */
- @Override
- public Agent getAgent() {
- return null;
- }
};

private class Listener implements ReteListener
=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/CmdRhsFunction.java
Thu Jun 12 13:38:41 2014 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/CmdRhsFunction.java
Thu Jun 12 17:18:13 2014 UTC
@@ -9,6 +9,7 @@
import java.util.ArrayList;
import java.util.List;

+import org.jsoar.kernel.Agent;
import org.jsoar.kernel.SoarException;
import org.jsoar.kernel.symbols.Symbol;
import org.jsoar.kernel.tracing.Printer;
@@ -46,11 +47,13 @@
public class CmdRhsFunction extends AbstractRhsFunctionHandler
{
private final SoarCommandInterpreter interp;
+ private final Agent agent;

- public CmdRhsFunction(SoarCommandInterpreter interp)
+ public CmdRhsFunction(SoarCommandInterpreter interp, Agent agent)
{
super("cmd", 1, Integer.MAX_VALUE);
- this.interp = interp;
+ this.interp = interp;
+ this.agent = agent;
}

/* (non-Javadoc)
@@ -75,7 +78,7 @@
// actually works like csoar (i.e., you have call write for it
to appear
// the actual returned result gets concatenated at the end.
This should match how the command output looks when executed normally
// while still matching csoar's behavior.
- Printer printer = context.getAgent().getPrinter();
+ Printer printer = this.agent.getPrinter();
StringWriter stringWriter = new StringWriter();
printer.pushWriter(stringWriter);
String result = command.execute(commandContext,
commandArgs.toArray(new String[commandArgs.size()]));
=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/RhsFunctionContext.java
Thu Jun 12 13:38:41 2014 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/RhsFunctionContext.java
Thu Jun 12 17:18:13 2014 UTC
@@ -44,10 +44,4 @@
*/
Production getProductionBeingFired();

- /**
- * Returns the agent that this is happening in.
- *
- * @return The agent
- */
- Agent getAgent();
}
=======================================
---
/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/StandardFunctions.java
Mon May 19 18:31:46 2014 UTC
+++
/jsoar-core/src/main/java/org/jsoar/kernel/rhs/functions/StandardFunctions.java
Thu Jun 12 17:18:13 2014 UTC
@@ -127,7 +127,7 @@
allInternal.add(new Interrupt(decisionCycle));
allInternal.add(new Debug(context));
allInternal.add(new ExecRhsFunction(context.getRhsFunctions()));
- allInternal.add(new CmdRhsFunction(context.getInterpreter()));
+ allInternal.add(new CmdRhsFunction(context.getInterpreter(),
context));

allInternal.add(new RandomInt(context.getRandom()));
allInternal.add(new RandomFloat(context.getRandom()));
=======================================
--- /jsoar-core/src/test/java/org/jsoar/JSoarTest.java Thu Jun 12 13:38:41
2014 UTC
+++ /jsoar-core/src/test/java/org/jsoar/JSoarTest.java Thu Jun 12 17:18:13
2014 UTC
@@ -54,14 +54,6 @@
{
return null;
}
-
- /* (non-Javadoc)
- * @see
org.jsoar.kernel.rhs.functions.RhsFunctionContext#getAgent()
- */
- @Override
- public Agent getAgent() {
- return null;
- }

};

=======================================
--- /jsoar-tcl/src/main/java/org/jsoar/tcl/SoarTclInterface.java Tue Jun 3
14:23:34 2014 UTC
+++ /jsoar-tcl/src/main/java/org/jsoar/tcl/SoarTclInterface.java Thu Jun 12
17:18:13 2014 UTC
@@ -119,11 +119,12 @@
private ReteNetCommand reteNetCommand;

private final TclRhsFunction tclRhsFunction = new TclRhsFunction(this);
- private final CmdRhsFunction cmdRhsFunction = new CmdRhsFunction(this);
+ private final CmdRhsFunction cmdRhsFunction;

private SoarTclInterface(Agent agent)
{
this.agent = agent;
+ this.cmdRhsFunction = new CmdRhsFunction(this, agent);

initializeEnv();
this.agent.getRhsFunctions().registerHandler(tclRhsFunction);
Reply all
Reply to author
Forward
0 new messages