add Timer::GetDelayLeft

This commit is contained in:
Mathieu Lacage
2007-10-04 09:22:05 +02:00
parent b28727ef8c
commit f70700c330
2 changed files with 25 additions and 1 deletions

View File

@@ -57,7 +57,25 @@ Timer::GetDelay (void) const
{
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)

View File

@@ -177,6 +177,12 @@ public:
* \returns the currently-configured delay for the next Schedule.
*/
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.