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