From a60ac679a06794965c576c7aec83b4ce1dd66519 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Thu, 26 Jul 2007 16:04:54 +0200 Subject: [PATCH] disable copying PointToPointNetDevice --- src/devices/p2p/p2p-net-device.cc | 54 ------------------------------- src/devices/p2p/p2p-net-device.h | 24 +++----------- 2 files changed, 5 insertions(+), 73 deletions(-) diff --git a/src/devices/p2p/p2p-net-device.cc b/src/devices/p2p/p2p-net-device.cc index 102cc247f..13d352889 100644 --- a/src/devices/p2p/p2p-net-device.cc +++ b/src/devices/p2p/p2p-net-device.cc @@ -65,66 +65,12 @@ PointToPointNetDevice::~PointToPointNetDevice() m_queue = 0; } -// -// Copy constructor for PointToPointNetDevice. -// -// 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. -// -// GFR Comments. Don't see where the "copy the pointer and add reference" -// stated above is done. Can original author please comment and/or fix. -// Shouldn't the queue pointer also bump the refcount? -PointToPointNetDevice::PointToPointNetDevice (const PointToPointNetDevice& nd) -: - NetDevice(nd), - m_txMachineState(READY), - m_bps (nd.m_bps), - m_tInterframeGap (nd.m_tInterframeGap), - m_channel(nd.m_channel), - m_queue(0), - m_rxTrace () -{ - NS_DEBUG ("PointToPointNetDevice::PointToPointNetDevice (" << &nd << ")"); - - if (nd.m_queue) - { - m_queue = nd.m_queue; - } - -} - - // GFR COmments...shouldn't this decrement the refcount instead - // of just nil-ing out the pointer? Don't understand this. void PointToPointNetDevice::DoDispose() { m_channel = 0; NetDevice::DoDispose (); } -// -// Assignment operator for PointToPointNetDevice. -// -// -PointToPointNetDevice& -PointToPointNetDevice::operator= (const PointToPointNetDevice& nd) -{ - NS_DEBUG ("PointToPointNetDevice::operator= (" << &nd << ")"); - // FIXME. Not sure what to do here - // GFR Note. I would suggest dis-allowing netdevice assignment, - // as well as pass-by-value (ie. copy constructor). - // This resolves some of the questions above about copy constructors. - // Why should we ever copy or assign a net device? - return *this; -} void PointToPointNetDevice::SetDataRate(const DataRate& bps) { diff --git a/src/devices/p2p/p2p-net-device.h b/src/devices/p2p/p2p-net-device.h index 526d84523..a4bc3be00 100644 --- a/src/devices/p2p/p2p-net-device.h +++ b/src/devices/p2p/p2p-net-device.h @@ -83,31 +83,12 @@ public: */ PointToPointNetDevice (Ptr node, const DataRate& = g_defaultRate.GetValue()); - /** - * Copy Construct a PointToPointNetDevice - * - * This is the copy constructor for the PointToPointNetDevice. This is - * primarily used in topology creation. - * - * @see PointToPointTopology::AddPointToPointLink () - * @param nd the object to be copied - */ - PointToPointNetDevice (const PointToPointNetDevice& nd); /** * Destroy a PointToPointNetDevice * * This is the destructor for the PointToPointNetDevice. */ virtual ~PointToPointNetDevice(); - /** - * Assignment Operator for a PointToPointNetDevice - * - * This is the assignment operator for the PointToPointNetDevice. This is - * to allow - * - * @param nd the object to be copied - */ - PointToPointNetDevice& operator= (const PointToPointNetDevice& 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 @@ -206,6 +187,11 @@ protected: static const DataRate& GetDefaultRate(); private: + // unimplemented methods to make it impossible + // to copy these objects. + PointToPointNetDevice (const PointToPointNetDevice& nd); + PointToPointNetDevice& operator = (const PointToPointNetDevice&o); + /** * Send a Packet Down the Wire. *