A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
network
helper
node-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
#include "
node-container.h
"
21
#include "ns3/node-list.h"
22
#include "ns3/names.h"
23
24
namespace
ns3
{
25
26
NodeContainer::NodeContainer
()
27
{
28
}
29
30
NodeContainer::NodeContainer
(
Ptr<Node>
node)
31
{
32
m_nodes
.push_back (node);
33
}
34
NodeContainer::NodeContainer
(std::string nodeName)
35
{
36
Ptr<Node>
node = Names::Find<Node> (nodeName);
37
m_nodes
.push_back (node);
38
}
39
NodeContainer::NodeContainer
(
const
NodeContainer
&a,
const
NodeContainer
&b)
40
{
41
Add
(a);
42
Add
(b);
43
}
44
NodeContainer::NodeContainer
(
const
NodeContainer
&a,
const
NodeContainer
&b,
45
const
NodeContainer
&c)
46
{
47
Add
(a);
48
Add
(b);
49
Add
(c);
50
}
51
NodeContainer::NodeContainer
(
const
NodeContainer
&a,
const
NodeContainer
&b,
52
const
NodeContainer
&c,
const
NodeContainer
&d)
53
{
54
Add
(a);
55
Add
(b);
56
Add
(c);
57
Add
(d);
58
}
59
60
NodeContainer::NodeContainer
(
const
NodeContainer
&a,
const
NodeContainer
&b,
61
const
NodeContainer
&c,
const
NodeContainer
&d,
62
const
NodeContainer
&e)
63
{
64
Add
(a);
65
Add
(b);
66
Add
(c);
67
Add
(d);
68
Add
(e);
69
}
70
71
NodeContainer::Iterator
72
NodeContainer::Begin
(
void
)
const
73
{
74
return
m_nodes
.begin ();
75
}
76
NodeContainer::Iterator
77
NodeContainer::End
(
void
)
const
78
{
79
return
m_nodes
.end ();
80
}
81
82
uint32_t
83
NodeContainer::GetN
(
void
)
const
84
{
85
return
m_nodes
.size ();
86
}
87
Ptr<Node>
88
NodeContainer::Get
(uint32_t i)
const
89
{
90
return
m_nodes
[i];
91
}
92
void
93
NodeContainer::Create
(uint32_t
n
)
94
{
95
for
(uint32_t i = 0; i <
n
; i++)
96
{
97
m_nodes
.push_back (CreateObject<Node> ());
98
}
99
}
100
void
101
NodeContainer::Create
(uint32_t
n
, uint32_t systemId)
102
{
103
for
(uint32_t i = 0; i <
n
; i++)
104
{
105
m_nodes
.push_back (CreateObject<Node> (systemId));
106
}
107
}
108
void
109
NodeContainer::Add
(
NodeContainer
other)
110
{
111
for
(
Iterator
i = other.
Begin
(); i != other.
End
(); i++)
112
{
113
m_nodes
.push_back (*i);
114
}
115
}
116
void
117
NodeContainer::Add
(
Ptr<Node>
node)
118
{
119
m_nodes
.push_back (node);
120
}
121
void
122
NodeContainer::Add
(std::string nodeName)
123
{
124
Ptr<Node>
node = Names::Find<Node> (nodeName);
125
m_nodes
.push_back (node);
126
}
127
128
NodeContainer
129
NodeContainer::GetGlobal
(
void
)
130
{
131
NodeContainer
c;
132
for
(
NodeList::Iterator
i =
NodeList::Begin
(); i !=
NodeList::End
(); ++i)
133
{
134
c.
Add
(*i);
135
}
136
return
c;
137
}
138
139
bool
140
NodeContainer::Contains
(uint32_t
id
)
const
141
{
142
for
(uint32_t i = 0; i <
m_nodes
.size (); i++)
143
{
144
if
(
m_nodes
[i]->GetId () == id)
145
{
146
return
true
;
147
}
148
}
149
return
false
;
150
}
151
152
}
// namespace ns3
ns3::Ptr< Node >
ns3::NodeContainer::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition:
node-container.h:42
ns3::NodeContainer::m_nodes
std::vector< Ptr< Node > > m_nodes
Nodes smart pointers.
Definition:
node-container.h:300
ns3::NodeContainer::End
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
Definition:
node-container.cc:77
ns3::NodeContainer::Contains
bool Contains(uint32_t id) const
Return true if container contains a Node with index id.
Definition:
node-container.cc:140
sample-rng-plot.n
n
Definition:
sample-rng-plot.py:37
ns3::NodeList::End
static Iterator End(void)
Definition:
node-list.cc:235
ns3::NodeContainer::GetN
uint32_t GetN(void) const
Get the number of Ptr<Node> stored in this container.
Definition:
node-container.cc:83
ns3::NodeContainer::NodeContainer
NodeContainer()
Create an empty NodeContainer.
Definition:
node-container.cc:26
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:38
ns3::NodeList::Iterator
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Definition:
node-list.h:44
ns3::NodeContainer::GetGlobal
static NodeContainer GetGlobal(void)
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
Definition:
node-container.cc:129
ns3::NodeContainer::Add
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
Definition:
node-container.cc:109
ns3::NodeList::Begin
static Iterator Begin(void)
Definition:
node-list.cc:229
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:88
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:93
node-container.h
ns3::NodeContainer::Begin
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
Definition:
node-container.cc:72
Generated on Wed Nov 7 2018 10:02:06 for ns-3 by
1.8.14