diff --git a/src/network/helper/net-device-container.cc b/src/network/helper/net-device-container.cc --- a/src/network/helper/net-device-container.cc +++ b/src/network/helper/net-device-container.cc @@ -21,6 +21,8 @@ #include "net-device-container.h" #include "ns3/names.h" +#include + namespace ns3 { NetDeviceContainer::NetDeviceContainer () @@ -83,4 +85,38 @@ m_devices.push_back (device); } +void +NetDeviceContainer::Remove (Ptr device) +{ + m_devices.erase (std::remove (m_devices.begin (), m_devices.end (), device), m_devices.end ()); +} +void +NetDeviceContainer::Remove (std::string deviceName) +{ + Ptr device = Names::Find (deviceName); + m_devices.erase (std::remove (m_devices.begin (), m_devices.end (), device), m_devices.end ()); +} + +bool +NetDeviceContainer::operator== (const NetDeviceContainer &other) const +{ + uint32_t nMatching = 0; + if (GetN () != other.GetN ()) + { + return false; + } + for (uint32_t i = 0; i < GetN (); i++) + { + if (Get (i) == other.Get (i)) + { + nMatching++; + } + } + if (nMatching == GetN ()) + { + return true; + } + return false; +} + } // namespace ns3 diff --git a/src/network/helper/net-device-container.h b/src/network/helper/net-device-container.h --- a/src/network/helper/net-device-container.h +++ b/src/network/helper/net-device-container.h @@ -194,6 +194,11 @@ */ void Add (std::string deviceName); + void Remove (Ptr device); + void Remove (std::string deviceName); + + bool operator== (const NetDeviceContainer &other) const; + private: std::vector > m_devices; };