samer@0: /* samer@0: * CompoundAgent.java samer@0: * samer@0: * Copyright (c) 2000, Samer Abdallah, King's College London. samer@0: * All rights reserved. samer@0: * samer@0: * This software is provided AS iS and WITHOUT ANY WARRANTY; samer@0: * without even the implied warranty of MERCHANTABILITY or samer@0: * FITNESS FOR A PARTICULAR PURPOSE. samer@0: */ samer@0: samer@0: package samer.core; samer@0: samer@0: /** An Agent that is a composition of two given Agents. */ samer@0: public class CompoundAgent implements Agent samer@0: { samer@0: Agent a1, a2; samer@0: samer@0: public CompoundAgent(Agent a1,Agent a2) { this.a1=a1; this.a2=a2; } samer@0: samer@0: /** This reports the commands from both the child agents. Duplicate samer@0: commands are not removed. */ samer@0: public void getCommands(Registry r) { a1.getCommands(r); r.group(); a2.getCommands(r); } samer@0: samer@0: /** Forwards the the command on to BOTH child agents in the order specified samer@0: in the constructor. */ samer@0: public void execute( String name, Environment env) throws Exception { samer@0: a1.execute(name,env); samer@0: a2.execute(name,env); samer@0: } samer@0: }