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