//
// Event to terminate simulation at a particular cycle/instruction
//
-class SimExitEvent : public Event
+class SimLoopExitEvent : public Event
{
private:
// string explaining why we're terminating
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*