A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
application-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
21
22#include "ns3/log.h"
23#include "ns3/names.h"
24
25namespace ns3
26{
27
28NS_LOG_COMPONENT_DEFINE("ApplicationContainer");
29
31{
32}
33
35{
36 m_applications.push_back(app);
37}
38
40{
41 Ptr<Application> app = Names::Find<Application>(name);
42 m_applications.push_back(app);
43}
44
47{
48 return m_applications.begin();
49}
50
53{
54 return m_applications.end();
55}
56
59{
60 return m_applications.size();
61}
62
65{
66 return m_applications[i];
67}
68
69void
71{
72 for (auto i = other.Begin(); i != other.End(); i++)
73 {
74 m_applications.push_back(*i);
75 }
76}
77
78void
80{
81 m_applications.push_back(application);
82}
83
84void
86{
87 Ptr<Application> application = Names::Find<Application>(name);
88 m_applications.push_back(application);
89}
90
91void
93{
94 for (auto i = Begin(); i != End(); ++i)
95 {
96 Ptr<Application> app = *i;
97 app->SetStartTime(start);
98 }
99}
100
101void
103{
104 for (auto i = Begin(); i != End(); ++i)
105 {
106 Ptr<Application> app = *i;
107 double value = rv->GetValue();
108 NS_LOG_DEBUG("Start application at time " << start.GetSeconds() + value << "s");
109 app->SetStartTime(start + Seconds(value));
110 }
111}
112
113void
115{
116 for (auto i = Begin(); i != End(); ++i)
117 {
118 Ptr<Application> app = *i;
119 app->SetStopTime(stop);
120 }
121}
122
123} // namespace ns3
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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.