add Simulator::GetDelayLeft
This commit is contained in:
@@ -67,9 +67,10 @@ public:
|
||||
EventId ScheduleDestroy (const Ptr<EventImpl> &event);
|
||||
void Remove (const EventId &ev);
|
||||
void Cancel (const EventId &ev);
|
||||
bool IsExpired (const EventId &ev);
|
||||
bool IsExpired (const EventId &ev) const;
|
||||
void Run (void);
|
||||
Time Now (void) const;
|
||||
Time GetDelayLeft (const EventId &id) const;
|
||||
|
||||
private:
|
||||
void ProcessOneEvent (void);
|
||||
@@ -251,6 +252,18 @@ SimulatorPrivate::Now (void) const
|
||||
{
|
||||
return TimeStep (m_currentTs);
|
||||
}
|
||||
Time
|
||||
SimulatorPrivate::GetDelayLeft (const EventId &id) const
|
||||
{
|
||||
if (IsExpired (id))
|
||||
{
|
||||
return TimeStep (0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return TimeStep (id.GetTs () - m_currentTs);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SimulatorPrivate::Remove (const EventId &ev)
|
||||
@@ -293,12 +306,12 @@ SimulatorPrivate::Cancel (const EventId &id)
|
||||
}
|
||||
|
||||
bool
|
||||
SimulatorPrivate::IsExpired (const EventId &ev)
|
||||
SimulatorPrivate::IsExpired (const EventId &ev) const
|
||||
{
|
||||
if (ev.GetUid () == 2)
|
||||
{
|
||||
// destroy events.
|
||||
for (DestroyEvents::iterator i = m_destroyEvents.begin (); i != m_destroyEvents.end (); i++)
|
||||
for (DestroyEvents::const_iterator i = m_destroyEvents.begin (); i != m_destroyEvents.end (); i++)
|
||||
{
|
||||
if (*i == ev)
|
||||
{
|
||||
@@ -411,6 +424,11 @@ Simulator::Now (void)
|
||||
{
|
||||
return GetPriv ()->Now ();
|
||||
}
|
||||
Time
|
||||
Simulator::GetDelayLeft (const EventId &id)
|
||||
{
|
||||
return GetPriv ()->GetDelayLeft (id);
|
||||
}
|
||||
|
||||
Ptr<EventImpl>
|
||||
Simulator::MakeEvent (void (*f) (void))
|
||||
|
||||
@@ -552,6 +552,13 @@ public:
|
||||
* Return the "current simulation time".
|
||||
*/
|
||||
static Time Now (void);
|
||||
/**
|
||||
* \param id the event id to analyse
|
||||
* \returns the delay left until the input event id expires.
|
||||
* if the event is not running, this method returns
|
||||
* zero.
|
||||
*/
|
||||
static Time GetDelayLeft (const EventId &id);
|
||||
private:
|
||||
Simulator ();
|
||||
~Simulator ();
|
||||
|
||||
Reference in New Issue
Block a user