src/node/node.h
author Tom Henderson <tomh@tomh.org>
Mon, 19 Mar 2007 22:19:38 -0700
changeset 355 d18da75542c7
parent 345 47b41507a45a
child 359 91b7ad7fa784
permissions -rw-r--r--
Add static node factory methods to class Node
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
// 5) Where possible Create a "Null" capability subclass of your capability
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
//    that does nothing.  For example, the basic energy model provides the
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
//    NullEnergyModel that is returned by the node base class "GetEnergyModel()"
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
//    call when the energy model does not exist.  This Null capability of course
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
//    has the same API as all energy models, but does nothing.  THis allows
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
//    users of the energy model to use the pointer returned by GetEnergyModel()
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
//    without having to check for the nil return.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
// 6) Implement a static GetNullCapability() method that returns either a
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
//     pointer to the Null capability (see 5 above) of a nil pointer if no
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
//     null capability exists.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
// 7) Implement a "Get*" virtual method in the node base that returns
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
//    the null capability.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
// 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
    75
// the following steps:
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
// 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
    78
// 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
    79
//    behavior.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
// 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
    81
//    subclass.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
//
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
// 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
    84
// 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
    85
// 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
    86
// an existing capability where possible.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
#ifndef NODE_H
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
#define NODE_H
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
#include <vector>
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
#include <list>
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    94
#include "ns3/smartvector.h"
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    95
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
namespace ns3 {
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
class L3Demux;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 233
diff changeset
    99
class Ipv4L4Demux;
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
class NetDeviceList;
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
   101
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
   102
class Udp;
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   103
class Arp;
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
   104
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
   105
class TraceResolver;
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   106
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   107
class Node {
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   108
public:
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   109
  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
   110
  Node();
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   111
  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
   112
  virtual ~Node();
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
  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
   114
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
   115
  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
   116
244
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   117
  uint32_t GetId (void) const;
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   118
  uint32_t GetSystemId (void) const;
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   119
  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
   120
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   121
  // 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
   122
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   123
  // 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
   124
  // node prototype list
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   125
  static Node* Create();
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   126
  // 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
   127
  // 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
   128
  static Node* Create(uint32_t);
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   129
  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
   130
  // 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
   131
  // 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
   132
  // 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
   133
  static Node* PushNodePrototype(const Node&); 
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   134
  // 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
   135
  static Node* PushNodePrototype();
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   136
  // 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
   137
  static void PopNodePrototype();
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   138
  // Node access
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   139
  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
   140
  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
   141
  static void  ClearAllPrototypes();// Delete the prototype stack
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   142
private: 
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   143
  static void  CreateDefaultPrototype(); // Create a "typical" prototype node
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   144
  // Global static variables
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   145
private: 
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   146
  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
   147
  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
   148
  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
   149
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   150
public:
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
  // Virtual "Getters" for each capability.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
  // 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
   153
  // 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
   154
  // 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
   155
  // 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
   156
  // 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
   157
  // null capability exists.
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
  virtual L3Demux*         GetL3Demux() const;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 233
diff changeset
   159
  virtual Ipv4L4Demux*     GetIpv4L4Demux() const;
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
  virtual NetDeviceList*   GetNetDeviceList() 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
   161
  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
   162
  virtual Udp *            GetUdp (void) const;
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   163
  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
   164
  
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   165
private:
244
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   166
  static uint32_t m_nodeId;
caff04d90a66 remove SetNodeId and implement GetId and GetSystemId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
   167
  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
   168
  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
   169
};
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
355
d18da75542c7 Add static node factory methods to class Node
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
   171
} //namespace ns3
232
8cd08910f9a1 initial node base class from george's repo.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   172
#endif