Fix tabbing.... Please fix your editors so they do tabbing correctly!!! (Spaces...
[IRC.git] / Robust / src / Analysis / Scheduling / ObjectSimulator.java
index 3eebda44246e3f4c815bae1d1d97a37d81c9567d..69421a4fe82b1abf5e67f5e47f5ec6e9a5bcacab 100644 (file)
@@ -5,6 +5,9 @@ import Analysis.TaskStateAnalysis.FlagState;
 import IR.ClassDescriptor;
 
 public class ObjectSimulator {
+  static int objid = 0;
+
+  int oid;
   ClassDescriptor cd;
   FlagState currentFS;
   boolean changed;
@@ -12,25 +15,47 @@ public class ObjectSimulator {
   boolean hold;
   int version;
 
-  public ObjectSimulator(ClassDescriptor cd, FlagState currentFS) {
+  // TODO, crack for KMeans
+  int counter;
+
+  public ObjectSimulator(ClassDescriptor cd,
+                         FlagState currentFS) {
     super();
+    this.oid = ObjectSimulator.objid++;
     this.cd = cd;
     this.currentFS = currentFS;
     this.changed = true;
     this.shared = false;
     this.hold = false;
     this.version = 0;
+    if(this.cd.getSymbol().equals("Cluster")) {
+      this.counter = 83 * 2 + 1; //102 * 2 + 1; //83 * 2 + 1;
+    } else {
+      this.counter = -1;
+    }
   }
 
   public void applyEdge(FEdge fedge) {
     if(!currentFS.equals((FlagState)fedge.getTarget())) {
       this.changed = true;
       currentFS = (FlagState)fedge.getTarget();
+      if(this.counter > 0) {
+       //System.err.println(this.counter);
+       this.counter--;
+      }
+      if((this.cd.getSymbol().equals("Cluster")) && (this.counter == 0)) {
+       // go to end state
+       this.currentFS = new FlagState(this.cd);
+      }
     } else {
       this.changed = false;
     }
   }
 
+  public int getOid() {
+    return oid;
+  }
+
   public ClassDescriptor getCd() {
     return cd;
   }
@@ -71,4 +96,4 @@ public class ObjectSimulator {
   public void increaseVersion() {
     this.version++;
   }
-}
\ No newline at end of file
+}