1 package edu.berkeley.fleet;
3 import edu.berkeley.sbp.chr.*;
4 import edu.berkeley.sbp.misc.*;
5 import edu.berkeley.sbp.meta.*;
6 import edu.berkeley.sbp.bind.*;
7 import edu.berkeley.sbp.util.*;
11 /** a ship, which belongs to a fleet and which may have many ports */
12 public abstract class Ship {
14 ArrayList<Port> portlist = new ArrayList<Port>();
15 private HashMap<String,Port> ports = new HashMap<String,Port>();
20 /** You should instantiate a bunch of Inboxes and Outboxes in your constructor */
21 public Ship(Fleet fleet, String name) {
24 fleet.shiplist.add(this);
25 fleet.ships.put(name, this);
28 public Port getPort(String s) {
29 Port p = ports.get(s);
30 if (p == null) throw new RuntimeException("unknown port \""+name+"."+s+"\"");
34 public String getBalsaName() { return name; }
35 public String getName() { return name; }
36 public String toString() { return name; }
38 public Fleet getFleet() { return fleet; }
41 * Override this method, check inboxes for the data you need, and
42 * if you find it, deposit results in an outbox; we'll take care
45 public abstract void service();
47 public final void _service() {
48 for(Port p : ports.values()) p.service();
52 void addPort(String name, Port port) {
54 ports.put(name, port);
57 public void shutdown() {
58 for(Port p : ports.values())
62 public int resolveShipSpecificConstant(String shipSpecificData) {
63 throw new RuntimeException("don't know how to resolve \""+shipSpecificData+"\"");