bug 498: Object Name Service Obsoletes Legacy Naming
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 16 Apr 2009 11:10:17 +0200
changeset 4322 bad9eed19283
parent 4321 cbbc344586fc
child 4323 689bece0b361
bug 498: Object Name Service Obsoletes Legacy Naming
src/devices/bridge/bridge-channel.cc
src/devices/bridge/bridge-net-device.cc
src/devices/bridge/bridge-net-device.h
src/devices/csma/csma-channel.cc
src/devices/csma/csma-net-device.cc
src/devices/csma/csma-net-device.h
src/devices/emu/emu-net-device.cc
src/devices/emu/emu-net-device.h
src/devices/point-to-point/point-to-point-channel.cc
src/devices/point-to-point/point-to-point-channel.h
src/devices/point-to-point/point-to-point-net-device.cc
src/devices/point-to-point/point-to-point-net-device.h
src/devices/tap-bridge/tap-bridge.cc
src/devices/tap-bridge/tap-bridge.h
src/devices/wifi/wifi-net-device.cc
src/devices/wifi/wifi-net-device.h
src/node/channel.cc
src/node/channel.h
src/node/net-device.h
src/node/node.cc
src/node/simple-net-device.cc
src/node/simple-net-device.h
--- a/src/devices/bridge/bridge-channel.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/bridge/bridge-channel.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -34,7 +34,7 @@
 }
 
 BridgeChannel::BridgeChannel ()
-  : Channel ("BridgeChannel")
+  : Channel ()
 {
   NS_LOG_FUNCTION_NOARGS ();
 }
--- a/src/devices/bridge/bridge-net-device.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/bridge/bridge-net-device.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -53,7 +53,6 @@
 
 BridgeNetDevice::BridgeNetDevice ()
   : m_node (0),
-    m_name (""),
     m_ifIndex (0),
     m_mtu (0xffff)
 {
@@ -128,7 +127,7 @@
                                  uint16_t protocol, Mac48Address src, Mac48Address dst)
 {
   NS_LOG_FUNCTION_NOARGS ();
-  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
+  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetInstanceTypeId ().GetName ()
                 << ", packet=" << packet << ", protocol="<<protocol
                 << ", src=" << src << ", dst=" << dst << ")");
 
@@ -136,7 +135,7 @@
   Ptr<NetDevice> outPort = GetLearnedState (dst);
   if (outPort != NULL && outPort != incomingPort)
     {
-      NS_LOG_LOGIC ("Learning bridge state says to use port `" << outPort->GetName () << "'");
+      NS_LOG_LOGIC ("Learning bridge state says to use port `" << outPort->GetInstanceTypeId ().GetName () << "'");
       outPort->SendFrom (packet->Copy (), src, dst, protocol);
     }
   else
@@ -148,8 +147,9 @@
           Ptr<NetDevice> port = *iter;
           if (port != incomingPort)
             {
-              NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " << incomingPort->GetName ()
-                            << " --> " << port->GetName ()
+              NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " 
+                            << incomingPort->GetInstanceTypeId ().GetName ()
+                            << " --> " << port->GetInstanceTypeId ().GetName ()
                             << " (UID " << packet->GetUid () << ").");
               port->SendFrom (packet->Copy (), src, dst, protocol);
             }
@@ -162,7 +162,7 @@
                                         uint16_t protocol, Mac48Address src, Mac48Address dst)
 {
   NS_LOG_FUNCTION_NOARGS ();
-  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
+  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetInstanceTypeId ().GetName ()
                 << ", packet=" << packet << ", protocol="<<protocol
                 << ", src=" << src << ", dst=" << dst << ")");
   Learn (src, incomingPort);
@@ -173,8 +173,9 @@
       Ptr<NetDevice> port = *iter;
       if (port != incomingPort)
         {
-          NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " << incomingPort->GetName ()
-                        << " --> " << port->GetName ()
+          NS_LOG_LOGIC ("LearningBridgeForward (" << src << " => " << dst << "): " 
+                        << incomingPort->GetInstanceTypeId ().GetName ()
+                        << " --> " << port->GetInstanceTypeId ().GetName ()
                         << " (UID " << packet->GetUid () << ").");
           port->SendFrom (packet->Copy (), src, dst, protocol);
         }
@@ -249,7 +250,7 @@
       m_address = Mac48Address::ConvertFrom (bridgePort->GetAddress ());
     }
 
-  NS_LOG_DEBUG ("RegisterProtocolHandler for " << bridgePort->GetName ());
+  NS_LOG_DEBUG ("RegisterProtocolHandler for " << bridgePort->GetInstanceTypeId ().GetName ());
   m_node->RegisterProtocolHandler (MakeCallback (&BridgeNetDevice::ReceiveFromDevice, this),
                                    0, bridgePort, true);
   m_ports.push_back (bridgePort);
@@ -257,20 +258,6 @@
 }
 
 void 
-BridgeNetDevice::SetName(const std::string name)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  m_name = name;
-}
-
-std::string 
-BridgeNetDevice::GetName(void) const
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  return m_name;
-}
-
-void 
 BridgeNetDevice::SetIfIndex(const uint32_t index)
 {
   NS_LOG_FUNCTION_NOARGS ();
--- a/src/devices/bridge/bridge-net-device.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/bridge/bridge-net-device.h	Thu Apr 16 11:10:17 2009 +0200
@@ -88,8 +88,6 @@
   Ptr<NetDevice> GetBridgePort (uint32_t n) const;
 
   // inherited from NetDevice base class.
-  virtual void SetName(const std::string name);
-  virtual std::string GetName(void) const;
   virtual void SetIfIndex(const uint32_t index);
   virtual uint32_t GetIfIndex(void) const;
   virtual Ptr<Channel> GetChannel (void) const;
@@ -140,7 +138,6 @@
   std::map<Mac48Address, LearnedState> m_learnState;
   Ptr<Node> m_node;
   Ptr<BridgeChannel> m_channel;
-  std::string m_name;
   std::vector< Ptr<NetDevice> > m_ports;
   uint32_t m_ifIndex;
   uint16_t m_mtu;
--- a/src/devices/csma/csma-channel.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/csma/csma-channel.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -51,7 +51,7 @@
 
 CsmaChannel::CsmaChannel ()
 : 
-  Channel ("Csma Channel")
+  Channel ()
 {
   NS_LOG_FUNCTION_NOARGS ();
   m_state = IDLE;
--- a/src/devices/csma/csma-net-device.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/csma/csma-net-device.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -154,8 +154,7 @@
 }
 
 CsmaNetDevice::CsmaNetDevice ()
-  : m_name (""),
-    m_linkUp (false)
+ : m_linkUp (false)
 {
   NS_LOG_FUNCTION (this);
   m_txMachineState = READY;
@@ -874,20 +873,6 @@
 }
 
   void 
-CsmaNetDevice::SetName (const std::string name)
-{
-  NS_LOG_FUNCTION (name);
-  m_name = name;
-}
-
-  std::string 
-CsmaNetDevice::GetName (void) const
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  return m_name;
-}
-
-  void 
 CsmaNetDevice::SetIfIndex (const uint32_t index)
 {
   NS_LOG_FUNCTION (index);
@@ -1054,25 +1039,6 @@
   NS_LOG_FUNCTION (node);
 
   m_node = node;
-  int count = -1;
-  if (m_name.size () == 0)
-    {
-      for (uint32_t i = 0; i < node->GetNDevices (); i++)
-        {
-          Ptr<NetDevice> dev = node->GetDevice (i);
-          if (dynamic_cast<CsmaNetDevice*> (PeekPointer (dev)))
-            {
-              count++;
-              if (dev == this)
-                {
-                  break;
-                }
-            }
-        }
-      std::ostringstream s;
-      s << "eth" << count;
-      m_name = s.str ();
-    }
 }
 
   bool 
--- a/src/devices/csma/csma-net-device.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/csma/csma-net-device.h	Thu Apr 16 11:10:17 2009 +0200
@@ -305,8 +305,6 @@
   //
   // The following methods are inherited from NetDevice base class.
   //
-  virtual void SetName (const std::string name);
-  virtual std::string GetName (void) const;
   virtual void SetIfIndex (const uint32_t index);
   virtual uint32_t GetIfIndex (void) const;
   virtual Ptr<Channel> GetChannel (void) const;
@@ -808,11 +806,6 @@
   uint32_t m_ifIndex;
 
   /**
-   * The human readable name of this device.
-   */
-  std::string m_name;
-
-  /**
    * Flag indicating whether or not the link is up.  In this case,
    * whether or not the device is connected to a channel.
    */
--- a/src/devices/emu/emu-net-device.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/emu/emu-net-device.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -68,11 +68,6 @@
                    Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
                    MakeMac48AddressAccessor (&EmuNetDevice::m_address),
                    MakeMac48AddressChecker ())
-    .AddAttribute ("DeviceName", 
-                   "The name of the underlying real device (e.g. eth1).",
-                   StringValue ("eth1"),
-                   MakeStringAccessor (&EmuNetDevice::m_deviceName),
-                   MakeStringChecker ())
     .AddAttribute ("Start", 
                    "The simulation time at which to spin up the device thread.",
                    TimeValue (Seconds (0.)),
@@ -173,8 +168,7 @@
   m_sock (-1),
   m_readThread (0),
   m_ifIndex (std::numeric_limits<uint32_t>::max ()),  // absurdly large value
-  m_sll_ifindex (-1),
-  m_name ("Emu NetDevice")
+  m_sll_ifindex (-1)
 {
   NS_LOG_FUNCTION (this);
   Start (m_tStart);
@@ -844,18 +838,6 @@
 }
 
 void 
-EmuNetDevice::SetName(const std::string name)
-{
-  m_name = name;
-}
-
-std::string 
-EmuNetDevice::GetName(void) const
-{
-  return m_name;
-}
-
-void 
 EmuNetDevice::SetIfIndex(const uint32_t index)
 {
   m_ifIndex = index;
--- a/src/devices/emu/emu-net-device.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/emu/emu-net-device.h	Thu Apr 16 11:10:17 2009 +0200
@@ -105,9 +105,6 @@
 //
 // Pure virtual methods inherited from NetDevice we must implement.
 //
-  virtual void SetName(const std::string name);
-  virtual std::string GetName(void) const;
-
   virtual void SetIfIndex(const uint32_t index);
   virtual uint32_t GetIfIndex(void) const;
 
@@ -450,11 +447,6 @@
   int32_t m_sll_ifindex;
 
   /**
-   * The human readable name of this device.
-   */
-  std::string m_name;
-
-  /**
    * Flag indicating whether or not the link is up.  In this case,
    * whether or not the device is connected to a channel.
    */
--- a/src/devices/point-to-point/point-to-point-channel.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/point-to-point/point-to-point-channel.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -43,11 +43,11 @@
 }
 
 //
-// By default, you get a channel with the name "PointToPoint Channel" that 
+// By default, you get a channel that 
 // has an "infitely" fast transmission speed and zero delay.
 PointToPointChannel::PointToPointChannel()
 : 
-  Channel ("PointToPoint Channel"), 
+  Channel (), 
   m_delay (Seconds (0.)),
   m_nDevices (0)
 {
--- a/src/devices/point-to-point/point-to-point-channel.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/point-to-point/point-to-point-channel.h	Thu Apr 16 11:10:17 2009 +0200
@@ -50,7 +50,7 @@
   /**
    * \brief Create a PointToPointChannel
    *
-   * By default, you get a channel with the name "PointToPoint Channel" that
+   * By default, you get a channel that
    * has zero transmission delay.
    */
   PointToPointChannel ();
--- a/src/devices/point-to-point/point-to-point-net-device.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -148,7 +148,6 @@
 : 
   m_txMachineState (READY),
   m_channel (0), 
-  m_name (""),
   m_linkUp (false),
   m_currentPkt (0)
 {
@@ -374,18 +373,6 @@
 }
 
   void 
-PointToPointNetDevice::SetName(const std::string name)
-{
-  m_name = name;
-}
-
-  std::string 
-PointToPointNetDevice::GetName(void) const
-{
-  return m_name;
-}
-
-  void 
 PointToPointNetDevice::SetIfIndex(const uint32_t index)
 {
   m_ifIndex = index;
--- a/src/devices/point-to-point/point-to-point-net-device.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.h	Thu Apr 16 11:10:17 2009 +0200
@@ -226,12 +226,6 @@
    */
   uint16_t GetFrameSize (void) const;
 
-//
-// Pure virtual methods inherited from NetDevice we must implement.
-//
-  virtual void SetName(const std::string name);
-  virtual std::string GetName(void) const;
-
   virtual void SetIfIndex(const uint32_t index);
   virtual uint32_t GetIfIndex(void) const;
 
@@ -531,7 +525,6 @@
   NetDevice::ReceiveCallback m_rxCallback;
   NetDevice::PromiscReceiveCallback m_promiscCallback;
   uint32_t m_ifIndex;
-  std::string m_name;
   bool m_linkUp;
   Callback<void> m_linkChangeCallback;
 
--- a/src/devices/tap-bridge/tap-bridge.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/tap-bridge/tap-bridge.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -958,20 +958,6 @@
 }
 
 void 
-TapBridge::SetName(const std::string name)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  m_name = name;
-}
-
-std::string 
-TapBridge::GetName(void) const
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  return m_name;
-}
-
-void 
 TapBridge::SetIfIndex(const uint32_t index)
 {
   NS_LOG_FUNCTION_NOARGS ();
--- a/src/devices/tap-bridge/tap-bridge.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/tap-bridge/tap-bridge.h	Thu Apr 16 11:10:17 2009 +0200
@@ -173,8 +173,6 @@
   // The following methods are inherited from NetDevice base class and are
   // documented there.
   //
-  virtual void SetName(const std::string name);
-  virtual std::string GetName(void) const;
   virtual void SetIfIndex(const uint32_t index);
   virtual uint32_t GetIfIndex(void) const;
   virtual Ptr<Channel> GetChannel (void) const;
@@ -318,12 +316,6 @@
    */
   Ptr<Node> m_node;
 
-  /**
-   * \internal
-   *
-   * A possible name for the (ghost) Node to which we are connected.
-   */
-  std::string m_name;
 
   /**
    * \internal
--- a/src/devices/wifi/wifi-net-device.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/wifi/wifi-net-device.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -137,16 +137,6 @@
 }
 
 void 
-WifiNetDevice::SetName(const std::string name)
-{
-  m_name = name;
-}
-std::string 
-WifiNetDevice::GetName(void) const
-{
-  return m_name;
-}
-void 
 WifiNetDevice::SetIfIndex(const uint32_t index)
 {
   m_ifIndex = index;
--- a/src/devices/wifi/wifi-net-device.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/devices/wifi/wifi-net-device.h	Thu Apr 16 11:10:17 2009 +0200
@@ -75,8 +75,6 @@
 
 
   // inherited from NetDevice base class.
-  virtual void SetName(const std::string name);
-  virtual std::string GetName(void) const;
   virtual void SetIfIndex(const uint32_t index);
   virtual uint32_t GetIfIndex(void) const;
   virtual Ptr<Channel> GetChannel (void) const;
@@ -123,7 +121,6 @@
   TracedCallback<Ptr<const Packet>, Mac48Address> m_txLogger;
 
   uint32_t m_ifIndex;
-  std::string m_name;
   bool m_linkUp;
   Callback<void> m_linkChange;
   mutable uint16_t m_mtu;
--- a/src/node/channel.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/node/channel.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -35,34 +35,14 @@
 }
 
 Channel::Channel ()
-  : m_name("Channel")
 {
   NS_LOG_FUNCTION_NOARGS ();
 }
 
-Channel::Channel (std::string name)
-  : m_name(name)
-{
-  NS_LOG_FUNCTION (this << name);
-}
 
 Channel::~Channel ()
 {
   NS_LOG_FUNCTION_NOARGS ();
 }
 
-  void
-Channel::SetName(std::string name)
-{
-  NS_LOG_FUNCTION (this << name);
-  m_name = name;
-}
-
-  std::string
-Channel::GetName(void)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  return m_name;
-}
-
 } // namespace ns3
--- a/src/node/channel.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/node/channel.h	Thu Apr 16 11:10:17 2009 +0200
@@ -43,12 +43,8 @@
   static TypeId GetTypeId (void);
 
   Channel ();
-  Channel (std::string name);
   virtual ~Channel ();
 
-  void SetName(std::string);
-  std::string GetName(void);
-
   /**
    * \returns the number of NetDevices connected to this Channel.
    *
@@ -63,10 +59,8 @@
    */
   virtual Ptr<NetDevice> GetDevice (uint32_t i) const = 0;
 
-private:
-  std::string   m_name;
 };
 
-}; // namespace ns3
+} // namespace ns3
 
 #endif /* NS3_CHANNEL_H */
--- a/src/node/net-device.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/node/net-device.h	Thu Apr 16 11:10:17 2009 +0200
@@ -68,14 +68,6 @@
   virtual ~NetDevice();
 
   /**
-   * \param name name of the device (e.g. "eth0")
-   */
-  virtual void SetName(const std::string name) = 0;
-  /**
-   * \return name name of the device (e.g. "eth0")
-   */
-  virtual std::string GetName(void) const = 0;
-  /**
    * \param index ifIndex of the device 
    */
   virtual void SetIfIndex(const uint32_t index) = 0;
--- a/src/node/node.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/node/node.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -225,7 +225,7 @@
 Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
                                 const Address &from, const Address &to, NetDevice::PacketType packetType)
 {
-  NS_LOG_FUNCTION(device->GetName ());
+  NS_LOG_FUNCTION(this);
   return ReceiveFromDevice (device, packet, protocol, from, to, packetType, true);
 }
 
@@ -233,7 +233,7 @@
 Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
                                    const Address &from)
 {
-  NS_LOG_FUNCTION(device->GetName ());
+  NS_LOG_FUNCTION(this);
   return ReceiveFromDevice (device, packet, protocol, from, from, NetDevice::PacketType (0), false);
 }
 
@@ -242,8 +242,7 @@
                          const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous)
 {
   NS_LOG_DEBUG("Node " << GetId () << " ReceiveFromDevice:  dev "
-               << device->GetIfIndex () << " ("
-               << device->GetName () << " type " << device->GetInstanceTypeId ().GetName ()
+               << device->GetIfIndex () << " (type=" << device->GetInstanceTypeId ().GetName ()
                << ") Packet UID " << packet->GetUid ());
   bool found = false;
 
--- a/src/node/simple-net-device.cc	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/node/simple-net-device.cc	Thu Apr 16 11:10:17 2009 +0200
@@ -38,7 +38,6 @@
   : m_channel (0),
     m_node (0),
     m_mtu (0xffff),
-    m_name (""),
     m_ifIndex (0)
 {}
 
@@ -84,16 +83,6 @@
 }
 
 void 
-SimpleNetDevice::SetName(const std::string name)
-{
-  m_name = name;
-}
-std::string 
-SimpleNetDevice::GetName(void) const
-{
-  return m_name;
-}
-void 
 SimpleNetDevice::SetIfIndex(const uint32_t index)
 {
   m_ifIndex = index;
--- a/src/node/simple-net-device.h	Thu Apr 16 11:00:13 2009 +0200
+++ b/src/node/simple-net-device.h	Thu Apr 16 11:10:17 2009 +0200
@@ -46,8 +46,6 @@
   void SetAddress (Mac48Address address);
 
   // inherited from NetDevice base class.
-  virtual void SetName(const std::string name);
-  virtual std::string GetName(void) const;
   virtual void SetIfIndex(const uint32_t index);
   virtual uint32_t GetIfIndex(void) const;
   virtual Ptr<Channel> GetChannel (void) const;
@@ -82,7 +80,6 @@
   NetDevice::PromiscReceiveCallback m_promiscCallback;
   Ptr<Node> m_node;
   uint16_t m_mtu;
-  std::string m_name;
   uint32_t m_ifIndex;
   Mac48Address m_address;
 };