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
node-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
#include "
node-container.h
"
20
21
#include "ns3/names.h"
22
#include "ns3/node-list.h"
23
24
namespace
ns3
25
{
26
27
NodeContainer
28
NodeContainer::GetGlobal
()
29
{
30
NodeContainer
c;
31
for
(
NodeList::Iterator
i =
NodeList::Begin
(); i !=
NodeList::End
(); ++i)
32
{
33
c.
Add
(*i);
34
}
35
return
c;
36
}
37
38
NodeContainer::NodeContainer
()
39
{
40
}
41
42
NodeContainer::NodeContainer
(
Ptr<Node>
node)
43
{
44
m_nodes
.push_back(node);
45
}
46
47
NodeContainer::NodeContainer
(std::string nodeName)
48
{
49
Ptr<Node>
node = Names::Find<Node>(nodeName);
50
m_nodes
.push_back(node);
51
}
52
53
NodeContainer::NodeContainer
(
uint32_t
n,
uint32_t
systemId
/* = 0 */
)
54
{
55
m_nodes
.reserve(n);
56
Create
(n, systemId);
57
}
58
59
NodeContainer::Iterator
60
NodeContainer::Begin
()
const
61
{
62
return
m_nodes
.begin();
63
}
64
65
NodeContainer::Iterator
66
NodeContainer::End
()
const
67
{
68
return
m_nodes
.end();
69
}
70
71
uint32_t
72
NodeContainer::GetN
()
const
73
{
74
return
m_nodes
.size();
75
}
76
77
Ptr<Node>
78
NodeContainer::Get
(
uint32_t
i)
const
79
{
80
return
m_nodes
[i];
81
}
82
83
void
84
NodeContainer::Create
(
uint32_t
n)
85
{
86
for
(
uint32_t
i = 0; i < n; i++)
87
{
88
m_nodes
.push_back(CreateObject<Node>());
89
}
90
}
91
92
void
93
NodeContainer::Create
(
uint32_t
n,
uint32_t
systemId)
94
{
95
for
(
uint32_t
i = 0; i < n; i++)
96
{
97
m_nodes
.push_back(CreateObject<Node>(systemId));
98
}
99
}
100
101
void
102
NodeContainer::Add
(
const
NodeContainer
& nc)
103
{
104
for
(
Iterator
i = nc.
Begin
(); i != nc.
End
(); i++)
105
{
106
m_nodes
.push_back(*i);
107
}
108
}
109
110
void
111
NodeContainer::Add
(
Ptr<Node>
node)
112
{
113
m_nodes
.push_back(node);
114
}
115
116
void
117
NodeContainer::Add
(std::string nodeName)
118
{
119
Ptr<Node>
node = Names::Find<Node>(nodeName);
120
m_nodes
.push_back(node);
121
}
122
123
bool
124
NodeContainer::Contains
(
uint32_t
id
)
const
125
{
126
for
(
uint32_t
i = 0; i <
m_nodes
.size(); i++)
127
{
128
if
(
m_nodes
[i]->GetId() ==
id
)
129
{
130
return
true
;
131
}
132
}
133
return
false
;
134
}
135
136
}
// namespace ns3
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:40
ns3::NodeContainer::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition:
node-container.h:43
ns3::NodeContainer::End
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Definition:
node-container.cc:66
ns3::NodeContainer::m_nodes
std::vector< Ptr< Node > > m_nodes
Nodes smart pointers.
Definition:
node-container.h:273
ns3::NodeContainer::GetN
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
Definition:
node-container.cc:72
ns3::NodeContainer::GetGlobal
static NodeContainer GetGlobal()
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
Definition:
node-container.cc:28
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition:
node-container.cc:84
ns3::NodeContainer::Contains
bool Contains(uint32_t id) const
Return true if container contains a Node with index id.
Definition:
node-container.cc:124
ns3::NodeContainer::Add
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Definition:
node-container.cc:102
ns3::NodeContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Definition:
node-container.cc:60
ns3::NodeContainer::NodeContainer
NodeContainer()
Create an empty NodeContainer.
Definition:
node-container.cc:38
ns3::NodeContainer::Get
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Definition:
node-container.cc:78
ns3::NodeList::Begin
static Iterator Begin()
Definition:
node-list.cc:237
ns3::NodeList::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition:
node-list.h:44
ns3::NodeList::End
static Iterator End()
Definition:
node-list.cc:244
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:78
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
node-container.h
src
network
helper
node-container.cc
Generated on Sun Jul 2 2023 18:21:57 for ns-3 by
1.9.6