A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
application-container.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#include "ns3/names.h"
22
#include "ns3/log.h"
23
#include "
application-container.h
"
24
25
namespace
ns3
{
26
27
NS_LOG_COMPONENT_DEFINE
(
"ApplicationContainer"
);
28
29
ApplicationContainer::ApplicationContainer
()
30
{
31
}
32
33
ApplicationContainer::ApplicationContainer
(
Ptr<Application>
app)
34
{
35
m_applications
.push_back (app);
36
}
37
38
ApplicationContainer::ApplicationContainer
(std::string name)
39
{
40
Ptr<Application>
app = Names::Find<Application> (name);
41
m_applications
.push_back (app);
42
}
43
44
45
ApplicationContainer::Iterator
46
ApplicationContainer::Begin
(
void
)
const
47
{
48
return
m_applications
.begin ();
49
}
50
ApplicationContainer::Iterator
51
ApplicationContainer::End
(
void
)
const
52
{
53
return
m_applications
.end ();
54
}
55
56
uint32_t
57
ApplicationContainer::GetN
(
void
)
const
58
{
59
return
m_applications
.size ();
60
}
61
Ptr<Application>
62
ApplicationContainer::Get
(uint32_t i)
const
63
{
64
return
m_applications
[i];
65
}
66
void
67
ApplicationContainer::Add
(
ApplicationContainer
other)
68
{
69
for
(
Iterator
i = other.
Begin
(); i != other.
End
(); i++)
70
{
71
m_applications
.push_back (*i);
72
}
73
}
74
void
75
ApplicationContainer::Add
(
Ptr<Application>
application)
76
{
77
m_applications
.push_back (application);
78
}
79
void
80
ApplicationContainer::Add
(std::string name)
81
{
82
Ptr<Application>
application = Names::Find<Application> (name);
83
m_applications
.push_back (application);
84
}
85
86
void
87
ApplicationContainer::Start
(
Time
start
)
88
{
89
for
(
Iterator
i =
Begin
(); i !=
End
(); ++i)
90
{
91
Ptr<Application>
app = *i;
92
app->
SetStartTime
(
start
);
93
}
94
}
95
void
96
ApplicationContainer::StartWithJitter
(
Time
start
,
Ptr<RandomVariableStream>
rv)
97
{
98
for
(
Iterator
i =
Begin
(); i !=
End
(); ++i)
99
{
100
Ptr<Application>
app = *i;
101
double
value = rv->
GetValue
();
102
NS_LOG_DEBUG
(
"Start application at time "
<<
start
.GetSeconds () + value <<
"s"
);
103
app->
SetStartTime
(
start
+
Seconds
(value));
104
}
105
}
106
void
107
ApplicationContainer::Stop
(
Time
stop)
108
{
109
for
(
Iterator
i =
Begin
(); i !=
End
(); ++i)
110
{
111
Ptr<Application>
app = *i;
112
app->
SetStopTime
(stop);
113
}
114
}
115
116
117
}
// namespace ns3
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
ns3::ApplicationContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Application in the container.
Definition:
application-container.cc:51
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:62
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ApplicationContainer::Stop
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
Definition:
application-container.cc:107
ns3::ApplicationContainer::m_applications
std::vector< Ptr< Application > > m_applications
Applications smart pointers.
Definition:
application-container.h:227
ns3::ApplicationContainer::Iterator
std::vector< Ptr< Application > >::const_iterator Iterator
Application container iterator.
Definition:
application-container.h:69
ns3::ApplicationContainer::Add
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Definition:
application-container.cc:67
ns3::ApplicationContainer::ApplicationContainer
ApplicationContainer()
Create an empty ApplicationContainer.
Definition:
application-container.cc:29
ns3::ApplicationContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first Application in the container.
Definition:
application-container.cc:46
ns3::Application::SetStopTime
void SetStopTime(Time stop)
Specify application stop time.
Definition:
application.cc:75
ns3::Ptr< Application >
visualizer.core.start
def start()
Definition:
core.py:1855
ns3::Application::SetStartTime
void SetStartTime(Time start)
Specify application start time.
Definition:
application.cc:69
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:104
ns3::ApplicationContainer::GetN
uint32_t GetN(void) const
Get the number of Ptr<Application> stored in this container.
Definition:
application-container.cc:57
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:273
ns3::RandomVariableStream::GetValue
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
ns3::ApplicationContainer::Start
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Definition:
application-container.cc:87
application-container.h
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1289
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition:
application-container.h:43
ns3::ApplicationContainer::StartWithJitter
void StartWithJitter(Time start, Ptr< RandomVariableStream > rv)
Start all of the Applications in this container at the start time given as a parameter,...
Definition:
application-container.cc:96
src
network
helper
application-container.cc
Generated on Fri Oct 1 2021 17:03:28 for ns-3 by
1.8.20