add NetDeviceContainer constructors
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 04 Sep 2008 10:04:14 -0700
changeset 3644 8100abafd21d
parent 3641 4925c4225148
child 3645 660d3a0c40cd
add NetDeviceContainer constructors
src/helper/net-device-container.cc
src/helper/net-device-container.h
--- a/src/helper/net-device-container.cc	Thu Sep 04 08:59:50 2008 -0700
+++ b/src/helper/net-device-container.cc	Thu Sep 04 10:04:14 2008 -0700
@@ -21,6 +21,19 @@
 
 namespace ns3 {
 
+NetDeviceContainer::NetDeviceContainer ()
+{}
+NetDeviceContainer::NetDeviceContainer (Ptr<NetDevice> dev)
+{
+  m_devices.push_back (dev);
+}
+NetDeviceContainer::NetDeviceContainer (const NetDeviceContainer &a, const NetDeviceContainer &b)
+{
+  *this = a;
+  Add (b);
+}
+
+
 NetDeviceContainer::Iterator 
 NetDeviceContainer::Begin (void) const
 {
--- a/src/helper/net-device-container.h	Thu Sep 04 08:59:50 2008 -0700
+++ b/src/helper/net-device-container.h	Thu Sep 04 10:04:14 2008 -0700
@@ -36,6 +36,33 @@
   typedef std::vector<Ptr<NetDevice> >::const_iterator Iterator;
 
   /**
+   * Create an empty NetDeviceContainer.
+   */
+  NetDeviceContainer ();
+  /**
+   * \param dev a device to add to the container
+   *
+   * Create a NetDeviceContainer with exactly one device
+   */
+  NetDeviceContainer (Ptr<NetDevice> dev);
+  /**
+   * \param a a device container
+   * \param b another device container
+   *
+   * Create a device container which is a concatenation of the two input
+   * NetDeviceContainers.
+   *
+   * \note A frequently seen idiom that uses these constructors involves the
+   * implicit conversion by constructor of Ptr<NetDevice>.  When used, two 
+   * Ptr<NetDevice> will be passed to this constructor instead of NetDeviceContainer&.
+   * C++ will notice the implicit conversion path that goes through the 
+   * NetDeviceContainer (Ptr<NetDevice> dev) constructor above.  Using this conversion
+   * one may provide optionally provide arguments of Ptr<NetDevice> to these 
+   * constructors.
+   */
+  NetDeviceContainer (const NetDeviceContainer &a, const NetDeviceContainer &b);
+
+  /**
    * \returns an iterator which points to the start of the array of pointers.
    */
   Iterator Begin (void) const;