1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.fleet.api.*;
3 import edu.berkeley.fleet.two.*;
7 /** a ship, which belongs to a fleet and which may have many ports */
8 abstract class InterpreterShip extends FleetTwoShip {
10 /** You should instantiate a bunch of Inboxes and Outboxes in your constructor */
11 public InterpreterShip(Interpreter fleet, String name, ShipDescription sd) {
15 private HashMap<String,InstructionDock> ports = new HashMap<String,InstructionDock>();
17 public Iterator<Dock> iterator() { return (Iterator<Dock>)(Object)ports.values().iterator(); }
18 public Interpreter getInterpreter() { return (Interpreter)getFleet(); }
21 * Override this method, check inboxes for the data you need, and
22 * if you find it, deposit results in an outbox; we'll take care
25 public abstract void service();
27 public final void _service() {
28 for(InstructionDock p : ports.values()) p.service();
32 protected void addDock(String name, InstructionDock port) {
33 ports.put(name, port);
36 public void shutdown() {
37 for(InstructionDock p : ports.values())