author | Tom Henderson <tomh@tomh.org> |
Tue, 27 Mar 2007 21:48:22 -0700 | |
changeset 381 | 83b52d112c99 |
parent 361 | 9b159ff6dbcb |
child 447 | 180117abfb04 |
permissions | -rw-r--r-- |
233
6b60d7b27ae4
change emacs style commands
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
232
diff
changeset
|
1 |
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
// Copyright (c) 2006 Georgia Tech Research Corporation |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
// All rights reserved. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
// This program is free software; you can redistribute it and/or modify |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
// it under the terms of the GNU General Public License version 2 as |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
// published by the Free Software Foundation; |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
// This program is distributed in the hope that it will be useful, |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
// GNU General Public License for more details. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
// You should have received a copy of the GNU General Public License |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
// along with this program; if not, write to the Free Software |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
// Author: George F. Riley<riley@ece.gatech.edu> |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
|
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
// Define the basic Node object for ns3. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
// George F. Riley, Georgia Tech, Fall 2006 |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
|
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
// The Node class is the building block for all network element definitions |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
// in ns3. The design approach is to create a node object by including |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
// one or mode "node capabilities", selecting the capabilities based on |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
// the desired features and behavior of a node. For example, an |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
// "InternetNode" has capabilities for a list of network devices, a layer 3 |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
// protocol list, a layer 4 protocol list, and a list of processs. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
// A "SensorNode" has a list of network devices, a list of "Sensors", and |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
// an energy model. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
// To create a new node class, perform the following steps. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
// 1) Create your node subclass as a direct descendent of the Node base class. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
// 2) Add members to your node subclass that are pointers to each of the |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
// node capabilities you need. We use pointers here rather than direct |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
// objects, since you might want a SensorNode with a specific energy |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
// model that derives from the base EnergyModel capability. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
// 3) Override each of the "Get*" virtual member functions of the Node base |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
// class to return the appropriate pointer to each capability. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
// 4) Implement a copy constructor that calls the "Copy" method on each |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
// capability in your class. Do NOT just copy the pointers, as this will |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
// result in "double delete". |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
// 5) Implement a destructor that deletes each of your capabilities. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
// 6) Implement a Copy() method that returns a copy of your node. This |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
// is usually just one line of code, calling "new" and specifying the |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
// copy constructor. See the Copy method in InternetNode for an example. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
// To implement a new Capability, perform the following steps: |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
// 1) Create your new capability class as a direct descendent of the |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
// NodeCapability base class. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
// 2) If needed, implement a copy constructor. This is typically only |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
// needed if your capability does dynamic memory management (ie. new |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
// and delete). |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
// 3) If needed, implement a destructor. Again, this is typically only |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
// needed if you use dynamic memory. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
// 4) Implement a Copy() method that returns a copy of your capability. |
361
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
61 |
// 5) Implement a "Get*" virtual method in the node base that returns |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
// the null capability. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
// To implement a variation on an existing capability, perform |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
// the following steps: |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
// 1) Create your new capability as a subclass of an existing capability. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
68 |
// 2) Override the capability members as needed to implement the desired |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
69 |
// behavior. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
70 |
// 3) Override the Copy() method to create a copy of your capability |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
// subclass. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
// |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
73 |
// The design team for ns3 expects that the number of different node |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
74 |
// capabilities will remain relatively small over time. Contributors |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
75 |
// and those modifying ns3 for their own uses are encouraged to subclass |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
// an existing capability where possible. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
|
361
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
78 |
#ifndef __NODE_H__ |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
79 |
#define __NODE_H__ |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
|
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
#include <vector> |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
82 |
#include <list> |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
83 |
|
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
84 |
#include "ns3/smartvector.h" |
361
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
85 |
#include "ns3/smartset.h" |
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
86 |
|
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
87 |
namespace ns3 { |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
88 |
|
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
361
diff
changeset
|
89 |
class NodeList; |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
361
diff
changeset
|
90 |
|
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
361
diff
changeset
|
91 |
class NetDeviceList; |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
361
diff
changeset
|
92 |
class ApplicationList; |
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
361
diff
changeset
|
93 |
|
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
361
diff
changeset
|
94 |
// The below five may be encapsulated/abstracted in a Kernel or Stack class |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
95 |
class L3Demux; |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
233
diff
changeset
|
96 |
class Ipv4L4Demux; |
241
9004ab4cfe17
add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
234
diff
changeset
|
97 |
class Ipv4; |
9004ab4cfe17
add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
234
diff
changeset
|
98 |
class Udp; |
242
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
99 |
class Arp; |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
361
diff
changeset
|
100 |
|
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
244
diff
changeset
|
101 |
class TraceContext; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
244
diff
changeset
|
102 |
class TraceResolver; |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
103 |
|
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
104 |
class Node { |
359
91b7ad7fa784
OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents:
355
diff
changeset
|
105 |
friend class NodeList; |
361
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
106 |
friend class SmartVector<Node*>; |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
107 |
friend class SmartSet<Node*>; |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
108 |
|
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
109 |
public: |
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
110 |
typedef SmartVector<Node*> SmartNodeVec_t; |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
111 |
Node(); |
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
112 |
Node(uint32_t); // Specify which system for a distributed simulation |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
113 |
virtual ~Node(); |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
114 |
virtual Node* Copy() const = 0;// Make a copy of this node |
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
115 |
|
345
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
244
diff
changeset
|
116 |
virtual TraceResolver *CreateTraceResolver (TraceContext const &context) = 0; |
47b41507a45a
move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
244
diff
changeset
|
117 |
|
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
118 |
uint32_t GetId (void) const; |
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
119 |
uint32_t GetSystemId (void) const; |
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
120 |
void SetSystemId(uint32_t s); |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
121 |
|
361
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
122 |
#ifdef REMOVE_FOR_NOW |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
123 |
// Define a protected delete operator. This will prevent users |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
124 |
// from attempting to delete Node objects. The deletion of |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
125 |
// Nodes is completely the responsibility of the Node class, |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
126 |
// and in no case should be deleted by users. |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
127 |
protected: |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
128 |
void operator delete(void* a) |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
129 |
{ // Just call the normal delete |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
130 |
::delete (Node*)a; |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
131 |
} |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
132 |
#endif |
9b159ff6dbcb
Clean up parameter passing per TOm's request
George F. Riley<riley@ece.gatech.edu>
parents:
359
diff
changeset
|
133 |
public: |
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
134 |
// Static methods for creating nodes and managing the node stack |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
135 |
|
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
136 |
// Create a new node. The node will be a copy of the top of the |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
137 |
// node prototype list |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
138 |
static Node* Create(); |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
139 |
// Create with a uint32_t is used by distributed simulations to |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
140 |
// indicate system ownership of the new node. |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
141 |
static Node* Create(uint32_t); |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
142 |
static Node* GetNodePrototype(); // Get the current node prototype |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
143 |
// Specifies the type of node to be returned by Create() |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
144 |
// This version specifies a pre-configured node to use as the prototype |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
145 |
// Of course the passed object can be any subclass of Node. |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
146 |
static Node* PushNodePrototype(const Node&); |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
147 |
// THis version replicates the top of the prototype stack |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
148 |
static Node* PushNodePrototype(); |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
149 |
// Remove the top of the prototype stack |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
150 |
static void PopNodePrototype(); |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
151 |
// Node access |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
152 |
static const SmartNodeVec_t& Nodes(); // Get a vector of all nodes |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
153 |
static void ClearAll(); // Delete all nodes for memory leak checking |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
154 |
static void ClearAllPrototypes();// Delete the prototype stack |
359
91b7ad7fa784
OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents:
355
diff
changeset
|
155 |
|
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
156 |
// Global static variables |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
157 |
private: |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
158 |
static uint32_t g_nextId; // Next available ID |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
159 |
static SmartNodeVec_t g_nodes; // Vector of all nodes created |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
160 |
static SmartNodeVec_t g_prototypes; // Node prototype stack |
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
161 |
|
359
91b7ad7fa784
OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents:
355
diff
changeset
|
162 |
protected: |
91b7ad7fa784
OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents:
355
diff
changeset
|
163 |
void SetId(uint32_t); // NodeList::Add() calls this |
91b7ad7fa784
OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents:
355
diff
changeset
|
164 |
|
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
165 |
public: |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
166 |
// Virtual "Getters" for each capability. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
167 |
// These exist to allow owners of a generic Node pointer to get |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
168 |
// a pointer to the underlying capability, a pointer to a "NULL" |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
169 |
// capability if one exists, or the nil pointer if not. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
170 |
// Each of these has a default behavior of returning a null capability |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
171 |
// of the correct type if one exists, or the nil pointer if no |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
172 |
// null capability exists. |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
173 |
virtual L3Demux* GetL3Demux() const; |
234
6124bda39cb3
code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
233
diff
changeset
|
174 |
virtual Ipv4L4Demux* GetIpv4L4Demux() const; |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
175 |
virtual NetDeviceList* GetNetDeviceList() const; |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
361
diff
changeset
|
176 |
virtual ApplicationList* GetApplicationList() const; |
241
9004ab4cfe17
add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
234
diff
changeset
|
177 |
virtual Ipv4 * GetIpv4 (void) const; |
9004ab4cfe17
add Ipv4 and Udp node capabilities, rework Copy methods to include an extra Node * argument
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
234
diff
changeset
|
178 |
virtual Udp * GetUdp (void) const; |
242
a44932709b47
add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
179 |
virtual Arp * GetArp (void) const; |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
180 |
|
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
181 |
private: |
244
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
182 |
uint32_t m_id; // Node id for this node |
caff04d90a66
remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
242
diff
changeset
|
183 |
uint32_t m_sid; // System id for this node |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
184 |
}; |
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
185 |
|
355
d18da75542c7
Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents:
345
diff
changeset
|
186 |
} //namespace ns3 |
232
8cd08910f9a1
initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
187 |
#endif |