A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
20
#include "
application-container.h
"
21
22
#include "ns3/log.h"
23
#include "ns3/names.h"
24
25
namespace
ns3
26
{
27
28
NS_LOG_COMPONENT_DEFINE
(
"ApplicationContainer"
);
29
30
ApplicationContainer::ApplicationContainer
()
31
{
32
}
33
34
ApplicationContainer::ApplicationContainer
(
Ptr<Application>
app
)
35
{
36
m_applications
.push_back(
app
);
37
}
38
39
ApplicationContainer::ApplicationContainer
(std::string name)
40
{
41
Ptr<Application>
app
= Names::Find<Application>(name);
42
m_applications
.push_back(
app
);
43
}
44
45
ApplicationContainer::Iterator
46
ApplicationContainer::Begin
()
const
47
{
48
return
m_applications
.begin();
49
}
50
51
ApplicationContainer::Iterator
52
ApplicationContainer::End
()
const
53
{
54
return
m_applications
.end();
55
}
56
57
uint32_t
58
ApplicationContainer::GetN
()
const
59
{
60
return
m_applications
.size();
61
}
62
63
Ptr<Application>
64
ApplicationContainer::Get
(uint32_t i)
const
65
{
66
return
m_applications
[i];
67
}
68
69
void
70
ApplicationContainer::Add
(
ApplicationContainer
other)
71
{
72
for
(
auto
i = other.
Begin
(); i != other.
End
(); i++)
73
{
74
m_applications
.push_back(*i);
75
}
76
}
77
78
void
79
ApplicationContainer::Add
(
Ptr<Application>
application)
80
{
81
m_applications
.push_back(application);
82
}
83
84
void
85
ApplicationContainer::Add
(std::string name)
86
{
87
Ptr<Application>
application = Names::Find<Application>(name);
88
m_applications
.push_back(application);
89
}
90
91
void
92
ApplicationContainer::Start
(
Time
start
)
const
93
{
94
for
(
auto
i =
Begin
(); i !=
End
(); ++i)
95
{
96
Ptr<Application>
app
= *i;
97
app
->SetStartTime(
start
);
98
}
99
}
100
101
void
102
ApplicationContainer::StartWithJitter
(
Time
start
,
Ptr<RandomVariableStream>
rv)
const
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
113
void
114
ApplicationContainer::Stop
(
Time
stop
)
const
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
application-container.h
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition:
application-container.h:44
ns3::ApplicationContainer::m_applications
std::vector< Ptr< Application > > m_applications
Applications smart pointers.
Definition:
application-container.h:228
ns3::ApplicationContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first Application in the container.
Definition:
application-container.cc:46
ns3::ApplicationContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Application in the container.
Definition:
application-container.cc:52
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:92
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:102
ns3::ApplicationContainer::Iterator
std::vector< Ptr< Application > >::const_iterator Iterator
Application container iterator.
Definition:
application-container.h:70
ns3::ApplicationContainer::ApplicationContainer
ApplicationContainer()
Create an empty ApplicationContainer.
Definition:
application-container.cc:30
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:64
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:114
ns3::ApplicationContainer::GetN
uint32_t GetN() const
Get the number of Ptr<Application> stored in this container.
Definition:
application-container.cc:58
ns3::ApplicationContainer::Add
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Definition:
application-container.cc:70
ns3::Ptr< Application >
ns3::RandomVariableStream::GetValue
virtual double GetValue()=0
Get the next random value drawn from the distribution.
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:268
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1326
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
openflow-switch.app
app
Definition:
openflow-switch.py:75
two-ray-to-three-gpp-ch-calibration.start
start
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
two-ray-to-three-gpp-ch-calibration.stop
stop
Definition:
two-ray-to-three-gpp-ch-calibration.py:520
src
network
helper
application-container.cc
Generated on Sun Mar 3 2024 17:11:05 for ns-3 by
1.9.1