A Discrete-Event Network Simulator
API
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 (Iterator 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 (Iterator i = Begin(); i != End(); ++i)
95 {
96 Ptr<Application> app = *i;
97 app->SetStartTime(start);
98 }
99}
100
101void
103{
104 for (Iterator 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");
110 }
111}
112
113void
115{
116 for (Iterator 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.
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 Start(Time start)
Start all of the Applications in this container at the start time given as a parameter.
void StartWithJitter(Time start, Ptr< RandomVariableStream > rv)
Start all of the Applications in this container at the start 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.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:78
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:71
virtual double GetValue()=0
Get the next random value as a double drawn from the distribution.
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:1336
Every class exported by the ns3 library is enclosed in the ns3 namespace.
value
Definition: second.py:41
def start()
Definition: core.py:1864