make duplicate aggregations fail; avoid duplicate aggregations
authorCraig Dowell <craigdo@ee.washington.edu>
Thu, 10 Apr 2008 13:16:43 -0700
changeset 2902 9c2cfada5e72
parent 2901 81ac5e25e8c2
child 2903 ea31499ecbfb
make duplicate aggregations fail; avoid duplicate aggregations
examples/csma-broadcast.cc
examples/csma-multicast.cc
src/core/object.cc
--- a/examples/csma-broadcast.cc	Wed Apr 09 10:04:16 2008 -0700
+++ b/examples/csma-broadcast.cc	Thu Apr 10 13:16:43 2008 -0700
@@ -74,10 +74,8 @@
   NetDeviceContainer n0 = csma.Install (c0);
   NetDeviceContainer n1 = csma.Install (c1);
 
-
   InternetStackHelper internet;
-  internet.Install (c0);
-  internet.Install (c1);
+  internet.Install (c);
 
   NS_LOG_INFO ("Assign IP Addresses.");
   Ipv4AddressHelper ipv4;
--- a/examples/csma-multicast.cc	Wed Apr 09 10:04:16 2008 -0700
+++ b/examples/csma-multicast.cc	Thu Apr 10 13:16:43 2008 -0700
@@ -84,8 +84,7 @@
 
   NS_LOG_INFO ("Add IP Stack.");
   InternetStackHelper internet;
-  internet.Install (c0);
-  internet.Install (c1);
+  internet.Install (c);
 
   NS_LOG_INFO ("Assign IP Addresses.");
   Ipv4AddressHelper ipv4Addr;
--- a/src/core/object.cc	Wed Apr 09 10:04:16 2008 -0700
+++ b/src/core/object.cc	Thu Apr 10 13:16:43 2008 -0700
@@ -114,6 +114,13 @@
   NS_ASSERT (!o->m_disposed);
   NS_ASSERT (CheckLoose ());
   NS_ASSERT (o->CheckLoose ());
+
+  if (DoGetObject (o->m_tid))
+    {
+      NS_FATAL_ERROR ("Object::AggregateObject(): "
+       "Multiple aggregation of objects of type " << o->m_tid.GetName ());
+    }
+
   Object *other = PeekPointer (o);
   Object *next = m_next;
   m_next = other->m_next;