diff src/samer/core_/CompoundAgent.java @ 0:bf79fb79ee13

Initial Mercurial check in.
author samer
date Tue, 17 Jan 2012 17:50:20 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/samer/core_/CompoundAgent.java	Tue Jan 17 17:50:20 2012 +0000
@@ -0,0 +1,31 @@
+/*
+ *	CompoundAgent.java	
+ *
+ *	Copyright (c) 2000, Samer Abdallah, King's College London.
+ *	All rights reserved.
+ *
+ *	This software is provided AS iS and WITHOUT ANY WARRANTY; 
+ *	without even the implied warranty of MERCHANTABILITY or 
+ *	FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+package samer.core;
+
+/** An Agent that is a composition of two given Agents. */
+public class CompoundAgent implements Agent
+{
+	Agent a1, a2;
+
+	public CompoundAgent(Agent a1,Agent a2) { this.a1=a1; this.a2=a2; }
+
+	/** This reports the commands from both the child agents. Duplicate
+		commands are not removed. */
+	public void getCommands(Registry r) { a1.getCommands(r); r.group(); a2.getCommands(r); }
+
+	/** Forwards the the command on to BOTH child agents in the order specified
+		in the constructor. */
+	public void execute( String name, Environment env) throws Exception {
+		a1.execute(name,env);
+		a2.execute(name,env);
+	}
+}