Finish test clean-up & reorg.
[gem5.git] / src / sim / sim_events.hh
index 89bf83fc90702b4d48512717f3eb79cd2abf84fd..3c4a9dd05f6814f960b737b880288530512e6859 100644 (file)
@@ -36,7 +36,7 @@
 //
 // Event to terminate simulation at a particular cycle/instruction
 //
-class SimExitEvent : public Event
+class SimLoopExitEvent : public Event
 {
   private:
     // string explaining why we're terminating
@@ -44,30 +44,45 @@ class SimExitEvent : public Event
     int code;
 
   public:
-    SimExitEvent(const std::string &_cause, int c = 0)
-        : Event(&mainEventQueue, Sim_Exit_Pri), cause(_cause),
-          code(c)
-        { schedule(curTick); }
+    // Default constructor.  Only really used for derived classes.
+    SimLoopExitEvent()
+        : Event(&mainEventQueue, Sim_Exit_Pri)
+    { }
 
-    SimExitEvent(Tick _when, const std::string &_cause, int c = 0)
+    SimLoopExitEvent(Tick _when, const std::string &_cause, int c = 0)
         : Event(&mainEventQueue, Sim_Exit_Pri), cause(_cause),
           code(c)
-        { schedule(_when); }
+    { setFlags(IsExitEvent); schedule(_when); }
 
-    SimExitEvent(EventQueue *q, const std::string &_cause, int c = 0)
+    SimLoopExitEvent(EventQueue *q,
+                     Tick _when, const std::string &_cause, int c = 0)
         : Event(q, Sim_Exit_Pri), cause(_cause), code(c)
-        { schedule(curTick); }
+    { setFlags(IsExitEvent); schedule(_when); }
 
-    SimExitEvent(EventQueue *q, Tick _when, const std::string &_cause,
-                 int c = 0)
-        : Event(q, Sim_Exit_Pri), cause(_cause), code(c)
-        { schedule(_when); }
+    std::string getCause() { return cause; }
+    int getCode() { return code; }
 
     void process();    // process event
 
     virtual const char *description();
 };
 
+class CountedDrainEvent : public SimLoopExitEvent
+{
+  private:
+    // Count of how many objects have not yet drained
+    int count;
+  public:
+    CountedDrainEvent()
+        : count(0)
+    { }
+    void process();
+
+    void setCount(int _count) { count = _count; }
+
+    int getCount() { return count; }
+};
+
 //
 // Event class to terminate simulation after 'n' related events have
 // occurred using a shared counter: used to terminate when *all*