change internal uses of "port" to "dock"
[fleet.git] / src / edu / berkeley / fleet / interpreter / InterpreterShip.java
1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.fleet.api.*;
3 import edu.berkeley.fleet.two.*;
4 import java.util.*;
5 import java.io.*;
6
7 /** a ship, which belongs to a fleet and which may have many docks */
8 abstract class InterpreterShip extends FleetTwoShip {
9         
10     LinkedHashMap<String,InterpreterDock> docks = new LinkedHashMap<String,InterpreterDock>();
11
12     /** You should instantiate a bunch of Inboxes and Outboxes in your constructor */
13     public InterpreterShip(Interpreter fleet, ShipDescription sd) {
14         super(fleet, sd);
15     }
16
17     public Iterator<Dock> iterator() {
18         return (Iterator<Dock>)(Object)docks.values().iterator();
19     }
20
21     /**
22      *  Override this method, check inboxes for the data you need, and
23      *  if you find it, deposit results in an outbox; we'll take care
24      *  of the rest.
25      */
26     public abstract void service();
27
28     public final void _service() {
29         for(InterpreterDock p : docks.values()) p.service();
30         service();
31     }
32
33     public void reset() {
34         for(InterpreterDock p : docks.values())
35             p.reset();
36     }
37
38     public Interpreter getInterpreter() { return (Interpreter)getFleet(); }
39 }