core: add a Simulator::GetStopEvent
This commit is contained in:
committed by
Tommaso Pecorella
parent
a3d8cc4c23
commit
808e3b4ec7
@@ -209,11 +209,11 @@ DefaultSimulatorImpl::Stop()
|
||||
m_stop = true;
|
||||
}
|
||||
|
||||
void
|
||||
EventId
|
||||
DefaultSimulatorImpl::Stop(const Time& delay)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << delay.GetTimeStep());
|
||||
Simulator::Schedule(delay, &Simulator::Stop);
|
||||
return Simulator::Schedule(delay, &Simulator::Stop);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -61,7 +61,7 @@ class DefaultSimulatorImpl : public SimulatorImpl
|
||||
void Destroy() override;
|
||||
bool IsFinished() const override;
|
||||
void Stop() override;
|
||||
void Stop(const Time& delay) override;
|
||||
EventId Stop(const Time& delay) override;
|
||||
EventId Schedule(const Time& delay, EventImpl* event) override;
|
||||
void ScheduleWithContext(uint32_t context, const Time& delay, EventImpl* event) override;
|
||||
EventId ScheduleNow(EventImpl* event) override;
|
||||
|
||||
@@ -497,11 +497,11 @@ RealtimeSimulatorImpl::Stop()
|
||||
m_stop = true;
|
||||
}
|
||||
|
||||
void
|
||||
EventId
|
||||
RealtimeSimulatorImpl::Stop(const Time& delay)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << delay);
|
||||
Simulator::Schedule(delay, &Simulator::Stop);
|
||||
return Simulator::Schedule(delay, &Simulator::Stop);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -91,7 +91,7 @@ class RealtimeSimulatorImpl : public SimulatorImpl
|
||||
void Destroy() override;
|
||||
bool IsFinished() const override;
|
||||
void Stop() override;
|
||||
void Stop(const Time& delay) override;
|
||||
EventId Stop(const Time& delay) override;
|
||||
EventId Schedule(const Time& delay, EventImpl* event) override;
|
||||
void ScheduleWithContext(uint32_t context, const Time& delay, EventImpl* event) override;
|
||||
EventId ScheduleNow(EventImpl* event) override;
|
||||
|
||||
@@ -61,7 +61,7 @@ class SimulatorImpl : public Object
|
||||
/** \copydoc Simulator::Stop() */
|
||||
virtual void Stop() = 0;
|
||||
/** \copydoc Simulator::Stop(const Time&) */
|
||||
virtual void Stop(const Time& delay) = 0;
|
||||
virtual EventId Stop(const Time& delay) = 0;
|
||||
/** \copydoc Simulator::Schedule(const Time&,const Ptr<EventImpl>&) */
|
||||
virtual EventId Schedule(const Time& delay, EventImpl* event) = 0;
|
||||
/** \copydoc Simulator::ScheduleWithContext(uint32_t,const Time&,EventImpl*) */
|
||||
|
||||
@@ -54,6 +54,8 @@ namespace ns3
|
||||
// of causing recursions leading to stack overflow
|
||||
NS_LOG_COMPONENT_DEFINE("Simulator");
|
||||
|
||||
EventId Simulator::m_stopEvent;
|
||||
|
||||
/**
|
||||
* \ingroup simulator
|
||||
* \anchor GlobalValueSimulatorImplementationType
|
||||
@@ -192,7 +194,13 @@ void
|
||||
Simulator::Stop(const Time& delay)
|
||||
{
|
||||
NS_LOG_FUNCTION(delay);
|
||||
GetImpl()->Stop(delay);
|
||||
m_stopEvent = GetImpl()->Stop(delay);
|
||||
}
|
||||
|
||||
EventId
|
||||
Simulator::GetStopEvent()
|
||||
{
|
||||
return m_stopEvent;
|
||||
}
|
||||
|
||||
Time
|
||||
|
||||
@@ -169,6 +169,12 @@ class Simulator
|
||||
*/
|
||||
static void Stop(const Time& delay);
|
||||
|
||||
/**
|
||||
* Returns the Stop Event, or an invalid event if the simulation
|
||||
* does not have a scheduled stop time.
|
||||
*/
|
||||
static EventId GetStopEvent();
|
||||
|
||||
/**
|
||||
* Get the current simulation context.
|
||||
*
|
||||
@@ -520,6 +526,11 @@ class Simulator
|
||||
*/
|
||||
static EventId DoScheduleDestroy(EventImpl* event);
|
||||
|
||||
/**
|
||||
* Stop event (if present)
|
||||
*/
|
||||
static EventId m_stopEvent;
|
||||
|
||||
}; // class Simulator
|
||||
|
||||
/**
|
||||
|
||||
@@ -464,12 +464,12 @@ DistributedSimulatorImpl::Stop()
|
||||
m_stop = true;
|
||||
}
|
||||
|
||||
void
|
||||
EventId
|
||||
DistributedSimulatorImpl::Stop(const Time& delay)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << delay.GetTimeStep());
|
||||
|
||||
Simulator::Schedule(delay, &Simulator::Stop);
|
||||
return Simulator::Schedule(delay, &Simulator::Stop);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -122,7 +122,7 @@ class DistributedSimulatorImpl : public SimulatorImpl
|
||||
void Destroy() override;
|
||||
bool IsFinished() const override;
|
||||
void Stop() override;
|
||||
void Stop(const Time& delay) override;
|
||||
EventId Stop(const Time& delay) override;
|
||||
EventId Schedule(const Time& delay, EventImpl* event) override;
|
||||
void ScheduleWithContext(uint32_t context, const Time& delay, EventImpl* event) override;
|
||||
EventId ScheduleNow(EventImpl* event) override;
|
||||
|
||||
@@ -382,12 +382,12 @@ NullMessageSimulatorImpl::Stop()
|
||||
m_stop = true;
|
||||
}
|
||||
|
||||
void
|
||||
EventId
|
||||
NullMessageSimulatorImpl::Stop(const Time& delay)
|
||||
{
|
||||
NS_LOG_FUNCTION(this << delay.GetTimeStep());
|
||||
|
||||
Simulator::Schedule(delay, &Simulator::Stop);
|
||||
return Simulator::Schedule(delay, &Simulator::Stop);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -66,7 +66,7 @@ class NullMessageSimulatorImpl : public SimulatorImpl
|
||||
void Destroy() override;
|
||||
bool IsFinished() const override;
|
||||
void Stop() override;
|
||||
void Stop(const Time& delay) override;
|
||||
EventId Stop(const Time& delay) override;
|
||||
EventId Schedule(const Time& delay, EventImpl* event) override;
|
||||
void ScheduleWithContext(uint32_t context, const Time& delay, EventImpl* event) override;
|
||||
EventId ScheduleNow(EventImpl* event) override;
|
||||
|
||||
@@ -140,10 +140,10 @@ VisualSimulatorImpl::Stop()
|
||||
m_simulator->Stop();
|
||||
}
|
||||
|
||||
void
|
||||
EventId
|
||||
VisualSimulatorImpl::Stop(const Time& delay)
|
||||
{
|
||||
m_simulator->Stop(delay);
|
||||
return m_simulator->Stop(delay);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -56,7 +56,7 @@ class VisualSimulatorImpl : public SimulatorImpl
|
||||
void Destroy() override;
|
||||
bool IsFinished() const override;
|
||||
void Stop() override;
|
||||
void Stop(const Time& delay) override;
|
||||
EventId Stop(const Time& delay) override;
|
||||
EventId Schedule(const Time& delay, EventImpl* event) override;
|
||||
void ScheduleWithContext(uint32_t context, const Time& delay, EventImpl* event) override;
|
||||
EventId ScheduleNow(EventImpl* event) override;
|
||||
|
||||
Reference in New Issue
Block a user