remove superfluous computeOffset() and computeTarget()
[fleet.git] / src / edu / berkeley / fleet / api / Fleet.java
1 package edu.berkeley.fleet.api;
2 import edu.berkeley.fleet.doc.*;
3 import java.io.*;
4 import java.util.*;
5
6 public abstract class Fleet implements Iterable<Ship> {
7
8     /** read a machine-formatted instruction from a file (into a Java object) */
9     public abstract Instruction readInstruction(DataInputStream is) throws IOException;
10
11     /** write a machine-formatted instruction to a file (from a Java object) */
12     public abstract void        writeInstruction(DataOutputStream os, Instruction instr) throws IOException;
13
14     /** ships must be returned in the same order every time -- ordering may be significant */
15     public abstract Iterator<Ship> iterator();
16
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()");
20     }
21
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()");
25     }
26
27     /**
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.
30      */
31     public static interface WithDynamicShips {
32         public Ship createShip(String shiptype, String shipname);
33     }
34
35 }