merge in raj's dispose early work
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 02 May 2007 09:10:19 +0200
changeset 465 7f620ea278f4
parent 464 687e2b7b5f11
child 466 33710ab0ecf9
merge in raj's dispose early work
src/devices/p2p/p2p-net-device.cc
src/devices/p2p/p2p-net-device.h
src/node/internet-node.cc
src/node/internet-node.h
src/node/net-device.cc
src/node/net-device.h
src/node/node.cc
src/node/node.h
--- a/src/devices/p2p/p2p-net-device.cc	Tue May 01 11:58:19 2007 +0200
+++ b/src/devices/p2p/p2p-net-device.cc	Wed May 02 09:10:19 2007 +0200
@@ -106,6 +106,16 @@
     
 }
 
+void PointToPointNetDevice::Dispose()
+{
+ if (m_channel != 0)
+ {
+   m_channel->Unref ();
+   m_channel = 0;
+ }
+ NetDevice::Dispose ();
+}
+
 //
 // Assignment operator for PointToPointNetDevice.
 //
@@ -357,6 +367,7 @@
 Channel* 
 PointToPointNetDevice::DoGetChannel(void) const 
 { 
+    m_channel->Ref();
     return m_channel;
 }
 
--- a/src/devices/p2p/p2p-net-device.h	Tue May 01 11:58:19 2007 +0200
+++ b/src/devices/p2p/p2p-net-device.h	Wed May 02 09:10:19 2007 +0200
@@ -97,6 +97,10 @@
    */
   virtual ~PointToPointNetDevice();
   /**
+   *Dispose method for refcounting
+   */
+  virtual void Dispose();
+  /**
    * Assignment Operator for a PointToPointNetDevice
    *
    * This is the assignment operator for the PointToPointNetDevice.  This is
--- a/src/node/internet-node.cc	Tue May 01 11:58:19 2007 +0200
+++ b/src/node/internet-node.cc	Wed May 02 09:10:19 2007 +0200
@@ -106,6 +106,12 @@
   return resolver;
 }
 
+void InternetNode::Dispose()
+{
+  for(uint32_t i=0;i<GetNDevices();++i)
+    GetDevice(i)->Dispose();
+  
+}
 
 ApplicationList* 
 InternetNode::GetApplicationList() const
--- a/src/node/internet-node.h	Tue May 01 11:58:19 2007 +0200
+++ b/src/node/internet-node.h	Wed May 02 09:10:19 2007 +0200
@@ -47,6 +47,7 @@
   virtual ~InternetNode ();
   virtual InternetNode* Copy() const;
   virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
+  virtual void Dispose();
   // Capability access
   virtual ApplicationList* GetApplicationList() const;
   virtual L3Demux*         GetL3Demux() const;
--- a/src/node/net-device.cc	Tue May 01 11:58:19 2007 +0200
+++ b/src/node/net-device.cc	Wed May 02 09:10:19 2007 +0200
@@ -25,6 +25,7 @@
 #include "net-device.h"
 #include "llc-snap-header.h"
 #include "node.h"
+#include "ns3/channel.h"
 
 namespace ns3 {
 
@@ -225,4 +226,9 @@
   m_receiveCallback = cb;
 }
 
+void
+NetDevice::Dispose()
+{
+}
+
 }; // namespace ns3
--- a/src/node/net-device.h	Tue May 01 11:58:19 2007 +0200
+++ b/src/node/net-device.h	Wed May 02 09:10:19 2007 +0200
@@ -155,6 +155,8 @@
   bool NeedsArp (void) const;
 
   void SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t> cb);
+  
+  virtual void Dispose();
 
  protected:
   /**
--- a/src/node/node.cc	Tue May 01 11:58:19 2007 +0200
+++ b/src/node/node.cc	Wed May 02 09:10:19 2007 +0200
@@ -87,6 +87,10 @@
   return m_devices.size ();
 }
 
+void Node::Dispose()
+{
+}
+
 // Node stack creation and management routines.
 Node* Node::Create()
 {
--- a/src/node/node.h	Tue May 01 11:58:19 2007 +0200
+++ b/src/node/node.h	Wed May 02 09:10:19 2007 +0200
@@ -122,6 +122,8 @@
   uint32_t AddDevice (NetDevice *device);
   NetDevice *GetDevice (uint32_t index) const;
   uint32_t GetNDevices (void) const;
+  
+  virtual void Dispose();
 
 private:
   virtual void DoAddDevice (NetDevice *device) const = 0;