A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
application-container.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7
*/
8
9
#include "
application-container.h
"
10
11
#include "ns3/log.h"
12
#include "ns3/names.h"
13
14
namespace
ns3
15
{
16
17
NS_LOG_COMPONENT_DEFINE
(
"ApplicationContainer"
);
18
19
ApplicationContainer::ApplicationContainer
()
20
{
21
}
22
23
ApplicationContainer::ApplicationContainer
(
Ptr<Application>
app)
24
{
25
m_applications
.push_back(app);
26
}
27
28
ApplicationContainer::ApplicationContainer
(std::string name)
29
{
30
Ptr<Application>
app =
Names::Find<Application>
(name);
31
m_applications
.push_back(app);
32
}
33
34
ApplicationContainer::Iterator
35
ApplicationContainer::Begin
()
const
36
{
37
return
m_applications
.begin();
38
}
39
40
ApplicationContainer::Iterator
41
ApplicationContainer::End
()
const
42
{
43
return
m_applications
.end();
44
}
45
46
uint32_t
47
ApplicationContainer::GetN
()
const
48
{
49
return
m_applications
.size();
50
}
51
52
Ptr<Application>
53
ApplicationContainer::Get
(
uint32_t
i)
const
54
{
55
return
m_applications
[i];
56
}
57
58
void
59
ApplicationContainer::Add
(
ApplicationContainer
other)
60
{
61
for
(
auto
i = other.
Begin
(); i != other.
End
(); i++)
62
{
63
m_applications
.push_back(*i);
64
}
65
}
66
67
void
68
ApplicationContainer::Add
(
Ptr<Application>
application)
69
{
70
m_applications
.push_back(application);
71
}
72
73
void
74
ApplicationContainer::Add
(std::string name)
75
{
76
Ptr<Application>
application =
Names::Find<Application>
(name);
77
m_applications
.push_back(application);
78
}
79
80
void
81
ApplicationContainer::Start
(
Time
start)
const
82
{
83
for
(
auto
i =
Begin
(); i !=
End
(); ++i)
84
{
85
Ptr<Application>
app = *i;
86
app->SetStartTime(start);
87
}
88
}
89
90
void
91
ApplicationContainer::StartWithJitter
(
Time
start,
Ptr<RandomVariableStream>
rv)
const
92
{
93
for
(
auto
i =
Begin
(); i !=
End
(); ++i)
94
{
95
Ptr<Application>
app = *i;
96
double
value = rv->GetValue();
97
NS_LOG_DEBUG
(
"Start application at time "
<< start.GetSeconds() + value <<
"s"
);
98
app->SetStartTime(start +
Seconds
(value));
99
}
100
}
101
102
void
103
ApplicationContainer::Stop
(
Time
stop)
const
104
{
105
for
(
auto
i =
Begin
(); i !=
End
(); ++i)
106
{
107
Ptr<Application>
app = *i;
108
app->SetStopTime(stop);
109
}
110
}
111
112
}
// namespace ns3
application-container.h
ns3::ApplicationContainer
holds a vector of ns3::Application pointers.
Definition
application-container.h:33
ns3::ApplicationContainer::m_applications
std::vector< Ptr< Application > > m_applications
Applications smart pointers.
Definition
application-container.h:217
ns3::ApplicationContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first Application in the container.
Definition
application-container.cc:35
ns3::ApplicationContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Application in the container.
Definition
application-container.cc:41
ns3::ApplicationContainer::Iterator
std::vector< Ptr< Application > >::const_iterator Iterator
Application container iterator.
Definition
application-container.h:59
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:81
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:91
ns3::ApplicationContainer::ApplicationContainer
ApplicationContainer()
Create an empty ApplicationContainer.
Definition
application-container.cc:19
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:53
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:103
ns3::ApplicationContainer::GetN
uint32_t GetN() const
Get the number of Ptr<Application> stored in this container.
Definition
application-container.cc:47
ns3::ApplicationContainer::Add
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Definition
application-container.cc:59
ns3::Names::Find
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition
names.h:443
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition
nstime.h:1344
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
network
helper
application-container.cc
Generated on Fri Dec 13 2024 18:20:46 for ns-3 by
1.11.0