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
application-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
9
#ifndef APPLICATION_CONTAINER_H
10
#define APPLICATION_CONTAINER_H
11
12
#include "ns3/application.h"
13
#include "ns3/random-variable-stream.h"
14
15
#include <stdint.h>
16
#include <vector>
17
18
namespace
ns3
19
{
20
21
/**
22
* @brief holds a vector of ns3::Application pointers.
23
*
24
* Typically ns-3 Applications are installed on nodes using an Application
25
* helper. The helper Install method takes a NodeContainer which holds
26
* some number of Ptr<Node>. For each of the Nodes in the NodeContainer
27
* the helper will instantiate an application, install it in a node and
28
* add a Ptr<Application> to that application into a Container for use
29
* by the caller. This is that container used to hold the Ptr<Application>
30
* which are instantiated by the Application helper.
31
*/
32
class
ApplicationContainer
33
{
34
public
:
35
/**
36
* Create an empty ApplicationContainer.
37
*/
38
ApplicationContainer
();
39
40
/**
41
* Create an ApplicationContainer with exactly one application which has
42
* been previously instantiated. The single application is specified
43
* by a smart pointer.
44
*
45
* @param application The Ptr<Application> to add to the container.
46
*/
47
ApplicationContainer
(
Ptr<Application>
application);
48
49
/**
50
* Create an ApplicationContainer with exactly one application which has
51
* been previously instantiated and assigned a name using the Object Name
52
* Service. This Application is then specified by its assigned name.
53
*
54
* @param name The name of the Application Object to add to the container.
55
*/
56
ApplicationContainer
(std::string name);
57
58
/// Application container iterator
59
typedef
std::vector<Ptr<Application>>::const_iterator
Iterator
;
60
61
/**
62
* @brief Get an iterator which refers to the first Application in the
63
* container.
64
*
65
* Applications can be retrieved from the container in two ways. First,
66
* directly by an index into the container, and second, using an iterator.
67
* This method is used in the iterator method and is typically used in a
68
* for-loop to run through the Applications
69
*
70
* @code
71
* for (auto i = container.Begin(); i != container.End(); ++i)
72
* {
73
* (*i)->method(); // some Application method
74
* }
75
* @endcode
76
*
77
* @returns an iterator which refers to the first Application in the container.
78
*/
79
Iterator
Begin
()
const
;
80
81
/**
82
* @brief Get an iterator which indicates past-the-last Application in the
83
* container.
84
*
85
* Applications can be retrieved from the container in two ways. First,
86
* directly by an index into the container, and second, using an iterator.
87
* This method is used in the iterator method and is typically used in a
88
* for-loop to run through the Applications
89
*
90
* @code
91
* for (auto i = container.Begin(); i != container.End(); ++i)
92
* {
93
* (*i)->method(); // some Application method
94
* }
95
* @endcode
96
*
97
* @returns an iterator which indicates an ending condition for a loop.
98
*/
99
Iterator
End
()
const
;
100
101
/**
102
* @brief Get the number of Ptr<Application> stored in this container.
103
*
104
* Applications can be retrieved from the container in two ways. First,
105
* directly by an index into the container, and second, using an iterator.
106
* This method is used in the direct method and is typically used to
107
* define an ending condition in a for-loop that runs through the stored
108
* Applications
109
*
110
* @code
111
* uint32_t nApplications = container.GetN ();
112
* for (uint32_t i = 0 i < nApplications; ++i)
113
* {
114
* Ptr<Application> p = container.Get (i)
115
* i->method (); // some Application method
116
* }
117
* @endcode
118
*
119
* @returns the number of Ptr<Application> stored in this container.
120
*/
121
uint32_t
GetN
()
const
;
122
123
/**
124
* @brief Get the Ptr<Application> stored in this container at a given
125
* index.
126
*
127
* Applications can be retrieved from the container in two ways. First,
128
* directly by an index into the container, and second, using an iterator.
129
* This method is used in the direct method and is used to retrieve the
130
* indexed Ptr<Application>.
131
*
132
* @code
133
* uint32_t nApplications = container.GetN ();
134
* for (uint32_t i = 0 i < nApplications; ++i)
135
* {
136
* Ptr<Application> p = container.Get (i)
137
* i->method (); // some Application method
138
* }
139
* @endcode
140
*
141
* @param i the index of the requested application pointer.
142
* @returns the requested application pointer.
143
*/
144
Ptr<Application>
Get
(
uint32_t
i)
const
;
145
146
/**
147
* @brief Append the contents of another ApplicationContainer to the end of
148
* this container.
149
*
150
* @param other The ApplicationContainer to append.
151
*/
152
void
Add
(
ApplicationContainer
other);
153
154
/**
155
* @brief Append a single Ptr<Application> to this container.
156
*
157
* @param application The Ptr<Application> to append.
158
*/
159
void
Add
(
Ptr<Application>
application);
160
161
/**
162
* @brief Append to this container the single Ptr<Application> referred to
163
* via its object name service registered name.
164
*
165
* @param name The name of the Application Object to add to the container.
166
*/
167
void
Add
(std::string name);
168
169
/**
170
* @brief Start all of the Applications in this container at the start time
171
* given as a parameter.
172
*
173
* All Applications need to be provided with a starting simulation time and
174
* a stopping simulation time. The ApplicationContainer is a convenient
175
* place for allowing all of the contained Applications to be told to wake
176
* up and start doing their thing (Start) at a common time.
177
*
178
* This method simply iterates through the contained Applications and calls
179
* their Application::SetStartTime() methods with the provided Time.
180
*
181
* @param start The Time at which each of the applications should start.
182
*/
183
void
Start
(
Time
start)
const
;
184
185
/**
186
* @brief Start all of the Applications in this container at the start time
187
* given as a parameter, plus some jitter.
188
*
189
* This method iterates through the contained Applications and calls
190
* their Application::SetStartTime() methods with the provided start Time, plus
191
* a jitter value drawn from the provided random variable.
192
*
193
* @param start The Time at which each of the applications should start.
194
* @param rv The random variable that adds jitter (units of seconds)
195
*/
196
void
StartWithJitter
(
Time
start,
Ptr<RandomVariableStream>
rv)
const
;
197
198
/**
199
* @brief Arrange for all of the Applications in this container to Stop()
200
* at the Time given as a parameter.
201
*
202
* All Applications need to be provided with a starting simulation time and
203
* a stopping simulation time. The ApplicationContainer is a convenient
204
* place for allowing all of the contained Applications to be told to shut
205
* down and stop doing their thing (Stop) at a common time.
206
*
207
* This method simply iterates through the contained Applications and calls
208
* their Application::SetStopTime() methods with the provided Time.
209
*
210
* @param stop The Time at which each of the applications should stop.
211
*/
212
void
Stop
(
Time
stop)
const
;
213
214
private
:
215
std::vector<Ptr<Application>>
m_applications
;
//!< Applications smart pointers
216
};
217
218
}
// namespace ns3
219
220
#endif
/* APPLICATION_CONTAINER_H */
ns3::ApplicationContainer::m_applications
std::vector< Ptr< Application > > m_applications
Applications smart pointers.
Definition
application-container.h:215
ns3::ApplicationContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first Application in the container.
Definition
application-container.cc:35
ns3::ApplicationContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Application in the container.
Definition
application-container.cc:41
ns3::ApplicationContainer::Iterator
std::vector< Ptr< Application > >::const_iterator Iterator
Application container iterator.
Definition
application-container.h:59
ns3::ApplicationContainer::Start
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
Definition
application-container.cc:81
ns3::ApplicationContainer::StartWithJitter
void StartWithJitter(Time start, Ptr< RandomVariableStream > rv) const
Start all of the Applications in this container at the start time given as a parameter,...
Definition
application-container.cc:91
ns3::ApplicationContainer::ApplicationContainer
ApplicationContainer()
Create an empty ApplicationContainer.
Definition
application-container.cc:19
ns3::ApplicationContainer::Get
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
Definition
application-container.cc:53
ns3::ApplicationContainer::Stop
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Definition
application-container.cc:103
ns3::ApplicationContainer::GetN
uint32_t GetN() const
Get the number of Ptr<Application> stored in this container.
Definition
application-container.cc:47
ns3::ApplicationContainer::Add
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Definition
application-container.cc:59
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:96
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
helper
application-container.h
Generated on
for ns-3 by
1.15.0