src/node/node-list.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 14 May 2007 10:06:12 +0200
changeset 607 1b7abeccfcda
parent 604 0b6bef4e99bc
child 728 95c426b1cb60
permissions -rw-r--r--
rename Node to INode
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
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
 * All rights reserved.
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 *
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 * 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
     7
 * 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
     8
 * 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
     9
 *
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * 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
    11
 * 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
    12
 * 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
    13
 * 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
    14
 *
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 * 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
    16
 * 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
    17
 * 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
    18
 *
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
 * Authors: 
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
 *  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
    21
 */
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    23
#include "ns3/array-trace-resolver.h"
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
#include "ns3/trace-root.h"
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    25
#include "ns3/simulator.h"
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    26
#include "ns3/simulation-singleton.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"
604
0b6bef4e99bc rename node.h to i-node.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 573
diff changeset
    28
#include "i-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
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    30
namespace {
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    31
static class Initialization 
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    32
{
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    33
public:
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    34
  Initialization ()
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    35
  {
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    36
    ns3::TraceRoot::Register ("nodes", ns3::MakeCallback (&ns3::NodeList::CreateTraceResolver));
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    37
  }
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    38
} g_initialization;
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    39
}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    40
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    41
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
    42
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    43
/**
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    44
 * The private node list used by the 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
    45
 */
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    46
class NodeListPriv
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    47
{
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    48
public:
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    49
  NodeListPriv ();
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    50
  ~NodeListPriv ();
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    51
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    52
  uint32_t Add (Ptr<INode> 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
    53
  NodeList::Iterator Begin (void);
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    54
  NodeList::Iterator End (void);
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    55
  TraceResolver *CreateTraceResolver (TraceContext const &context);
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    56
  INode *PeekINode (uint32_t n);
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    57
  Ptr<INode> GetINode (uint32_t n);
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    58
  uint32_t GetNINodes (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
    59
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    60
private:
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    61
  std::vector<Ptr<INode> > 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
    62
};
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    63
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    64
NodeListPriv::NodeListPriv ()
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    65
{}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    66
NodeListPriv::~NodeListPriv ()
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    67
{
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    68
  for (std::vector<Ptr<INode> >::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
    69
       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
    70
    {
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    71
      Ptr<INode> 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
    72
      node->Dispose ();
551
12ed30c77cab revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 546
diff changeset
    73
      *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
    74
    }
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    75
  m_nodes.erase (m_nodes.begin (), 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
    76
}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    77
359
91b7ad7fa784 OnOffApplication functioning; some Node class cleanup
Tom Henderson <tomh@tomh.org>
parents: 345
diff changeset
    78
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    79
uint32_t
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    80
NodeListPriv::Add (Ptr<INode> 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
    81
{
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    82
  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
    83
  m_nodes.push_back (node);
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    84
  return index;
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    85
  
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    86
}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    87
NodeList::Iterator 
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    88
NodeListPriv::Begin (void)
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    89
{
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    90
  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
    91
}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    92
NodeList::Iterator 
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    93
NodeListPriv::End (void)
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    94
{
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    95
  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
    96
}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
    97
uint32_t 
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
    98
NodeListPriv::GetNINodes (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
    99
{
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   100
  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
   101
}
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   102
INode *
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   103
NodeListPriv::PeekINode (uint32_t n)
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   104
{
573
0da9201a048e rename Ptr::Get and Ptr::Peek to GetPointer and PeekPointer
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 564
diff changeset
   105
  return PeekPointer (m_nodes[n]);
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
}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   107
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   108
Ptr<INode>
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   109
NodeListPriv::GetINode (uint32_t n)
564
4da6cc2af83f make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 562
diff changeset
   110
{
4da6cc2af83f make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 562
diff changeset
   111
  return m_nodes[n];
4da6cc2af83f make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 562
diff changeset
   112
}
4da6cc2af83f make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 562
diff changeset
   113
4da6cc2af83f make sure that NodeList::GetNode is correctly implemented
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 562
diff changeset
   114
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
TraceResolver *
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   116
NodeListPriv::CreateTraceResolver (TraceContext const &context)
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   117
{
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   118
  ArrayTraceResolver<INode> *resolver =
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   119
    new ArrayTraceResolver<INode>
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
    (context, 
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   121
     MakeCallback (&NodeListPriv::GetNINodes, this),
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   122
     MakeCallback (&NodeListPriv::PeekINode, 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
   123
  return resolver;
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   124
}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   125
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   126
}
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   127
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   128
/**
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   129
 * 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
   130
 * 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
   131
 * 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
   132
 */
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   133
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
   134
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   135
uint32_t
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   136
NodeList::Add (Ptr<INode> 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
   137
{
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
  return SimulationSingleton<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
   139
}
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
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
   141
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
   142
{
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   143
  return SimulationSingleton<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
   144
}
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   145
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
   146
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
   147
{
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   148
  return SimulationSingleton<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
   149
}
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
TraceResolver *
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   151
NodeList::CreateTraceResolver (TraceContext const &context)
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   152
{
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   153
  return SimulationSingleton<NodeListPriv>::Get ()->CreateTraceResolver (context);
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   154
}
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   155
Ptr<INode>
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   156
NodeList::GetINode (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
   157
{
607
1b7abeccfcda rename Node to INode
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 604
diff changeset
   158
  return SimulationSingleton<NodeListPriv>::Get ()->GetINode (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
   159
}
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   160
484
cf7fbb84d74b rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 425
diff changeset
   161
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   162
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   163
}//namespace ns3