diff --git a/examples/simple-p2p.cc b/examples/simple-p2p.cc index 1f7eede0a..b3a3e3d0f 100644 --- a/examples/simple-p2p.cc +++ b/examples/simple-p2p.cc @@ -103,10 +103,10 @@ int main (int argc, char *argv[]) // Here, we will explicitly create four nodes. In more sophisticated // topologies, we could configure a node factory. - Ptr n0 = MakeNewObject (); - Ptr n1 = MakeNewObject (); - Ptr n2 = MakeNewObject (); - Ptr n3 = MakeNewObject (); + Ptr n0 = Create (); + Ptr n1 = Create (); + Ptr n2 = Create (); + Ptr n3 = Create (); // We create the channels first without any IP addressing information Ptr channel0 = @@ -145,7 +145,7 @@ int main (int argc, char *argv[]) // Create the OnOff application to send UDP datagrams of size // 210 bytes at a rate of 448 Kb/s - Ptr ooff = MakeNewObject ( + Ptr ooff = Create ( n0, Ipv4Address("10.1.3.2"), 80, @@ -157,7 +157,7 @@ int main (int argc, char *argv[]) ooff->Stop (Seconds(10.0)); // Create a similar flow from n3 to n1, starting at time 1.1 seconds - ooff = MakeNewObject ( + ooff = Create ( n3, Ipv4Address("10.1.2.1"), 80, diff --git a/samples/main-object.cc b/samples/main-object.cc index 2382fab58..46bd58272 100644 --- a/samples/main-object.cc +++ b/samples/main-object.cc @@ -68,7 +68,7 @@ YetAnotherObject::YetAnotherObject (int a) // enable our interface SetInterfaceId (YetAnotherObject::iid); // aggregated directly to another object. - AddInterface (MakeNewObject ()); + AddInterface (Create ()); } void YetAnotherObject::DoDispose (void) @@ -87,7 +87,7 @@ int main (int argc, char *argv[]) Ptr anotherObject; Ptr yetAnotherObject; - p = MakeNewObject (); + p = Create (); // p gives you access to AnObject's interface anObject = p->QueryInterface (AnObject::iid); NS_ASSERT (anObject != 0); @@ -95,7 +95,7 @@ int main (int argc, char *argv[]) anotherObject = p->QueryInterface (AnotherObject::iid); NS_ASSERT (anotherObject == 0); - anotherObject = MakeNewObject (1); + anotherObject = Create (1); // AnotherObject does not give you access to AnObject's interface anObject = anotherObject->QueryInterface (AnObject::iid); NS_ASSERT (anObject == 0); @@ -110,7 +110,7 @@ int main (int argc, char *argv[]) NS_ASSERT (anotherObject != 0); - yetAnotherObject = MakeNewObject (2); + yetAnotherObject = Create (2); // gives you acess to AnObject interface too. anObject = yetAnotherObject->QueryInterface (AnObject::iid); NS_ASSERT (anObject != 0); diff --git a/samples/main-ptr.cc b/samples/main-ptr.cc index 67f20df04..b3102338d 100644 --- a/samples/main-ptr.cc +++ b/samples/main-ptr.cc @@ -49,7 +49,7 @@ int main (int argc, char *argv[]) { // Create a new object of type A, store it in global // variable g_a - Ptr a = MakeNewObject (); + Ptr a = Create (); a->Method (); Ptr prev = StoreA (a); NS_ASSERT (prev == 0); @@ -58,7 +58,7 @@ int main (int argc, char *argv[]) { // Create a new object of type A, store it in global // variable g_a, get a hold on the previous A object. - Ptr a = MakeNewObject (); + Ptr a = Create (); Ptr prev = StoreA (a); // call method on object prev->Method (); diff --git a/samples/main-simple.cc b/samples/main-simple.cc index 64ef5307e..4d4eb89d8 100644 --- a/samples/main-simple.cc +++ b/samples/main-simple.cc @@ -38,7 +38,7 @@ PrintTraffic (Ptr socket) void RunSimulation (void) { - Ptr a = MakeNewObject (); + Ptr a = Create (); InterfaceId iid = InterfaceId::LookupByName ("IUdp"); Ptr socketFactory = a->QueryInterface (iid); diff --git a/src/core/callback.h b/src/core/callback.h index 000346985..6acdd81a7 100644 --- a/src/core/callback.h +++ b/src/core/callback.h @@ -266,12 +266,12 @@ public: // always properly disambiguited by the c++ compiler template Callback (FUNCTOR const &functor, bool, bool) - : m_impl (MakeNewObject > (functor)) + : m_impl (Create > (functor)) {} template Callback (OBJ_PTR const &objPtr, MEM_PTR mem_ptr) - : m_impl (MakeNewObject > (objPtr, mem_ptr)) + : m_impl (Create > (objPtr, mem_ptr)) {} Callback (Ptr > const &impl) @@ -627,33 +627,33 @@ private: template Callback MakeBoundCallback (R (*fnPtr) (TX), TX a) { Ptr > impl = - MakeNewObject >(fnPtr, a); + Create >(fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr) (TX,T1), TX a) { Ptr > impl = - MakeNewObject > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr) (TX,T1,T2), TX a) { Ptr > impl = - MakeNewObject > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr) (TX,T1,T2,T3,T4), TX a) { Ptr > impl = - MakeNewObject > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr) (TX,T1,T2,T3,T4,T5), TX a) { Ptr > impl = - MakeNewObject > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } diff --git a/src/core/component-manager.cc b/src/core/component-manager.cc index f6ee14d4d..ec78d708d 100644 --- a/src/core/component-manager.cc +++ b/src/core/component-manager.cc @@ -278,7 +278,7 @@ A::A () m_oneUi32Invoked (false) { SetInterfaceId (A::iid); - ns3::Ptr b = ns3::MakeNewObject (); + ns3::Ptr b = ns3::Create (); AddInterface (b); } @@ -289,7 +289,7 @@ A::A (bool bo) m_bool (bo) { SetInterfaceId (A::iid); - ns3::Ptr b = ns3::MakeNewObject (); + ns3::Ptr b = ns3::Create (); AddInterface (b); } @@ -300,7 +300,7 @@ A::A (uint32_t i) m_ui32 (i) { SetInterfaceId (A::iid); - ns3::Ptr b = ns3::MakeNewObject (); + ns3::Ptr b = ns3::Create (); AddInterface (b); } diff --git a/src/core/component-manager.h b/src/core/component-manager.h index 0b0d05195..ccecc4b15 100644 --- a/src/core/component-manager.h +++ b/src/core/component-manager.h @@ -429,7 +429,7 @@ template struct ObjectMaker { static ns3::Ptr MakeObject (void) { - return ns3::MakeNewObject (); + return ns3::Create (); } }; @@ -437,7 +437,7 @@ template struct ObjectMaker { static ns3::Ptr MakeObject (T1 a1) { - return ns3::MakeNewObject (a1); + return ns3::Create (a1); } }; @@ -445,7 +445,7 @@ template struct ObjectMaker { static ns3::Ptr MakeObject (T1 a1, T2 a2) { - return ns3::MakeNewObject (a1, a2); + return ns3::Create (a1, a2); } }; @@ -453,7 +453,7 @@ template struct ObjectMaker { static ns3::Ptr MakeObject (T1 a1, T2 a2, T3 a3) { - return ns3::MakeNewObject (a1, a2, a3); + return ns3::Create (a1, a2, a3); } }; @@ -462,7 +462,7 @@ template { static ns3::Ptr MakeObject (T1 a1, T2 a2, T3 a3, T4 a4) { - return ns3::MakeNewObject (a1, a2, a3, a4); + return ns3::Create (a1, a2, a3, a4); } }; @@ -471,7 +471,7 @@ template MakeObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { - return ns3::MakeNewObject (a1, a2, a3, a4, a5); + return ns3::Create (a1, a2, a3, a4, a5); } }; diff --git a/src/core/object.cc b/src/core/object.cc index 96c480e49..9b4812c42 100644 --- a/src/core/object.cc +++ b/src/core/object.cc @@ -295,7 +295,7 @@ ObjectTest::RunTests (void) { bool ok = true; - Ptr baseA = MakeNewObject (); + Ptr baseA = Create (); if (baseA->QueryInterface (BaseA::iid) != baseA) { ok = false; @@ -308,7 +308,7 @@ ObjectTest::RunTests (void) { ok = false; } - baseA = MakeNewObject (10); + baseA = Create (10); if (baseA->QueryInterface (BaseA::iid) != baseA) { ok = false; @@ -322,8 +322,8 @@ ObjectTest::RunTests (void) ok = false; } - baseA = MakeNewObject (); - Ptr baseB = MakeNewObject (); + baseA = Create (); + Ptr baseB = Create (); Ptr baseBCopy = baseB; baseA->AddInterface (baseB); if (baseA->QueryInterface (BaseA::iid) == 0) @@ -363,8 +363,8 @@ ObjectTest::RunTests (void) ok = false; } - baseA = MakeNewObject (1); - baseB = MakeNewObject (1); + baseA = Create (1); + baseB = Create (1); baseBCopy = baseB; baseA->AddInterface (baseB); if (baseA->QueryInterface (DerivedB::iid) == 0) @@ -400,8 +400,8 @@ ObjectTest::RunTests (void) ok = false; } - baseA = MakeNewObject (); - baseB = MakeNewObject (); + baseA = Create (); + baseB = Create (); baseA->AddInterface (baseB); baseA = 0; baseA = baseB->QueryInterface (BaseA::iid); diff --git a/src/core/ptr.cc b/src/core/ptr.cc index 275a11324..10e63c606 100644 --- a/src/core/ptr.cc +++ b/src/core/ptr.cc @@ -93,7 +93,7 @@ PtrTest::RunTests (void) Callback cb = MakeCallback (&PtrTest::DestroyNotify, this); m_nDestroyed = false; { - Ptr p = MakeNewObject (cb); + Ptr p = Create (cb); } if (m_nDestroyed != 1) { @@ -103,7 +103,7 @@ PtrTest::RunTests (void) m_nDestroyed = 0; { Ptr p; - p = MakeNewObject (cb); + p = Create (cb); p = p; } if (m_nDestroyed != 1) @@ -114,7 +114,7 @@ PtrTest::RunTests (void) m_nDestroyed = 0; { Ptr p1; - p1 = MakeNewObject (cb); + p1 = Create (cb); Ptr p2 = p1; } if (m_nDestroyed != 1) @@ -125,7 +125,7 @@ PtrTest::RunTests (void) m_nDestroyed = 0; { Ptr p1; - p1 = MakeNewObject (cb); + p1 = Create (cb); Ptr p2; p2 = p1; } @@ -137,8 +137,8 @@ PtrTest::RunTests (void) m_nDestroyed = 0; { Ptr p1; - p1 = MakeNewObject (cb); - Ptr p2 = MakeNewObject (cb); + p1 = Create (cb); + Ptr p2 = Create (cb); p2 = p1; } if (m_nDestroyed != 2) @@ -149,9 +149,9 @@ PtrTest::RunTests (void) m_nDestroyed = 0; { Ptr p1; - p1 = MakeNewObject (cb); + p1 = Create (cb); Ptr p2; - p2 = MakeNewObject (cb); + p2 = Create (cb); p2 = p1; } if (m_nDestroyed != 2) @@ -162,8 +162,8 @@ PtrTest::RunTests (void) m_nDestroyed = 0; { Ptr p1; - p1 = MakeNewObject (cb); - p1 = MakeNewObject (cb); + p1 = Create (cb); + p1 = Create (cb); } if (m_nDestroyed != 2) { @@ -175,8 +175,8 @@ PtrTest::RunTests (void) Ptr p1; { Ptr p2; - p1 = MakeNewObject (cb); - p2 = MakeNewObject (cb); + p1 = Create (cb); + p2 = Create (cb); p2 = p1; } if (m_nDestroyed != 1) @@ -194,8 +194,8 @@ PtrTest::RunTests (void) Ptr p1; { Ptr p2; - p1 = MakeNewObject (cb); - p2 = MakeNewObject (cb); + p1 = Create (cb); + p2 = Create (cb); p2 = CallTest (p1); } if (m_nDestroyed != 1) @@ -237,7 +237,7 @@ PtrTest::RunTests (void) { NoCount *raw; { - Ptr p = MakeNewObject (cb); + Ptr p = Create (cb); { Ptr p1 = p; } @@ -254,7 +254,7 @@ PtrTest::RunTests (void) m_nDestroyed = 0; { - Ptr p = MakeNewObject (cb); + Ptr p = Create (cb); const NoCount *v1 = PeekPointer (p); NoCount *v2 = PeekPointer (p); v1->Nothing (); @@ -266,8 +266,8 @@ PtrTest::RunTests (void) } { - Ptr p0 = MakeNewObject (cb); - Ptr p1 = MakeNewObject (cb); + Ptr p0 = Create (cb); + Ptr p1 = Create (cb); if (p0 == p1) { ok = false; @@ -282,12 +282,12 @@ PtrTest::RunTests (void) } { - Ptr p = MakeNewObject (cb); + Ptr p = Create (cb); Callback callback = MakeCallback (&NoCount::Nothing, p); callback (); } { - Ptr p = MakeNewObject (cb); + Ptr p = Create (cb); Callback callback = MakeCallback (&NoCount::Nothing, p); callback (); } @@ -295,7 +295,7 @@ PtrTest::RunTests (void) #if 0 // as expected, fails compilation. { - Ptr p = MakeNewObject (cb); + Ptr p = Create (cb); Callback callback = MakeCallback (&NoCount::Nothing, p); } #endif diff --git a/src/core/ptr.h b/src/core/ptr.h index 5b4ae1538..dd664be86 100644 --- a/src/core/ptr.h +++ b/src/core/ptr.h @@ -43,7 +43,7 @@ namespace ns3 { * smart pointer with the GetPointer and PeekPointer methods. * * If you want to store a newed object into a smart pointer, - * we recommend you to use the MakeNewObject template functions + * we recommend you to use the Create template functions * to create the object and store it in a smart pointer to avoid * memory leaks. These functions are really small conveniance * functions and their goal is just is save you a small @@ -98,28 +98,28 @@ public: }; template -Ptr MakeNewObject (void); +Ptr Create (void); template -Ptr MakeNewObject (T1 a1); +Ptr Create (T1 a1); template -Ptr MakeNewObject (T1 a1, T2 a2); +Ptr Create (T1 a1, T2 a2); template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3); +Ptr Create (T1 a1, T2 a2, T3 a3); template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4); +Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4); template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); +Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5); template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); +Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6); template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7); +Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7); /** * \relates Ptr @@ -206,7 +206,7 @@ namespace ns3 { ************************************************/ template -Ptr MakeNewObject (void) +Ptr Create (void) { T *obj = new T (); Ptr p = obj; @@ -215,7 +215,7 @@ Ptr MakeNewObject (void) } template -Ptr MakeNewObject (T1 a1) +Ptr Create (T1 a1) { T *obj = new T (a1); Ptr p = obj; @@ -224,7 +224,7 @@ Ptr MakeNewObject (T1 a1) } template -Ptr MakeNewObject (T1 a1, T2 a2) +Ptr Create (T1 a1, T2 a2) { T *obj = new T (a1, a2); Ptr p = obj; @@ -233,7 +233,7 @@ Ptr MakeNewObject (T1 a1, T2 a2) } template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3) +Ptr Create (T1 a1, T2 a2, T3 a3) { T *obj = new T (a1, a2, a3); Ptr p = obj; @@ -242,7 +242,7 @@ Ptr MakeNewObject (T1 a1, T2 a2, T3 a3) } template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4) +Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4) { T *obj = new T (a1, a2, a3, a4); Ptr p = obj; @@ -251,7 +251,7 @@ Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4) } template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) +Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) { T *obj = new T (a1, a2, a3, a4, a5); Ptr p = obj; @@ -260,7 +260,7 @@ Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5) } template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) +Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) { T *obj = new T (a1, a2, a3, a4, a5, a6); Ptr p = obj; @@ -269,7 +269,7 @@ Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6) } template -Ptr MakeNewObject (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) +Ptr Create (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6, T7 a7) { T *obj = new T (a1, a2, a3, a4, a5, a6, a7); Ptr p = obj; diff --git a/src/devices/p2p/p2p-topology.cc b/src/devices/p2p/p2p-topology.cc index 7f9db4660..d15410aa3 100644 --- a/src/devices/p2p/p2p-topology.cc +++ b/src/devices/p2p/p2p-topology.cc @@ -45,15 +45,15 @@ PointToPointTopology::AddPointToPointLink( const DataRate& bps, const Time& delay) { - Ptr channel = MakeNewObject (bps, delay); + Ptr channel = Create (bps, delay); - Ptr net1 = MakeNewObject (n1); + Ptr net1 = Create (n1); Ptr q = Queue::CreateDefault (); net1->AddQueue(q); net1->Attach (channel); - Ptr net2 = MakeNewObject (n2); + Ptr net2 = Create (n2); q = Queue::CreateDefault (); net2->AddQueue(q); diff --git a/src/internet-node/internet-node.cc b/src/internet-node/internet-node.cc index 6bcb56772..0432b30a0 100644 --- a/src/internet-node/internet-node.cc +++ b/src/internet-node/internet-node.cc @@ -54,21 +54,21 @@ InternetNode::~InternetNode () void InternetNode::Construct (void) { - Ptr ipv4 = MakeNewObject (this); - Ptr arp = MakeNewObject (this); - Ptr udp = MakeNewObject (this); + Ptr ipv4 = Create (this); + Ptr arp = Create (this); + Ptr udp = Create (this); - Ptr l3Demux = MakeNewObject (this); - Ptr ipv4L4Demux = MakeNewObject (this); + Ptr l3Demux = Create (this); + Ptr ipv4L4Demux = Create (this); l3Demux->Insert (ipv4); l3Demux->Insert (arp); ipv4L4Demux->Insert (udp); - Ptr udpImpl = MakeNewObject (udp); - Ptr arpPrivate = MakeNewObject (arp); - Ptr ipv4Impl = MakeNewObject (ipv4); - Ptr ipv4Private = MakeNewObject (ipv4); + Ptr udpImpl = Create (udp); + Ptr arpPrivate = Create (arp); + Ptr ipv4Impl = Create (ipv4); + Ptr ipv4Private = Create (ipv4); Object::AddInterface (ipv4Private); Object::AddInterface (ipv4Impl); diff --git a/src/internet-node/udp.cc b/src/internet-node/udp.cc index 8a0ffc55a..f68e3142a 100644 --- a/src/internet-node/udp.cc +++ b/src/internet-node/udp.cc @@ -68,7 +68,7 @@ Udp::DoDispose (void) Ptr Udp::CreateSocket (void) { - Ptr socket = MakeNewObject (m_node, this); + Ptr socket = Create (m_node, this); return socket; } diff --git a/utils/bench-object.cc b/utils/bench-object.cc index 2ca09455c..81d632dca 100644 --- a/utils/bench-object.cc +++ b/utils/bench-object.cc @@ -28,7 +28,7 @@ int main (int argc, char *argv[]) std::vector< Ptr > objlist; for (int i = 0; i < nobjects; ++i) - objlist.push_back (MakeNewObject ()); + objlist.push_back (Create ()); for (int swapCounter = nswaps; swapCounter; --swapCounter) {