From f90fd0884de2d0f0e408182a77ccfd8474f9cc21 Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Tue, 14 Oct 2008 22:52:41 -0700 Subject: [PATCH] slight reorganization and naming change for added realtime methods --- samples/main-test-sync.cc | 6 +- src/simulator/realtime-simulator-impl.cc | 10 +- src/simulator/realtime-simulator-impl.h | 6 +- src/simulator/realtime-simulator.cc | 74 ------------ src/simulator/realtime-simulator.h | 148 +++++++++++------------ src/simulator/simulator.cc | 45 +++++++ src/simulator/simulator.h | 2 +- src/simulator/wscript | 1 - 8 files changed, 131 insertions(+), 161 deletions(-) delete mode 100644 src/simulator/realtime-simulator.cc diff --git a/samples/main-test-sync.cc b/samples/main-test-sync.cc index 04e34d56b..1e30acdf5 100644 --- a/samples/main-test-sync.cc +++ b/samples/main-test-sync.cc @@ -97,7 +97,7 @@ FakeNetDevice::Doit3 (void) // // Exercise the realtime relative now path // - RealtimeSimulatorExtension::ScheduleRealNow (&inserted_function); + RealtimeSimulator::ScheduleRealtimeNow (&inserted_function); usleep (1000); } } @@ -112,7 +112,7 @@ FakeNetDevice::Doit4 (void) // // Exercise the realtime relative schedule path // - RealtimeSimulatorExtension::ScheduleReal (Seconds (0), &inserted_function); + RealtimeSimulator::ScheduleRealtime (Seconds (0), &inserted_function); usleep (1000); } } @@ -128,7 +128,7 @@ test (void) // // Make sure ScheduleRealNow works when the system isn't running // - RealtimeSimulatorExtension::ScheduleRealNow(&first_function); + RealtimeSimulator::ScheduleRealtimeNow(&first_function); // // drive the progression of m_currentTs at a ten millisecond rate diff --git a/src/simulator/realtime-simulator-impl.cc b/src/simulator/realtime-simulator-impl.cc index 650c91e25..400c65663 100644 --- a/src/simulator/realtime-simulator-impl.cc +++ b/src/simulator/realtime-simulator-impl.cc @@ -629,7 +629,7 @@ RealtimeSimulatorImpl::Now (void) const // Schedule an event for a _relative_ time in the future. // EventId -RealtimeSimulatorImpl::ScheduleReal (Time const &time, const Ptr &event) +RealtimeSimulatorImpl::ScheduleRealtime (Time const &time, const Ptr &event) { NS_LOG_FUNCTION (time << event); @@ -638,7 +638,7 @@ RealtimeSimulatorImpl::ScheduleReal (Time const &time, const Ptr &eve CriticalSection cs (m_mutex); uint64_t ts = m_synchronizer->GetCurrentRealtime () + time.GetTimeStep (); - NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleReal(): schedule for time < m_currentTs"); + NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealtime(): schedule for time < m_currentTs"); id = EventId (event, ts, m_uid); m_uid++; ++m_unscheduledEvents; @@ -650,7 +650,7 @@ RealtimeSimulatorImpl::ScheduleReal (Time const &time, const Ptr &eve } EventId -RealtimeSimulatorImpl::ScheduleRealNow (const Ptr &event) +RealtimeSimulatorImpl::ScheduleRealtimeNow (const Ptr &event) { NS_LOG_FUNCTION_NOARGS (); EventId id; @@ -662,7 +662,7 @@ RealtimeSimulatorImpl::ScheduleRealNow (const Ptr &event) // realtime clock. If we're not, then m_currentTs is were we stopped. // uint64_t ts = m_running ? m_synchronizer->GetCurrentRealtime () : m_currentTs; - NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealNow(): schedule for time < m_currentTs"); + NS_ASSERT_MSG (ts >= m_currentTs, "RealtimeSimulatorImpl::ScheduleRealrimeNow(): schedule for time < m_currentTs"); id = EventId (event, ts, m_uid); m_uid++; ++m_unscheduledEvents; @@ -674,7 +674,7 @@ RealtimeSimulatorImpl::ScheduleRealNow (const Ptr &event) } Time -RealtimeSimulatorImpl::RealNow (void) const +RealtimeSimulatorImpl::RealtimeNow (void) const { return TimeStep (m_synchronizer->GetCurrentRealtime ()); } diff --git a/src/simulator/realtime-simulator-impl.h b/src/simulator/realtime-simulator-impl.h index 52d53ab11..55a19417a 100644 --- a/src/simulator/realtime-simulator-impl.h +++ b/src/simulator/realtime-simulator-impl.h @@ -69,11 +69,11 @@ public: void Stop (Time const &time); EventId Schedule (Time const &time, const Ptr &event); EventId ScheduleNow (const Ptr &event); - EventId ScheduleReal (Time const &time, const Ptr &event); - EventId ScheduleRealNow (const Ptr &event); + EventId ScheduleRealtime (Time const &time, const Ptr &event); + EventId ScheduleRealtimeNow (const Ptr &event); EventId ScheduleDestroy (const Ptr &event); Time Now (void) const; - Time RealNow (void) const; + Time RealtimeNow (void) const; void Remove (const EventId &ev); void Cancel (const EventId &ev); bool IsExpired (const EventId &ev) const; diff --git a/src/simulator/realtime-simulator.cc b/src/simulator/realtime-simulator.cc deleted file mode 100644 index c11b4a8ce..000000000 --- a/src/simulator/realtime-simulator.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2008 University of Washington - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "simulator.h" -#include "realtime-simulator.h" -#include "realtime-simulator-impl.h" -#include "event-impl.h" - -#include "ns3/assert.h" -#include "ns3/log.h" - -NS_LOG_COMPONENT_DEFINE ("RealtimeSimulatorExtension"); - -namespace ns3 { - -RealtimeSimulatorImpl * -RealtimeSimulatorExtension::GetRealtimeImpl (void) -{ - RealtimeSimulatorImpl *impl = dynamic_cast(Simulator::GetImpl ()); - NS_ASSERT_MSG (impl, - "RealtimeSimulatorExtension::GetImpl (): Underlying simulator implementation not realtime"); - return impl; -} - -Time -RealtimeSimulatorExtension::RealNow (void) -{ - return GetRealtimeImpl ()->RealNow (); -} - -EventId -RealtimeSimulatorExtension::ScheduleReal (Time const &time, const Ptr &ev) -{ - NS_LOG_FUNCTION (time << ev); - return GetRealtimeImpl ()->ScheduleReal (time, ev); -} - -EventId -RealtimeSimulatorExtension::ScheduleRealNow (const Ptr &ev) -{ - NS_LOG_FUNCTION (ev); - return GetRealtimeImpl ()->ScheduleRealNow (ev); -} - -EventId -RealtimeSimulatorExtension::ScheduleReal (Time const &time, void (*f) (void)) -{ - NS_LOG_FUNCTION (time << f); - return ScheduleReal (time, Simulator::MakeEvent (f)); -} - -EventId -RealtimeSimulatorExtension::ScheduleRealNow (void (*f) (void)) -{ - NS_LOG_FUNCTION (f); - return ScheduleRealNow (Simulator::MakeEvent (f)); -} - -} // namespace ns3 diff --git a/src/simulator/realtime-simulator.h b/src/simulator/realtime-simulator.h index c7e6d12fa..a6028a693 100644 --- a/src/simulator/realtime-simulator.h +++ b/src/simulator/realtime-simulator.h @@ -32,7 +32,7 @@ namespace ns3 { * events and will schedule events using the current real-time instead of * the current simulation time. */ -class RealtimeSimulatorExtension +class RealtimeSimulator { public: /** @@ -49,7 +49,7 @@ public: * @returns an id for the scheduled event. */ template - static EventId ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj); + static EventId ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj); /** * @param time the relative expiration time of the event. @@ -59,7 +59,7 @@ public: * @returns an id for the scheduled event. */ template - static EventId ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, T1 a1); + static EventId ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1); /** * @param time the relative expiration time of the event. @@ -70,7 +70,7 @@ public: * @returns an id for the scheduled event. */ template - static EventId ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); + static EventId ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2); /** * @param time the relative expiration time of the event. @@ -83,7 +83,7 @@ public: */ template - static EventId ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); + static EventId ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); /** * @param time the relative expiration time of the event. @@ -97,7 +97,7 @@ public: */ template - static EventId ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); + static EventId ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); /** * @param time the relative expiration time of the event. @@ -112,14 +112,14 @@ public: */ template - static EventId ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, + static EventId ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); /** * @param time the relative expiration time of the event. * @param f the function to invoke * @returns an id for the scheduled event. */ - static EventId ScheduleReal (Time const &time, void (*f) (void)); + static EventId ScheduleRealtime (Time const &time, void (*f) (void)); /** * @param time the relative expiration time of the event. @@ -128,7 +128,7 @@ public: * @returns an id for the scheduled event. */ template - static EventId ScheduleReal (Time const &time, void (*f) (U1), T1 a1); + static EventId ScheduleRealtime (Time const &time, void (*f) (U1), T1 a1); /** * @param time the relative expiration time of the event. @@ -138,7 +138,7 @@ public: * @returns an id for the scheduled event. */ template - static EventId ScheduleReal (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2); + static EventId ScheduleRealtime (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2); /** * @param time the relative expiration time of the event. @@ -149,7 +149,7 @@ public: * @returns an id for the scheduled event. */ template - static EventId ScheduleReal (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); + static EventId ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); /** * @param time the relative expiration time of the event. @@ -162,7 +162,7 @@ public: */ template - static EventId ScheduleReal (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); + static EventId ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); /** * @param time the relative expiration time of the event. @@ -176,7 +176,7 @@ public: */ template - static EventId ScheduleReal (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + static EventId ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); /** * Schedule an event to expire Now. All events scheduled to @@ -187,7 +187,7 @@ public: * @param obj the object on which to invoke the member method */ template - static EventId ScheduleRealNow (MEM mem_ptr, OBJ obj); + static EventId ScheduleRealtimeNow (MEM mem_ptr, OBJ obj); /** * @param mem_ptr member method pointer to invoke @@ -196,7 +196,7 @@ public: */ template - static EventId ScheduleRealNow (MEM mem_ptr, OBJ obj, T1 a1); + static EventId ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1); /** * @param mem_ptr member method pointer to invoke @@ -206,7 +206,7 @@ public: */ template - static EventId ScheduleRealNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); + static EventId ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2); /** * @param mem_ptr member method pointer to invoke @@ -217,7 +217,7 @@ public: */ template - static EventId ScheduleRealNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); + static EventId ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3); /** * @param mem_ptr member method pointer to invoke @@ -229,7 +229,7 @@ public: */ template - static EventId ScheduleRealNow (MEM mem_ptr, OBJ obj, + static EventId ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4); /** * @param mem_ptr member method pointer to invoke @@ -242,12 +242,12 @@ public: */ template - static EventId ScheduleRealNow (MEM mem_ptr, OBJ obj, + static EventId ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); /** * @param f the function to invoke */ - static EventId ScheduleRealNow (void (*f) (void)); + static EventId ScheduleRealtimeNow (void (*f) (void)); /** * @param f the function to invoke @@ -255,7 +255,7 @@ public: */ template - static EventId ScheduleRealNow (void (*f) (U1), T1 a1); + static EventId ScheduleRealtimeNow (void (*f) (U1), T1 a1); /** * @param f the function to invoke @@ -264,7 +264,7 @@ public: */ template - static EventId ScheduleRealNow (void (*f) (U1,U2), T1 a1, T2 a2); + static EventId ScheduleRealtimeNow (void (*f) (U1,U2), T1 a1, T2 a2); /** * @param f the function to invoke @@ -274,7 +274,7 @@ public: */ template - static EventId ScheduleRealNow (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); + static EventId ScheduleRealtimeNow (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3); /** * @param f the function to invoke @@ -285,7 +285,7 @@ public: */ template - static EventId ScheduleRealNow (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); + static EventId ScheduleRealtimeNow (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4); /** * @param f the function to invoke @@ -297,12 +297,12 @@ public: */ template - static EventId ScheduleRealNow (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); + static EventId ScheduleRealtimeNow (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); /** * Return the "current normalized real-time". */ - static Time RealNow (void); + static Time RealtimeNow (void); /** * \param time delay until the event expires @@ -312,7 +312,7 @@ public: * This method will be typically used by language bindings * to delegate events to their own subclass of the EventImpl base class. */ - static EventId ScheduleReal (Time const &time, const Ptr &event); + static EventId ScheduleRealtime (Time const &time, const Ptr &event); /** * \param event the event to schedule @@ -321,176 +321,176 @@ public: * This method will be typically used by language bindings * to delegate events to their own subclass of the EventImpl base class. */ - static EventId ScheduleRealNow (const Ptr &event); + static EventId ScheduleRealtimeNow (const Ptr &event); private: - RealtimeSimulatorExtension (); - ~RealtimeSimulatorExtension (); + RealtimeSimulator (); + ~RealtimeSimulator (); static RealtimeSimulatorImpl *GetRealtimeImpl (void); }; template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj) { - return ScheduleReal (time, Simulator::MakeEvent (mem_ptr, obj)); + return ScheduleRealtime (time, Simulator::MakeEvent (mem_ptr, obj)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, T1 a1) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1) { - return ScheduleReal (time, Simulator::MakeEvent (mem_ptr, obj, a1)); + return ScheduleRealtime (time, Simulator::MakeEvent (mem_ptr, obj, a1)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2) { - return ScheduleReal (time, Simulator::MakeEvent (mem_ptr, obj, a1, a2)); + return ScheduleRealtime (time, Simulator::MakeEvent (mem_ptr, obj, a1, a2)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) { - return ScheduleReal (time, Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3)); + return ScheduleRealtime (time, Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) { - return ScheduleReal (time, Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); + return ScheduleRealtime (time, Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, MEM mem_ptr, OBJ obj, +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { - return ScheduleReal (time, Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); + return ScheduleRealtime (time, Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, void (*f) (U1), T1 a1) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, void (*f) (U1), T1 a1) { - return ScheduleReal (time, Simulator::MakeEvent (f, a1)); + return ScheduleRealtime (time, Simulator::MakeEvent (f, a1)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, void (*f) (U1,U2), T1 a1, T2 a2) { - return ScheduleReal (time, Simulator::MakeEvent (f, a1, a2)); + return ScheduleRealtime (time, Simulator::MakeEvent (f, a1, a2)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) { - return ScheduleReal (time, Simulator::MakeEvent (f, a1, a2, a3)); + return ScheduleRealtime (time, Simulator::MakeEvent (f, a1, a2, a3)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) { - return ScheduleReal (time, Simulator::MakeEvent (f, a1, a2, a3, a4)); + return ScheduleRealtime (time, Simulator::MakeEvent (f, a1, a2, a3, a4)); } template -EventId RealtimeSimulatorExtension::ScheduleReal (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +EventId RealtimeSimulator::ScheduleRealtime (Time const &time, void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { - return ScheduleReal (time, Simulator::MakeEvent (f, a1, a2, a3, a4, a5)); + return ScheduleRealtime (time, Simulator::MakeEvent (f, a1, a2, a3, a4, a5)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (MEM mem_ptr, OBJ obj) +RealtimeSimulator::ScheduleRealtimeNow (MEM mem_ptr, OBJ obj) { - return ScheduleRealNow (Simulator::MakeEvent (mem_ptr, obj)); + return ScheduleRealtimeNow (Simulator::MakeEvent (mem_ptr, obj)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (MEM mem_ptr, OBJ obj, T1 a1) +RealtimeSimulator::ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1) { - return ScheduleRealNow (Simulator::MakeEvent (mem_ptr, obj, a1)); + return ScheduleRealtimeNow (Simulator::MakeEvent (mem_ptr, obj, a1)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) +RealtimeSimulator::ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2) { - return ScheduleRealNow (Simulator::MakeEvent (mem_ptr, obj, a1, a2)); + return ScheduleRealtimeNow (Simulator::MakeEvent (mem_ptr, obj, a1, a2)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) +RealtimeSimulator::ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) { - return ScheduleRealNow (Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3)); + return ScheduleRealtimeNow (Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) +RealtimeSimulator::ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4) { - return ScheduleRealNow (Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); + return ScheduleRealtimeNow (Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3, a4)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (MEM mem_ptr, OBJ obj, +RealtimeSimulator::ScheduleRealtimeNow (MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { - return ScheduleRealNow (Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); + return ScheduleRealtimeNow (Simulator::MakeEvent (mem_ptr, obj, a1, a2, a3, a4, a5)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (void (*f) (U1), T1 a1) +RealtimeSimulator::ScheduleRealtimeNow (void (*f) (U1), T1 a1) { - return ScheduleRealNow (Simulator::MakeEvent (f, a1)); + return ScheduleRealtimeNow (Simulator::MakeEvent (f, a1)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (void (*f) (U1,U2), T1 a1, T2 a2) +RealtimeSimulator::ScheduleRealtimeNow (void (*f) (U1,U2), T1 a1, T2 a2) { - return ScheduleRealNow (Simulator::MakeEvent (f, a1, a2)); + return ScheduleRealtimeNow (Simulator::MakeEvent (f, a1, a2)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) +RealtimeSimulator::ScheduleRealtimeNow (void (*f) (U1,U2,U3), T1 a1, T2 a2, T3 a3) { - return ScheduleRealNow (Simulator::MakeEvent (f, a1, a2, a3)); + return ScheduleRealtimeNow (Simulator::MakeEvent (f, a1, a2, a3)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) +RealtimeSimulator::ScheduleRealtimeNow (void (*f) (U1,U2,U3,U4), T1 a1, T2 a2, T3 a3, T4 a4) { - return ScheduleRealNow (Simulator::MakeEvent (f, a1, a2, a3, a4)); + return ScheduleRealtimeNow (Simulator::MakeEvent (f, a1, a2, a3, a4)); } template EventId -RealtimeSimulatorExtension::ScheduleRealNow (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +RealtimeSimulator::ScheduleRealtimeNow (void (*f) (U1,U2,U3,U4,U5), T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { - return ScheduleRealNow (Simulator::MakeEvent (f, a1, a2, a3, a4, a5)); + return ScheduleRealtimeNow (Simulator::MakeEvent (f, a1, a2, a3, a4, a5)); } }; // namespace ns3 diff --git a/src/simulator/simulator.cc b/src/simulator/simulator.cc index 6581a8d0a..ddfe84cee 100644 --- a/src/simulator/simulator.cc +++ b/src/simulator/simulator.cc @@ -19,8 +19,10 @@ */ #include "simulator.h" +#include "realtime-simulator.h" #include "simulator-impl.h" #include "default-simulator-impl.h" +#include "realtime-simulator-impl.h" #include "scheduler.h" #include "map-scheduler.h" #include "event-impl.h" @@ -288,6 +290,49 @@ Simulator::SetImplementation (Ptr impl) NS_FATAL_ERROR ("TODO"); } +RealtimeSimulatorImpl * +RealtimeSimulator::GetRealtimeImpl (void) +{ + RealtimeSimulatorImpl *impl = dynamic_cast(Simulator::GetImpl ()); + NS_ASSERT_MSG (impl, + "RealtimeSimulator::GetImpl (): Underlying simulator implementation not realtime"); + return impl; +} + +Time +RealtimeSimulator::RealtimeNow (void) +{ + return GetRealtimeImpl ()->RealtimeNow (); +} + +EventId +RealtimeSimulator::ScheduleRealtime (Time const &time, const Ptr &ev) +{ + NS_LOG_FUNCTION (time << ev); + return GetRealtimeImpl ()->ScheduleRealtime (time, ev); +} + +EventId +RealtimeSimulator::ScheduleRealtimeNow (const Ptr &ev) +{ + NS_LOG_FUNCTION (ev); + return GetRealtimeImpl ()->ScheduleRealtimeNow (ev); +} + +EventId +RealtimeSimulator::ScheduleRealtime (Time const &time, void (*f) (void)) +{ + NS_LOG_FUNCTION (time << f); + return ScheduleRealtime (time, Simulator::MakeEvent (f)); +} + +EventId +RealtimeSimulator::ScheduleRealtimeNow (void (*f) (void)) +{ + NS_LOG_FUNCTION (f); + return ScheduleRealtimeNow (Simulator::MakeEvent (f)); +} + } // namespace ns3 diff --git a/src/simulator/simulator.h b/src/simulator/simulator.h index e44c23bf9..7363e8bb0 100644 --- a/src/simulator/simulator.h +++ b/src/simulator/simulator.h @@ -56,7 +56,7 @@ class SimulatorImpl; */ class Simulator { - friend class RealtimeSimulatorExtension; + friend class RealtimeSimulator; public: /** diff --git a/src/simulator/wscript b/src/simulator/wscript index fa3f417d8..d737dc290 100644 --- a/src/simulator/wscript +++ b/src/simulator/wscript @@ -61,7 +61,6 @@ def build(bld): 'heap-scheduler.cc', 'event-impl.cc', 'simulator.cc', - 'realtime-simulator.cc', 'default-simulator-impl.cc', 'timer.cc', 'watchdog.cc',