SoarQMemoryAdapter implements SoarEventListener, QMemoryListener { public void detach() { synchronized(lock) { if(this.io != null) { this.io.getEvents().removeListener(null, this); removeAllWmes(io, memory); } this.io = null; this.memory = null; } } SoarQMemoryAdapter(); static SoarQMemoryAdapter attach(Agent agent, QMemory source); static SoarQMemoryAdapter attach(InputOutput io, Identifier rootId, QMemory source); void initialize(InputOutput io, Identifier rootId); void detach(); QMemory getSource(); void setSource(QMemory source); Symbol getValue(String path); @Override void onEvent(SoarEvent event); @Override void onQMemoryChanged();  }
@Test public void testDetach() throws Exception { ifc.eval("soar wait-snc --on"); QMemory qmem = DefaultQMemory.create(); SoarQMemoryAdapter adapter = SoarQMemoryAdapter.attach(agent, qmem); qmem.setInteger("cycles", 99); qmem.setDouble("location.x", 3.14159); qmem.setDouble("location.y", 10.0); qmem.setString("agent.info.name", "test"); agent.runFor(2, RunType.DECISIONS); assertEquals(3, Iterators.size(agent.getInputOutput().getInputLink().getWmes())); adapter.detach(); assertEquals(3, Iterators.size(agent.getInputOutput().getInputLink().getWmes())); agent.runFor(1, RunType.DECISIONS); assertEquals(0, Iterators.size(agent.getInputOutput().getInputLink().getWmes())); }