A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
net-device-container.h
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
#ifndef NET_DEVICE_CONTAINER_H
20
#define NET_DEVICE_CONTAINER_H
21
22
#include "ns3/net-device.h"
23
24
#include <stdint.h>
25
#include <vector>
26
27
namespace
ns3
28
{
29
30
/**
31
* \brief holds a vector of ns3::NetDevice pointers
32
*
33
* Typically ns-3 NetDevices are installed on nodes using a net device
34
* helper. The helper Install method takes a NodeContainer which holds
35
* some number of Ptr<Node>. For each of the Nodes in the NodeContainer
36
* the helper will instantiate a net device, add a MAC address and a queue
37
* to the device and install it to the node. For each of the devices, the
38
* helper also adds the device into a Container for later use by the caller.
39
* This is that container used to hold the Ptr<NetDevice> which are
40
* instantiated by the device helper.
41
*/
42
class
NetDeviceContainer
43
{
44
public
:
45
/// NetDevice container iterator
46
typedef
std::vector<Ptr<NetDevice>>::const_iterator
Iterator
;
47
48
/**
49
* Create an empty NetDeviceContainer.
50
*/
51
NetDeviceContainer
();
52
53
/**
54
* \param dev a device to add to the container
55
*
56
* Create a NetDeviceContainer with exactly one net device that has previously
57
* been instantiated
58
*/
59
NetDeviceContainer
(
Ptr<NetDevice>
dev);
60
61
/**
62
* Create a NetDeviceContainer with exactly one device which has been
63
* previously instantiated and assigned a name using the Object name
64
* service. This NetDevice is specified by its assigned name.
65
*
66
* \param devName The name of the device to add to the container
67
*
68
* Create a NetDeviceContainer with exactly one device
69
*/
70
NetDeviceContainer
(std::string devName);
71
72
/**
73
* \param a a device container
74
* \param b another device container
75
*
76
* Create a device container which is a concatenation of the two input
77
* NetDeviceContainers.
78
*
79
* \note A frequently seen idiom that uses these constructors involves the
80
* implicit conversion by constructor of Ptr<NetDevice>. When used, two
81
* Ptr<NetDevice> will be passed to this constructor instead of NetDeviceContainer&.
82
* C++ will notice the implicit conversion path that goes through the
83
* NetDeviceContainer (Ptr<NetDevice> dev) constructor above. Using this conversion
84
* one may provide optionally provide arguments of Ptr<NetDevice> to these
85
* constructors.
86
*/
87
NetDeviceContainer
(
const
NetDeviceContainer
& a,
const
NetDeviceContainer
& b);
88
89
/**
90
* \brief Get an iterator which refers to the first NetDevice in the
91
* container.
92
*
93
* NetDevices can be retrieved from the container in two ways. First,
94
* directly by an index into the container, and second, using an iterator.
95
* This method is used in the iterator method and is typically used in a
96
* for-loop to run through the NetDevices
97
*
98
* \code
99
* NetDeviceContainer::Iterator i;
100
* for (i = container.Begin (); i != container.End (); ++i)
101
* {
102
* (*i)->method (); // some NetDevice method
103
* }
104
* \endcode
105
*
106
* \returns an iterator which refers to the first NetDevice in the container.
107
*/
108
Iterator
Begin
()
const
;
109
110
/**
111
* \brief Get an iterator which indicates past-the-last NetDevice in the
112
* container.
113
*
114
* NetDevices can be retrieved from the container in two ways. First,
115
* directly by an index into the container, and second, using an iterator.
116
* This method is used in the iterator method and is typically used in a
117
* for-loop to run through the NetDevices
118
*
119
* \code
120
* NetDeviceContainer::Iterator i;
121
* for (i = container.Begin (); i != container.End (); ++i)
122
* {
123
* (*i)->method (); // some NetDevice method
124
* }
125
* \endcode
126
*
127
* \returns an iterator which indicates an ending condition for a loop.
128
*/
129
Iterator
End
()
const
;
130
131
/**
132
* \brief Get the number of Ptr<NetDevice> stored in this container.
133
*
134
* NetDevices can be retrieved from the container in two ways. First,
135
* directly by an index into the container, and second, using an iterator.
136
* This method is used in the direct method and is typically used to
137
* define an ending condition in a for-loop that runs through the stored
138
* NetDevices
139
*
140
* \code
141
* uint32_t nDevices = container.GetN ();
142
* for (uint32_t i = 0 i < nDevices; ++i)
143
* {
144
* Ptr<NetDevice> p = container.Get (i)
145
* i->method (); // some NetDevice method
146
* }
147
* \endcode
148
*
149
* \returns the number of Ptr<NetDevice> stored in this container.
150
*/
151
uint32_t
GetN
()
const
;
152
153
/**
154
* \brief Get the Ptr<NetDevice> stored in this container at a given
155
* index.
156
*
157
* NetDevices can be retrieved from the container in two ways. First,
158
* directly by an index into the container, and second, using an iterator.
159
* This method is used in the direct method and is used to retrieve the
160
* indexed Ptr<NetDevice>.
161
*
162
* \code
163
* uint32_t nDevices = container.GetN ();
164
* for (uint32_t i = 0 i < nDevices; ++i)
165
* {
166
* Ptr<NetDevice> p = container.Get (i)
167
* i->method (); // some NetDevice method
168
* }
169
* \endcode
170
*
171
* \param i the index of the requested device pointer.
172
* \returns the requested device pointer.
173
*/
174
Ptr<NetDevice>
Get
(
uint32_t
i)
const
;
175
176
/**
177
* \brief Append the contents of another NetDeviceContainer to the end of
178
* this container.
179
*
180
* \param other The NetDeviceContainer to append.
181
*/
182
void
Add
(
NetDeviceContainer
other);
183
184
/**
185
* \brief Append a single Ptr<NetDevice> to this container.
186
*
187
* \param device The Ptr<NetDevice> to append.
188
*/
189
void
Add
(
Ptr<NetDevice>
device);
190
191
/**
192
* \brief Append to this container the single Ptr<NetDevice> referred to
193
* via its object name service registered name.
194
*
195
* \param deviceName The name of the NetDevice Object to add to the container.
196
*/
197
void
Add
(std::string deviceName);
198
199
private
:
200
std::vector<Ptr<NetDevice>>
m_devices
;
//!< NetDevices smart pointers
201
};
202
203
}
// namespace ns3
204
205
#endif
/* NET_DEVICE_CONTAINER_H */
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition:
net-device-container.h:43
ns3::NetDeviceContainer::GetN
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
Definition:
net-device-container.cc:61
ns3::NetDeviceContainer::Iterator
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Definition:
net-device-container.h:46
ns3::NetDeviceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Definition:
net-device-container.cc:49
ns3::NetDeviceContainer::Add
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Definition:
net-device-container.cc:73
ns3::NetDeviceContainer::m_devices
std::vector< Ptr< NetDevice > > m_devices
NetDevices smart pointers.
Definition:
net-device-container.h:200
ns3::NetDeviceContainer::End
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Definition:
net-device-container.cc:55
ns3::NetDeviceContainer::Get
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Definition:
net-device-container.cc:67
ns3::NetDeviceContainer::NetDeviceContainer
NetDeviceContainer()
Create an empty NetDeviceContainer.
Definition:
net-device-container.cc:27
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
helper
net-device-container.h
Generated on Tue May 28 2024 23:38:28 for ns-3 by
1.9.6