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