1 package edu.berkeley.fleet.api;
2 import edu.berkeley.fleet.doc.*;
6 public abstract class Fleet implements Iterable<Ship> {
8 /** read a machine-formatted instruction from a file (into a Java object) */
9 public abstract Instruction readInstruction(DataInputStream is) throws IOException;
11 /** write a machine-formatted instruction to a file (from a Java object) */
12 public abstract void writeInstruction(DataOutputStream os, Instruction instr) throws IOException;
14 /** ships must be returned in the same order every time -- ordering may be significant */
15 public abstract Iterator<Ship> iterator();
17 /** if possible, run the given code and create a FleetProcess */
18 public FleetProcess run(byte[] code) {
19 throw new RuntimeException("class " + this.getClass().getName() + " does not implement method run()");
22 /** extract the portion of ShipDescription which is specific to this fleet and generate any source code necessary */
23 public void expand(ShipDescription sd) {
24 throw new RuntimeException("class " + this.getClass().getName() + " does not implement method expand()");
28 * This interface marks Fleets which can create ships on the fly, like the fleeterpreter;
29 * if available, the parser will use this interface to create ships out of #ship definitions.
31 public static interface WithDynamicShips {
32 public Ship createShip(String shiptype, String shipname);