add Fleet.getDefaultImpl() and use it in Makefile
[fleet.git] / src / edu / berkeley / fleet / api / Fleet.java
index ce0cfb2..0e9700c 100644 (file)
@@ -35,6 +35,12 @@ public abstract class Fleet implements Iterable<Ship> {
 
     /** the width of the immediate field in the "set data latch" instruction */
     public abstract int getSetWidth();
+
+    /** FIXME: this will soon become a property of individual memories rather than the entire Fleet */
+    public abstract int getMaxCodeBagSize();
+
+    /** FIXME: this will soon become a property of individual memories rather than the entire Fleet */
+    public abstract BitVector makeCodeBagDescriptor(long offset, long length);
     
     /**
      *  Encodes an instruction as a BitVector
@@ -54,4 +60,16 @@ public abstract class Fleet implements Iterable<Ship> {
     public FleetProcess run(Instruction[] program) {
         throw new RuntimeException("class " + this.getClass().getName() + " does not implement method run()");
     }
+
+    /** Assumes that the system property "fleet.impl" holds the name of a subclass to instantiate */
+    public static Fleet getDefaultImpl() {
+        String impl = System.getProperty("fleet.impl");
+        if (impl==null) throw new RuntimeException("You must invoke the JVM with -Dfleet.impl=<impl>");
+        try {
+            return (Fleet)Class.forName(impl).newInstance();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
 }