A Discrete-Event Network Simulator
API
net-device-container.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "net-device-container.h"
22 #include "ns3/names.h"
23 
24 namespace ns3 {
25 
27 {
28 }
30 {
31  m_devices.push_back (dev);
32 }
34 {
35  Ptr<NetDevice> dev = Names::Find<NetDevice> (devName);
36  m_devices.push_back (dev);
37 }
39 {
40  *this = a;
41  Add (b);
42 }
43 
44 
47 {
48  return m_devices.begin ();
49 }
52 {
53  return m_devices.end ();
54 }
55 
56 uint32_t
58 {
59  return m_devices.size ();
60 }
62 NetDeviceContainer::Get (uint32_t i) const
63 {
64  return m_devices[i];
65 }
66 void
68 {
69  for (Iterator i = other.Begin (); i != other.End (); i++)
70  {
71  m_devices.push_back (*i);
72  }
73 }
74 void
76 {
77  m_devices.push_back (device);
78 }
79 void
80 NetDeviceContainer::Add (std::string deviceName)
81 {
82  Ptr<NetDevice> device = Names::Find<NetDevice> (deviceName);
83  m_devices.push_back (device);
84 }
85 
86 } // namespace ns3
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
NetDeviceContainer()
Create an empty NetDeviceContainer.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
holds a vector of ns3::NetDevice pointers
std::vector< Ptr< NetDevice > > m_devices
NetDevices smart pointers.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.