diff --git a/CHANGES.html b/CHANGES.html
index 7003d49c0..3d344a5da 100644
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -61,6 +61,28 @@ can be found
here.
+
+Changes from ns-3.6 to ns-3.7
+
+Changes to existing API:
+
+
Changes from ns-3.5 to ns-3.6
diff --git a/src/simulator/default-simulator-impl.cc b/src/simulator/default-simulator-impl.cc
index 394545651..39506737d 100644
--- a/src/simulator/default-simulator-impl.cc
+++ b/src/simulator/default-simulator-impl.cc
@@ -86,8 +86,10 @@ DefaultSimulatorImpl::Destroy ()
}
void
-DefaultSimulatorImpl::SetScheduler (Ptr scheduler)
+DefaultSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory)
{
+ Ptr scheduler = schedulerFactory.Create ();
+
if (m_events != 0)
{
while (!m_events->IsEmpty ())
diff --git a/src/simulator/default-simulator-impl.h b/src/simulator/default-simulator-impl.h
index 4811a57a1..c5156078b 100644
--- a/src/simulator/default-simulator-impl.h
+++ b/src/simulator/default-simulator-impl.h
@@ -56,7 +56,7 @@ public:
virtual Time Now (void) const;
virtual Time GetDelayLeft (const EventId &id) const;
virtual Time GetMaximumSimulationTime (void) const;
- virtual void SetScheduler (Ptr scheduler);
+ virtual void SetScheduler (ObjectFactory schedulerFactory);
private:
void ProcessOneEvent (void);
diff --git a/src/simulator/realtime-simulator-impl.cc b/src/simulator/realtime-simulator-impl.cc
index b096c99f0..ccbd2fa4f 100644
--- a/src/simulator/realtime-simulator-impl.cc
+++ b/src/simulator/realtime-simulator-impl.cc
@@ -122,10 +122,12 @@ RealtimeSimulatorImpl::Destroy ()
}
void
-RealtimeSimulatorImpl::SetScheduler (Ptr scheduler)
+RealtimeSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory)
{
NS_LOG_FUNCTION_NOARGS ();
+ Ptr scheduler = schedulerFactory.Create ();
+
{
CriticalSection cs (m_mutex);
diff --git a/src/simulator/realtime-simulator-impl.h b/src/simulator/realtime-simulator-impl.h
index 8a3becd57..832919af1 100644
--- a/src/simulator/realtime-simulator-impl.h
+++ b/src/simulator/realtime-simulator-impl.h
@@ -66,7 +66,7 @@ public:
virtual Time Now (void) const;
virtual Time GetDelayLeft (const EventId &id) const;
virtual Time GetMaximumSimulationTime (void) const;
- virtual void SetScheduler (Ptr scheduler);
+ virtual void SetScheduler (ObjectFactory schedulerFactory);
void ScheduleRealtime (Time const &time, EventImpl *event);
void ScheduleRealtimeNow (EventImpl *event);
diff --git a/src/simulator/simulator-impl.h b/src/simulator/simulator-impl.h
index 4479b23bb..166905a9d 100644
--- a/src/simulator/simulator-impl.h
+++ b/src/simulator/simulator-impl.h
@@ -25,6 +25,7 @@
#include "event-id.h"
#include "nstime.h"
#include "ns3/object.h"
+#include "ns3/object-factory.h"
#include "ns3/ptr.h"
namespace ns3 {
@@ -49,7 +50,7 @@ public:
virtual Time Now (void) const = 0;
virtual Time GetDelayLeft (const EventId &id) const = 0;
virtual Time GetMaximumSimulationTime (void) const = 0;
- virtual void SetScheduler (Ptr scheduler) = 0;
+ virtual void SetScheduler (ObjectFactory schedulerFactory) = 0;
};
} // namespace ns3
diff --git a/src/simulator/simulator.cc b/src/simulator/simulator.cc
index 5c9552d99..dda4f9d63 100644
--- a/src/simulator/simulator.cc
+++ b/src/simulator/simulator.cc
@@ -25,6 +25,7 @@
# include "realtime-simulator-impl.h"
#endif
#include "scheduler.h"
+#include "map-scheduler.h"
#include "event-impl.h"
#include "ns3/ptr.h"
@@ -51,8 +52,8 @@ GlobalValue g_simTypeImpl = GlobalValue ("SimulatorImplementationType",
GlobalValue g_schedTypeImpl = GlobalValue ("SchedulerType",
"The object class to use as the scheduler implementation",
- StringValue ("ns3::MapScheduler"),
- MakeStringChecker ());
+ TypeIdValue (MapScheduler::GetTypeId ()),
+ MakeTypeIdChecker ());
#ifdef NS3_LOG_ENABLE
@@ -97,7 +98,7 @@ static SimulatorImpl * GetImpl (void)
StringValue s;
g_schedTypeImpl.GetValue (s);
factory.SetTypeId (s.Get ());
- impl->SetScheduler (factory.Create ());
+ impl->SetScheduler (factory);
}
//
@@ -133,10 +134,10 @@ Simulator::Destroy (void)
}
void
-Simulator::SetScheduler (Ptr scheduler)
+Simulator::SetScheduler (ObjectFactory schedulerFactory)
{
- NS_LOG_FUNCTION (scheduler);
- GetImpl ()->SetScheduler (scheduler);
+ NS_LOG_FUNCTION (schedulerFactory);
+ GetImpl ()->SetScheduler (schedulerFactory);
}
bool
@@ -302,7 +303,7 @@ Simulator::SetImplementation (Ptr impl)
StringValue s;
g_schedTypeImpl.GetValue (s);
factory.SetTypeId (s.Get ());
- impl->SetScheduler (factory.Create ());
+ impl->SetScheduler (factory);
//
// Note: we call LogSetTimePrinter _after_ creating the implementation
// object because the act of creation can trigger calls to the logging
@@ -334,7 +335,7 @@ namespace ns3 {
class SimulatorEventsTestCase : public TestCase
{
public:
- SimulatorEventsTestCase (Ptr scheduler);
+ SimulatorEventsTestCase (ObjectFactory schedulerFactory);
virtual bool DoRun (void);
void A (int a);
void B (int b);
@@ -350,10 +351,13 @@ public:
EventId m_idC;
bool m_destroy;
EventId m_destroyId;
+ ObjectFactory m_schedulerFactory;
};
-SimulatorEventsTestCase::SimulatorEventsTestCase (Ptr scheduler)
- : TestCase ("Check that basic event handling is working with " + scheduler->GetInstanceTypeId ().GetName ())
+SimulatorEventsTestCase::SimulatorEventsTestCase (ObjectFactory schedulerFactory)
+ : TestCase ("Check that basic event handling is working with " +
+ schedulerFactory.GetTypeId ().GetName ()),
+ m_schedulerFactory (schedulerFactory)
{}
uint64_t
SimulatorEventsTestCase::NowUs (void)
@@ -422,6 +426,8 @@ SimulatorEventsTestCase::DoRun (void)
m_c = true;
m_d = false;
+ Simulator::SetScheduler (m_schedulerFactory);
+
EventId a = Simulator::Schedule (MicroSeconds (10), &SimulatorEventsTestCase::A, this, 1);
Simulator::Schedule (MicroSeconds (11), &SimulatorEventsTestCase::B, this, 2);
m_idC = Simulator::Schedule (MicroSeconds (12), &SimulatorEventsTestCase::C, this, 3);
@@ -767,11 +773,18 @@ public:
SimulatorTestSuite ()
: TestSuite ("simulator")
{
- AddTestCase (new SimulatorEventsTestCase (CreateObject ()));
- AddTestCase (new SimulatorEventsTestCase (CreateObject ()));
- AddTestCase (new SimulatorEventsTestCase (CreateObject ()));
- AddTestCase (new SimulatorEventsTestCase (CreateObject ()));
- AddTestCase (new SimulatorEventsTestCase (CreateObject ()));
+ ObjectFactory factory;
+ factory.SetTypeId (ListScheduler::GetTypeId ());
+
+ AddTestCase (new SimulatorEventsTestCase (factory));
+ factory.SetTypeId (MapScheduler::GetTypeId ());
+ AddTestCase (new SimulatorEventsTestCase (factory));
+ factory.SetTypeId (HeapScheduler::GetTypeId ());
+ AddTestCase (new SimulatorEventsTestCase (factory));
+ factory.SetTypeId (CalendarScheduler::GetTypeId ());
+ AddTestCase (new SimulatorEventsTestCase (factory));
+ factory.SetTypeId (Ns2CalendarScheduler::GetTypeId ());
+ AddTestCase (new SimulatorEventsTestCase (factory));
}
} g_simulatorTestSuite;
diff --git a/src/simulator/simulator.h b/src/simulator/simulator.h
index 477a55be8..ec02182fa 100644
--- a/src/simulator/simulator.h
+++ b/src/simulator/simulator.h
@@ -27,6 +27,7 @@
#include "nstime.h"
#include "ns3/deprecated.h"
+#include "ns3/object-factory.h"
#include
#include
@@ -80,7 +81,7 @@ public:
* in the previous scheduler will be transfered to the new scheduler
* before we start to use it.
*/
- static void SetScheduler (Ptr scheduler);
+ static void SetScheduler (ObjectFactory schedulerFactory);
/**
* Every event scheduled by the Simulator::insertAtDestroy method is
diff --git a/utils/bench-simulator.cc b/utils/bench-simulator.cc
index 8a3011ec1..c06ddbae1 100644
--- a/utils/bench-simulator.cc
+++ b/utils/bench-simulator.cc
@@ -162,21 +162,26 @@ int main (int argc, char *argv[])
}
while (argc > 0)
{
+ ObjectFactory factory;
if (strcmp ("--list", argv[0]) == 0)
{
- Simulator::SetScheduler (CreateObject ());
+ factory.SetTypeId ("ns3::ListScheduler");
+ Simulator::SetScheduler (factory);
}
else if (strcmp ("--heap", argv[0]) == 0)
{
- Simulator::SetScheduler (CreateObject ());
+ factory.SetTypeId ("ns3::HeapScheduler");
+ Simulator::SetScheduler (factory);
}
else if (strcmp ("--map", argv[0]) == 0)
{
- Simulator::SetScheduler (CreateObject ());
+ factory.SetTypeId ("ns3::HeapScheduler");
+ Simulator::SetScheduler (factory);
}
else if (strcmp ("--calendar", argv[0]) == 0)
{
- Simulator::SetScheduler (CreateObject ());
+ factory.SetTypeId ("ns3::CalendarScheduler");
+ Simulator::SetScheduler (factory);
}
else if (strcmp ("--debug", argv[0]) == 0)
{