disable copy constructor and operator = for CsmaCdNetDevice
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 28 Jul 2007 12:30:31 +0200
changeset 992 37953a86a975
parent 991 e05514a93564
child 993 9f9d5048b710
disable copy constructor and operator = for CsmaCdNetDevice
src/devices/csma-cd/csma-cd-net-device.cc
src/devices/csma-cd/csma-cd-net-device.h
--- a/src/devices/csma-cd/csma-cd-net-device.cc	Fri Jul 27 14:54:41 2007 -0700
+++ b/src/devices/csma-cd/csma-cd-net-device.cc	Sat Jul 28 12:30:31 2007 +0200
@@ -62,43 +62,6 @@
   m_queue = 0;
 }
 
-//
-// Copy constructor for CsmaCdNetDevice.
-//
-// We use the underlying NetDevice copy constructor to get the base class
-// copied.  These just remain as is (e.g. you get the same name, the same
-// MAC address).  If you need to fix them up, YOU, the copier need to do 
-// that.
-// 
-// The things we need to be careful of are the channel, the queue and the
-// trace callback.  If the channel pointer is non-zero, we copy the pointer 
-// and add a reference.  If the queue is non-zero, we copy it using the queue
-// assignment operator.  We don't mess with the trace -- we just reset it.
-// We're assuming that the tracing will be set up after the topology creation
-// phase and this won't actually matter.
-//
-
-CsmaCdNetDevice::CsmaCdNetDevice (const CsmaCdNetDevice& nd)
-  : NetDevice(nd), m_bps (nd.m_bps)
-{
-  NS_DEBUG ("CsmaCdNetDevice::CsmaCdNetDevice (" << &nd << ")");
-
-  m_txMachineState = READY;
-  m_tInterframeGap = nd.m_tInterframeGap;
-  m_backoff = nd.m_backoff;
-  m_channel = nd.m_channel; 
-  m_queue = 0;
-  m_pktType = nd.m_pktType;
-  m_sendEnable = nd.m_sendEnable;
-  m_receiveEnable = nd.m_receiveEnable;
-    
-  if (nd.m_queue)
-    {
-      m_queue = nd.m_queue;
-    }
-    
-}
-
 void 
 CsmaCdNetDevice::DoDispose ()
 {
--- a/src/devices/csma-cd/csma-cd-net-device.h	Fri Jul 27 14:54:41 2007 -0700
+++ b/src/devices/csma-cd/csma-cd-net-device.h	Sat Jul 28 12:30:31 2007 +0200
@@ -97,30 +97,12 @@
                    CsmaCdEncapsulationMode pktType,
                    bool sendEnable, bool receiveEnable);
   /**
-   * Copy Construct a CsmaCdNetDevice
-   *
-   * This is the copy constructor for the CsmaCdNetDevice.  This is
-   * primarily used in topology creation.
-   *
-   * \param nd the object to be copied
-   */
-  CsmaCdNetDevice (const CsmaCdNetDevice& nd);
-  /**
    * Destroy a CsmaCdNetDevice
    *
    * This is the destructor for the CsmaCdNetDevice.
    */
   virtual ~CsmaCdNetDevice();
   /**
-   * Assignment Operator for a CsmaCdNetDevice
-   *
-   * This is the assignment operator for the CsmaCdNetDevice.  This is
-   * to allow
-   *
-   * \param nd the object to be copied
-   */
-  // CsmaCdNetDevice& operator= (CsmaCdNetDevice nd);
-  /**
    * Set the Data Rate used for transmission of packets.  The data rate is
    * set in the Attach () method from the corresponding field in the channel
    * to which the device is attached.  It can be overridden using this method.
@@ -243,6 +225,9 @@
   bool ProcessHeader (Packet& p, int& param);
 
 private:
+  // disable copy constructor and operator =
+  CsmaCdNetDevice &operator = (const CsmaCdNetDevice &o);
+  CsmaCdNetDevice (const CsmaCdNetDevice &o);
   /**
    * Initializes variablea when construction object.
    */