author | Vedran Miletić <rivanvx@gmail.com> |
Fri, 19 Apr 2013 22:39:55 +0200 | |
changeset 9703 | 681f35b212ff |
parent 9144 | 6a15c50388bc |
child 10410 | 4d4eb8097fa3 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7182
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
/* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
* |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
* Authors: |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>, |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
*/ |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
|
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
22 |
#include "ns3/simulator.h" |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
23 |
#include "ns3/object-vector.h" |
2532
86a40c7cbfe9
register and unregister the NodeList as a config root namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2480
diff
changeset
|
24 |
#include "ns3/config.h" |
2898
6993ee3fa5a3
add some debugging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
25 |
#include "ns3/log.h" |
3513
fe3945d67a88
Add bounds checking asserts to Node::GetApplication, NodeList::GetNode, and Node::GetDevice.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3290
diff
changeset
|
26 |
#include "ns3/assert.h" |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
#include "node-list.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
28 |
#include "node.h" |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
|
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
namespace ns3 { |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
|
2898
6993ee3fa5a3
add some debugging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
32 |
NS_LOG_COMPONENT_DEFINE ("NodeList"); |
6993ee3fa5a3
add some debugging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
33 |
|
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
34 |
/** |
2943
cdbcd43a019c
add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
35 |
* \brief private implementation detail of the NodeList API. |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
36 |
*/ |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
37 |
class NodeListPriv : public Object |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
38 |
{ |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
39 |
public: |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
40 |
static TypeId GetTypeId (void); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
41 |
NodeListPriv (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
42 |
~NodeListPriv (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
43 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
44 |
uint32_t Add (Ptr<Node> node); |
1383 | 45 |
NodeList::Iterator Begin (void) const; |
46 |
NodeList::Iterator End (void) const; |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
47 |
Ptr<Node> GetNode (uint32_t n); |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
48 |
uint32_t GetNNodes (void); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
49 |
|
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
50 |
static Ptr<NodeListPriv> Get (void); |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
51 |
|
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
52 |
private: |
5872
188ecd74fcb4
It is not legal to call Dispose from within a destructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5524
diff
changeset
|
53 |
virtual void DoDispose (void); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
54 |
static Ptr<NodeListPriv> *DoGet (void); |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
55 |
static void Delete (void); |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
56 |
std::vector<Ptr<Node> > m_nodes; |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
57 |
}; |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
58 |
|
2943
cdbcd43a019c
add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
59 |
NS_OBJECT_ENSURE_REGISTERED (NodeListPriv); |
cdbcd43a019c
add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
60 |
|
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
61 |
TypeId |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
62 |
NodeListPriv::GetTypeId (void) |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
63 |
{ |
2943
cdbcd43a019c
add a few missing ns3:: prefixes in TypeId names.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2933
diff
changeset
|
64 |
static TypeId tid = TypeId ("ns3::NodeListPriv") |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
65 |
.SetParent<Object> () |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
66 |
.AddAttribute ("NodeList", "The list of all nodes created during the simulation.", |
2965
4b28e9740e3b
get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2943
diff
changeset
|
67 |
ObjectVectorValue (), |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
68 |
MakeObjectVectorAccessor (&NodeListPriv::m_nodes), |
2933
c7983cfa2cb3
add ObjectVector::GetItemTypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2898
diff
changeset
|
69 |
MakeObjectVectorChecker<Node> ()) |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
70 |
; |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
71 |
return tid; |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
72 |
} |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
73 |
|
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
74 |
Ptr<NodeListPriv> |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
75 |
NodeListPriv::Get (void) |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
76 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
77 |
NS_LOG_FUNCTION_NOARGS (); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
78 |
return *DoGet (); |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
79 |
} |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
80 |
Ptr<NodeListPriv> * |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
81 |
NodeListPriv::DoGet (void) |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
82 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
83 |
NS_LOG_FUNCTION_NOARGS (); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
84 |
static Ptr<NodeListPriv> ptr = 0; |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
85 |
if (ptr == 0) |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
86 |
{ |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
87 |
ptr = CreateObject<NodeListPriv> (); |
2532
86a40c7cbfe9
register and unregister the NodeList as a config root namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2480
diff
changeset
|
88 |
Config::RegisterRootNamespaceObject (ptr); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
89 |
Simulator::ScheduleDestroy (&NodeListPriv::Delete); |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
90 |
} |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
91 |
return &ptr; |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
92 |
} |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
93 |
void |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
94 |
NodeListPriv::Delete (void) |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
95 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2898
diff
changeset
|
96 |
NS_LOG_FUNCTION_NOARGS (); |
2532
86a40c7cbfe9
register and unregister the NodeList as a config root namespace
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2480
diff
changeset
|
97 |
Config::UnregisterRootNamespaceObject (Get ()); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
98 |
(*DoGet ()) = 0; |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
99 |
} |
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
100 |
|
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
101 |
|
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
102 |
NodeListPriv::NodeListPriv () |
2898
6993ee3fa5a3
add some debugging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
103 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
104 |
NS_LOG_FUNCTION (this); |
2898
6993ee3fa5a3
add some debugging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2834
diff
changeset
|
105 |
} |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
106 |
NodeListPriv::~NodeListPriv () |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
107 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
108 |
NS_LOG_FUNCTION (this); |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
109 |
} |
5872
188ecd74fcb4
It is not legal to call Dispose from within a destructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5524
diff
changeset
|
110 |
void |
188ecd74fcb4
It is not legal to call Dispose from within a destructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5524
diff
changeset
|
111 |
NodeListPriv::DoDispose (void) |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
112 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
113 |
NS_LOG_FUNCTION (this); |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
114 |
for (std::vector<Ptr<Node> >::iterator i = m_nodes.begin (); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
115 |
i != m_nodes.end (); i++) |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
116 |
{ |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
117 |
Ptr<Node> node = *i; |
485
152927527647
rename NodeList::GetNode to NodeList::PeekNode to avoid memory leaks. Call Dispose from NodeListPriv::~NodeListPriv
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
484
diff
changeset
|
118 |
node->Dispose (); |
551
12ed30c77cab
revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
546
diff
changeset
|
119 |
*i = 0; |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
120 |
} |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
121 |
m_nodes.erase (m_nodes.begin (), m_nodes.end ()); |
5872
188ecd74fcb4
It is not legal to call Dispose from within a destructor
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
5524
diff
changeset
|
122 |
Object::DoDispose (); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
123 |
} |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
124 |
|
359
91b7ad7fa784
OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
125 |
|
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
126 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
127 |
NodeListPriv::Add (Ptr<Node> node) |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
128 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
129 |
NS_LOG_FUNCTION (this << node); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
130 |
uint32_t index = m_nodes.size (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
131 |
m_nodes.push_back (node); |
9703
681f35b212ff
Rename Start and DoStart methods to Initialize and DoInitialize
Vedran Miletić <rivanvx@gmail.com>
parents:
9144
diff
changeset
|
132 |
Simulator::ScheduleWithContext (index, TimeStep (0), &Node::Initialize, node); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
133 |
return index; |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6823
diff
changeset
|
134 |
|
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
135 |
} |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
136 |
NodeList::Iterator |
1383 | 137 |
NodeListPriv::Begin (void) const |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
138 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
139 |
NS_LOG_FUNCTION (this); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
140 |
return m_nodes.begin (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
141 |
} |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
142 |
NodeList::Iterator |
1383 | 143 |
NodeListPriv::End (void) const |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
144 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
145 |
NS_LOG_FUNCTION (this); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
146 |
return m_nodes.end (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
147 |
} |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
148 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
149 |
NodeListPriv::GetNNodes (void) |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
150 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
151 |
NS_LOG_FUNCTION (this); |
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
152 |
return m_nodes.size (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
153 |
} |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
154 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
155 |
Ptr<Node> |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
156 |
NodeListPriv::GetNode (uint32_t n) |
564
4da6cc2af83f
make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
562
diff
changeset
|
157 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
158 |
NS_LOG_FUNCTION (this << n); |
3513
fe3945d67a88
Add bounds checking asserts to Node::GetApplication, NodeList::GetNode, and Node::GetDevice.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3290
diff
changeset
|
159 |
NS_ASSERT_MSG (n < m_nodes.size (), "Node index " << n << |
fe3945d67a88
Add bounds checking asserts to Node::GetApplication, NodeList::GetNode, and Node::GetDevice.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3290
diff
changeset
|
160 |
" is out of range (only have " << m_nodes.size () << " nodes)."); |
564
4da6cc2af83f
make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
562
diff
changeset
|
161 |
return m_nodes[n]; |
4da6cc2af83f
make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
562
diff
changeset
|
162 |
} |
4da6cc2af83f
make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
562
diff
changeset
|
163 |
|
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
164 |
} |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
165 |
|
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
166 |
/** |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
167 |
* The implementation of the public static-based API |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
168 |
* which calls into the private implementation through |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
169 |
* the simulation singleton. |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
170 |
*/ |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
171 |
namespace ns3 { |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
172 |
|
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
425
diff
changeset
|
173 |
uint32_t |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
174 |
NodeList::Add (Ptr<Node> node) |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
175 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
176 |
NS_LOG_FUNCTION (node); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
177 |
return NodeListPriv::Get ()->Add (node); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
178 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
179 |
NodeList::Iterator |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
180 |
NodeList::Begin (void) |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
181 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
182 |
NS_LOG_FUNCTION_NOARGS (); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
183 |
return NodeListPriv::Get ()->Begin (); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
184 |
} |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
185 |
NodeList::Iterator |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
186 |
NodeList::End (void) |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
187 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
188 |
NS_LOG_FUNCTION_NOARGS (); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
189 |
return NodeListPriv::Get ()->End (); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
190 |
} |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
191 |
Ptr<Node> |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
192 |
NodeList::GetNode (uint32_t n) |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
193 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
194 |
NS_LOG_FUNCTION (n); |
2480
2538b244b3c7
convert NodeList to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1420
diff
changeset
|
195 |
return NodeListPriv::Get ()->GetNode (n); |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
196 |
} |
3290
3167a20f9cf0
GetNNodes() in NodeList fixes bug 225
craigdo@craig-dowells-imac.local
parents:
2989
diff
changeset
|
197 |
uint32_t |
3167a20f9cf0
GetNNodes() in NodeList fixes bug 225
craigdo@craig-dowells-imac.local
parents:
2989
diff
changeset
|
198 |
NodeList::GetNNodes (void) |
3167a20f9cf0
GetNNodes() in NodeList fixes bug 225
craigdo@craig-dowells-imac.local
parents:
2989
diff
changeset
|
199 |
{ |
9144
6a15c50388bc
Clean up function logging of network module.
Maja Grubišić <maja.grubisic@live.com>
parents:
7386
diff
changeset
|
200 |
NS_LOG_FUNCTION_NOARGS (); |
3290
3167a20f9cf0
GetNNodes() in NodeList fixes bug 225
craigdo@craig-dowells-imac.local
parents:
2989
diff
changeset
|
201 |
return NodeListPriv::Get ()->GetNNodes (); |
3167a20f9cf0
GetNNodes() in NodeList fixes bug 225
craigdo@craig-dowells-imac.local
parents:
2989
diff
changeset
|
202 |
} |
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
203 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
204 |
} // namespace ns3 |