add Timer::GetDelayLeft
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 04 Oct 2007 09:22:05 +0200
changeset 1693 bf884d490040
parent 1692 b35ba80cafef
child 1694 fc22854fc549
add Timer::GetDelayLeft
src/simulator/timer.cc
src/simulator/timer.h
--- a/src/simulator/timer.cc	Thu Oct 04 09:14:16 2007 +0200
+++ b/src/simulator/timer.cc	Thu Oct 04 09:22:05 2007 +0200
@@ -57,7 +57,25 @@
 {
   return m_delay;
 }
-
+Time
+Timer::GetDelayLeft (void) const
+{
+  switch (GetState ()) {
+  case Timer::RUNNING:
+    return Simulator::GetDelayLeft (m_event);
+    break;
+  case Timer::EXPIRED:
+    return TimeStep (0);
+    break;
+  case Timer::SUSPENDED:
+    return m_delayLeft;
+    break;
+  default:
+    NS_ASSERT (false);
+    return TimeStep (0);
+    break;
+  }
+}
 
 void 
 Timer::Cancel (void)
--- a/src/simulator/timer.h	Thu Oct 04 09:14:16 2007 +0200
+++ b/src/simulator/timer.h	Thu Oct 04 09:22:05 2007 +0200
@@ -178,6 +178,12 @@
    */
   Time GetDelay (void) const;
   /**
+   * \returns the amount of time left until this timer expires.
+   *
+   * This method returns zero if the timer is in EXPIRED state.
+   */
+  Time GetDelayLeft (void) const;
+  /**
    * Cancel the currently-running event if there is one. Do nothing
    * otherwise.
    */