disable copy constructor and operator = for CsmaCdNetDevice
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Sat, 28 Jul 2007 12:30:31 +0200
changeset 99237953a86a975
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
     1.1 --- a/src/devices/csma-cd/csma-cd-net-device.cc	Fri Jul 27 14:54:41 2007 -0700
     1.2 +++ b/src/devices/csma-cd/csma-cd-net-device.cc	Sat Jul 28 12:30:31 2007 +0200
     1.3 @@ -62,43 +62,6 @@
     1.4    m_queue = 0;
     1.5  }
     1.6  
     1.7 -//
     1.8 -// Copy constructor for CsmaCdNetDevice.
     1.9 -//
    1.10 -// We use the underlying NetDevice copy constructor to get the base class
    1.11 -// copied.  These just remain as is (e.g. you get the same name, the same
    1.12 -// MAC address).  If you need to fix them up, YOU, the copier need to do 
    1.13 -// that.
    1.14 -// 
    1.15 -// The things we need to be careful of are the channel, the queue and the
    1.16 -// trace callback.  If the channel pointer is non-zero, we copy the pointer 
    1.17 -// and add a reference.  If the queue is non-zero, we copy it using the queue
    1.18 -// assignment operator.  We don't mess with the trace -- we just reset it.
    1.19 -// We're assuming that the tracing will be set up after the topology creation
    1.20 -// phase and this won't actually matter.
    1.21 -//
    1.22 -
    1.23 -CsmaCdNetDevice::CsmaCdNetDevice (const CsmaCdNetDevice& nd)
    1.24 -  : NetDevice(nd), m_bps (nd.m_bps)
    1.25 -{
    1.26 -  NS_DEBUG ("CsmaCdNetDevice::CsmaCdNetDevice (" << &nd << ")");
    1.27 -
    1.28 -  m_txMachineState = READY;
    1.29 -  m_tInterframeGap = nd.m_tInterframeGap;
    1.30 -  m_backoff = nd.m_backoff;
    1.31 -  m_channel = nd.m_channel; 
    1.32 -  m_queue = 0;
    1.33 -  m_pktType = nd.m_pktType;
    1.34 -  m_sendEnable = nd.m_sendEnable;
    1.35 -  m_receiveEnable = nd.m_receiveEnable;
    1.36 -    
    1.37 -  if (nd.m_queue)
    1.38 -    {
    1.39 -      m_queue = nd.m_queue;
    1.40 -    }
    1.41 -    
    1.42 -}
    1.43 -
    1.44  void 
    1.45  CsmaCdNetDevice::DoDispose ()
    1.46  {
     2.1 --- a/src/devices/csma-cd/csma-cd-net-device.h	Fri Jul 27 14:54:41 2007 -0700
     2.2 +++ b/src/devices/csma-cd/csma-cd-net-device.h	Sat Jul 28 12:30:31 2007 +0200
     2.3 @@ -97,30 +97,12 @@
     2.4                     CsmaCdEncapsulationMode pktType,
     2.5                     bool sendEnable, bool receiveEnable);
     2.6    /**
     2.7 -   * Copy Construct a CsmaCdNetDevice
     2.8 -   *
     2.9 -   * This is the copy constructor for the CsmaCdNetDevice.  This is
    2.10 -   * primarily used in topology creation.
    2.11 -   *
    2.12 -   * \param nd the object to be copied
    2.13 -   */
    2.14 -  CsmaCdNetDevice (const CsmaCdNetDevice& nd);
    2.15 -  /**
    2.16     * Destroy a CsmaCdNetDevice
    2.17     *
    2.18     * This is the destructor for the CsmaCdNetDevice.
    2.19     */
    2.20    virtual ~CsmaCdNetDevice();
    2.21    /**
    2.22 -   * Assignment Operator for a CsmaCdNetDevice
    2.23 -   *
    2.24 -   * This is the assignment operator for the CsmaCdNetDevice.  This is
    2.25 -   * to allow
    2.26 -   *
    2.27 -   * \param nd the object to be copied
    2.28 -   */
    2.29 -  // CsmaCdNetDevice& operator= (CsmaCdNetDevice nd);
    2.30 -  /**
    2.31     * Set the Data Rate used for transmission of packets.  The data rate is
    2.32     * set in the Attach () method from the corresponding field in the channel
    2.33     * to which the device is attached.  It can be overridden using this method.
    2.34 @@ -243,6 +225,9 @@
    2.35    bool ProcessHeader (Packet& p, int& param);
    2.36  
    2.37  private:
    2.38 +  // disable copy constructor and operator =
    2.39 +  CsmaCdNetDevice &operator = (const CsmaCdNetDevice &o);
    2.40 +  CsmaCdNetDevice (const CsmaCdNetDevice &o);
    2.41    /**
    2.42     * Initializes variablea when construction object.
    2.43     */