This commit is contained in:
Mathieu Lacage
2008-03-24 10:14:35 -07:00
parent 4404c371af
commit 29f19e164e
2 changed files with 36 additions and 10 deletions

View File

@@ -5,36 +5,36 @@ namespace ns3 {
NetDeviceContainer::Iterator
NetDeviceContainer::Begin (void) const
{
return m_nodes.begin ();
return m_devices.begin ();
}
NetDeviceContainer::Iterator
NetDeviceContainer::End (void) const
{
return m_nodes.end ();
return m_devices.end ();
}
uint32_t
NetDeviceContainer::GetN (void) const
{
return m_nodes.size ();
return m_devices.size ();
}
Ptr<NetDevice>
NetDeviceContainer::Get (uint32_t i) const
{
return m_nodes[i];
return m_devices[i];
}
void
NetDeviceContainer::Add (NetDeviceContainer other)
{
for (Iterator i = other.Begin (); i != other.End (); i++)
{
m_nodes.push_back (*i);
m_devices.push_back (*i);
}
}
void
NetDeviceContainer::Add (Ptr<NetDevice> node)
NetDeviceContainer::Add (Ptr<NetDevice> device)
{
m_nodes.push_back (node);
m_devices.push_back (device);
}
} // namespace ns3

View File

@@ -7,23 +7,49 @@
namespace ns3 {
/**
* \brief holds a vector of ns3::NetDevice pointers
*
*/
class NetDeviceContainer
{
public:
typedef std::vector<Ptr<NetDevice> >::const_iterator Iterator;
/**
* \returns an iterator which points to the start of the array of pointers.
*/
Iterator Begin (void) const;
/**
* \returns an iterator which points to the end of the array of pointers.
*/
Iterator End (void) const;
/**
* \returns the number of netdevice pointers stored in this container.
*/
uint32_t GetN (void) const;
/**
* \param i the index of the requested netdevice pointer.
* \returns the requested netdevice pointer.
*/
Ptr<NetDevice> Get (uint32_t i) const;
void Create (uint32_t n);
/**
* \param other another netdevice container
*
* Append to the end of this container the other input container.
*/
void Add (NetDeviceContainer other);
void Add (Ptr<NetDevice> node);
/**
* \param device another netdevice pointer.
*
* Append to the end of this container the input netdevice pointer.
*/
void Add (Ptr<NetDevice> device);
private:
std::vector<Ptr<NetDevice> > m_nodes;
std::vector<Ptr<NetDevice> > m_devices;
};
} // namespace ns3