merge implicit conversion tree
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 06 Aug 2007 15:32:27 +0200
changeset 1208 ad83a13631c1
parent 1203 c225fdfe6de2 (current diff)
parent 1207 a9f3610bbffa (diff)
child 1209 7629e5cd8f5e
merge implicit conversion tree
examples/csma-cd-one-subnet.cc
examples/csma-cd-packet-socket.cc
src/devices/csma-cd/csma-cd-net-device.cc
src/devices/point-to-point/point-to-point-net-device.cc
src/internet-node/udp-socket.cc
src/node/eui48-address.cc
src/node/eui48-address.h
src/node/eui64-address.cc
src/node/eui64-address.h
src/node/ipv4-address.cc
src/node/ipv4-address.h
--- a/examples/csma-cd-one-subnet.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/examples/csma-cd-one-subnet.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -127,7 +127,7 @@
   // from n0 to n1
   Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
     n0, 
-    InetSocketAddress (Ipv4Address("10.1.1.2"), 80).ConvertTo (), 
+    InetSocketAddress ("10.1.1.2", 80), 
     "Udp",
     ConstantVariable(1), 
     ConstantVariable(0));
@@ -138,7 +138,7 @@
   // Create a similar flow from n3 to n0, starting at time 1.1 seconds
   ooff = Create<OnOffApplication> (
     n3, 
-    InetSocketAddress (Ipv4Address("10.1.1.1"), 80).ConvertTo (), 
+    InetSocketAddress ("10.1.1.1", 80), 
     "Udp",
     ConstantVariable(1), 
     ConstantVariable(0));
--- a/examples/csma-cd-packet-socket.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/examples/csma-cd-packet-socket.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -105,7 +105,7 @@
   // from n0 to n1
   Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
     n0, 
-    n0ToN1.ConvertTo (),
+    n0ToN1,
     "Packet",
     ConstantVariable(1), 
     ConstantVariable(0));
@@ -116,7 +116,7 @@
   // Create a similar flow from n3 to n0, starting at time 1.1 seconds
   ooff = Create<OnOffApplication> (
     n3, 
-    n3ToN0.ConvertTo (),
+    n3ToN0,
     "Packet",
     ConstantVariable(1), 
     ConstantVariable(0));
--- a/examples/simple-point-to-point.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/examples/simple-point-to-point.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -144,7 +144,7 @@
   // 210 bytes at a rate of 448 Kb/s
   Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
     n0, 
-    InetSocketAddress (Ipv4Address("10.1.3.2"), 80).ConvertTo (), 
+    InetSocketAddress ("10.1.3.2", 80), 
     "Udp",
     ConstantVariable(1), 
     ConstantVariable(0));
@@ -155,7 +155,7 @@
   // Create a similar flow from n3 to n1, starting at time 1.1 seconds
   ooff = Create<OnOffApplication> (
     n3, 
-    InetSocketAddress (Ipv4Address("10.1.2.1"), 80).ConvertTo (), 
+    InetSocketAddress ("10.1.2.1", 80), 
     "Udp",
     ConstantVariable(1), 
     ConstantVariable(0));
--- a/samples/main-simple.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/samples/main-simple.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -46,11 +46,11 @@
 
   Ptr<Socket> sink = socketFactory->CreateSocket ();
   InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80);
-  sink->Bind (local.ConvertTo ());
+  sink->Bind (local);
 
   Ptr<Socket> source = socketFactory->CreateSocket ();
   InetSocketAddress remote = InetSocketAddress (Ipv4Address::GetLoopback (), 80);
-  source->Connect (remote.ConvertTo ());
+  source->Connect (remote);
 
   GenerateTraffic (source, 500);
   PrintTraffic (sink);
--- a/src/devices/csma-cd/csma-cd-net-device.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/devices/csma-cd/csma-cd-net-device.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -46,7 +46,7 @@
 
 CsmaCdNetDevice::CsmaCdNetDevice (Ptr<Node> node, Eui48Address addr, 
                                   CsmaCdEncapsulationMode encapMode) 
-  : NetDevice(node, addr.ConvertTo ()), 
+  : NetDevice(node, addr), 
     m_bps (DataRate (0xffffffff))
 {
   NS_DEBUG ("CsmaCdNetDevice::CsmaCdNetDevice (" << node << ")");
@@ -58,7 +58,7 @@
 CsmaCdNetDevice::CsmaCdNetDevice (Ptr<Node> node, Eui48Address addr, 
                                   CsmaCdEncapsulationMode encapMode,
                                   bool sendEnable, bool receiveEnable) 
-  : NetDevice(node, addr.ConvertTo ()), 
+  : NetDevice(node, addr), 
     m_bps (DataRate (0xffffffff))
 {
   NS_DEBUG ("CsmaCdNetDevice::CsmaCdNetDevice (" << node << ")");
@@ -105,7 +105,7 @@
   m_channel = 0; 
   m_queue = 0;
 
-  EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff").ConvertTo ());
+  EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff"));
   EnableMulticast();
   EnablePointToPoint();
 
@@ -210,10 +210,8 @@
   trailer.CheckFcs(p);
   p.RemoveHeader(header);
 
-  Eui48Address broadcast = Eui48Address::ConvertFrom (GetBroadcast ());
-  Eui48Address destination = Eui48Address::ConvertFrom (GetAddress ());
-  if ((header.GetDestination() != broadcast) &&
-      (header.GetDestination() != destination))
+  if ((header.GetDestination() != GetBroadcast ()) &&
+      (header.GetDestination() != GetAddress ()))
     {
       return false;
     }
@@ -261,8 +259,8 @@
   if (!IsSendEnabled())
     return false;
 
-  Eui48Address address = Eui48Address::ConvertFrom (dest);
-  AddHeader(p, address, protocolNumber);
+  Eui48Address destination = Eui48Address::ConvertFrom (dest);
+  AddHeader(p, destination, protocolNumber);
 
   // Place the packet to be sent on the send queue
   if (m_queue->Enqueue(p) == false )
--- a/src/devices/point-to-point/point-to-point-net-device.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/devices/point-to-point/point-to-point-net-device.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -43,7 +43,7 @@
 PointToPointNetDevice::PointToPointNetDevice (Ptr<Node> node,
                                               const DataRate& rate) 
 : 
-  NetDevice(node, Eui48Address::Allocate ().ConvertTo ()), 
+  NetDevice(node, Eui48Address::Allocate ()), 
   m_txMachineState (READY),
   m_bps (rate),
   m_tInterframeGap (Seconds(0)),
@@ -56,7 +56,7 @@
   // BUGBUG FIXME
   //
   // You _must_ support broadcast to get any sort of packet from the ARP layer.
-  EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff").ConvertTo ());
+  EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff"));
   EnableMulticast();
   EnablePointToPoint();
 }
--- a/src/internet-node/udp-socket.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/internet-node/udp-socket.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -271,7 +271,7 @@
       return;
     }
   
-  Address address = InetSocketAddress (ipv4, port).ConvertTo ();
+  Address address = InetSocketAddress (ipv4, port);
   Packet p = packet;
   if (!m_dummyRxCallback.IsNull ())
     {
--- a/src/node/eui48-address.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/node/eui48-address.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -95,6 +95,14 @@
 {
   return address.CheckCompatible (GetType (), 6);
 }
+Eui48Address::operator Address ()
+{
+  return ConvertTo ();
+}
+Eui48Address::Eui48Address (const Address &address)
+{
+  *this = ConvertFrom (address);
+}
 Address 
 Eui48Address::ConvertTo (void) const
 {
--- a/src/node/eui48-address.h	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/node/eui48-address.h	Mon Aug 06 15:32:27 2007 +0200
@@ -55,28 +55,37 @@
    * Copy the internal address to the input buffer.
    */
   void CopyTo (uint8_t buffer[6]) const;
+
+  /**
+   * \returns a new Address instance
+   *
+   * Convert an instance of this class to a polymorphic Address instance.
+   */
+  operator Address ();
+  /**
+   * \param address a polymorphic address
+   * \returns a new Eui48Address from the polymorphic address
+   * 
+   * This function performs a type check and asserts if the
+   * type of the input address is not compatible with an
+   * Eui48Address.
+   */
+  static Eui48Address ConvertFrom (const Address &address);
+  /**
+   * \returns true if the address matches, false otherwise.
+   */
+  static bool IsMatchingType (const Address &address);
+  /**
+   * Allocate a new Eui48Address.
+   */
+  static Eui48Address Allocate (void);
+private:
   /**
    * \returns a new Address instance
    *
    * Convert an instance of this class to a polymorphic Address instance.
    */
   Address ConvertTo (void) const;
-  /**
-   * \returns true if the address matches, false otherwise.
-   */
-  static bool IsMatchingType (const Address &address);
-  /**
-   * \param address a polymorphic address
-   *
-   * Convert a polymorphic address to an Eui48Address instance.
-   * The conversion performs a type check.
-   */
-  static Eui48Address ConvertFrom (const Address &address);
-  /**
-   * Allocate a new Eui48Address.
-   */
-  static Eui48Address Allocate (void);
-private:
   static uint8_t GetType (void);
   uint8_t m_address[6];
 };
--- a/src/node/eui64-address.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/node/eui64-address.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -95,6 +95,14 @@
 {
   return address.CheckCompatible (GetType (), 8);
 }
+Eui48Address::operator Address ()
+{
+  return ConvertTo ();
+}
+Eui48Address::Eui48Address (const Address &address)
+{
+  *this = ConvertFrom (address);
+}
 Address 
 Eui64Address::ConvertTo (void) const
 {
--- a/src/node/eui64-address.h	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/node/eui64-address.h	Mon Aug 06 15:32:27 2007 +0200
@@ -60,12 +60,22 @@
    *
    * Convert an instance of this class to a polymorphic Address instance.
    */
-  Address ConvertTo (void) const;
+  operator Address ();
+  /**
+   * \param address a polymorphic address
+   * \returns a new Eui48Address from the polymorphic address
+   * 
+   * This function performs a type check and asserts if the
+   * type of the input address is not compatible with an
+   * Eui48Address.
+   */
+  static Eui48Address ConvertFrom (const Address &address);
   /**
    * \returns true if the address matches, false otherwise.
    */
   static bool IsMatchingType (const Address &address);
   /**
+<<<<<<< /auto/fugue/u/fugue/home/mlacage/code/ns-3-dev/src/node/eui64-address.h
    * \param address a polymorphic address
    *
    * Convert a polymorphic address to an Eui64Address instance.
@@ -74,9 +84,18 @@
   static Eui64Address ConvertFrom (const Address &address);
   /**
    * Allocate a new Eui64Address.
+=======
+   * Allocate a new Eui48Address.
+>>>>>>> /tmp/eui48-address.h~other.OBFjbL
    */
   static Eui64Address Allocate (void);
 private:
+  /**
+   * \returns a new Address instance
+   *
+   * Convert an instance of this class to a polymorphic Address instance.
+   */
+  Address ConvertTo (void) const;
   static uint8_t GetType (void);
   uint8_t m_address[8];
 };
--- a/src/node/inet-socket-address.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/node/inet-socket-address.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -51,6 +51,11 @@
   return address.CheckCompatible (GetType (), 6);
 }
 
+InetSocketAddress::operator Address () const
+{
+  return ConvertTo ();
+}
+
 Address 
 InetSocketAddress::ConvertTo (void) const
 {
--- a/src/node/inet-socket-address.h	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/node/inet-socket-address.h	Mon Aug 06 15:32:27 2007 +0200
@@ -73,14 +73,18 @@
    * \returns an Address instance which represents this
    * InetSocketAddress instance.
    */
-  Address ConvertTo (void) const;
+  operator Address () const;
+
   /**
    * \param address the Address instance to convert from.
-   * \returns an InetSocketAddress which corresponds to the input
+   *
+   * Returns an InetSocketAddress which corresponds to the input
    * Address
    */
   static InetSocketAddress ConvertFrom (const Address &address);
 private:
+  Address ConvertTo (void) const;
+
   static uint8_t GetType (void);
   Ipv4Address m_ipv4;
   uint16_t m_port;
--- a/src/node/ipv4-address.cc	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/node/ipv4-address.cc	Mon Aug 06 15:32:27 2007 +0200
@@ -222,6 +222,11 @@
 {
   return address.CheckCompatible (GetType (), 4);
 }
+Ipv4Address::operator Address ()
+{
+  return ConvertTo ();
+}
+
 Address 
 Ipv4Address::ConvertTo (void) const
 {
--- a/src/node/ipv4-address.h	Mon Aug 06 11:55:17 2007 +0100
+++ b/src/node/ipv4-address.h	Mon Aug 06 15:32:27 2007 +0200
@@ -121,7 +121,7 @@
   Ipv4Address CombineMask (Ipv4Mask const &mask) const;
 
   static bool IsMatchingType (const Address &address);
-  Address ConvertTo (void) const;
+  operator Address ();
   static Ipv4Address ConvertFrom (const Address &address);
 
   static Ipv4Address GetZero (void);
@@ -129,6 +129,7 @@
   static Ipv4Address GetBroadcast (void);
   static Ipv4Address GetLoopback (void);
 private:
+  Address ConvertTo (void) const;
   static uint8_t GetType (void);
   uint32_t m_address;
 };