Removed TraceContext and TraceResolver references, removed MobilityModelNotifier class, and minor changes on samples/main-random-walk.cc.
authortjkopena@cs.drexel.edu
Wed, 14 May 2008 19:24:17 -0400
changeset 3021 5b1479210da3
parent 3014 b9c517e4bfd5
child 3022 c64c571c8e0c
Removed TraceContext and TraceResolver references, removed MobilityModelNotifier class, and minor changes on samples/main-random-walk.cc.
examples/mixed-wireless.cc
samples/main-random-topology.cc
samples/main-random-walk.cc
src/devices/csma/csma-net-device.h
src/devices/point-to-point/point-to-point-net-device.h
src/helper/mobility-helper.cc
src/helper/mobility-helper.h
src/helper/ns2-mobility-helper.cc
src/helper/ns2-mobility-helper.h
src/internet-node/arp-l3-protocol.h
src/internet-node/ascii-trace.h
src/internet-node/ipv4-interface.h
src/internet-node/ipv4-l4-demux.h
src/internet-node/ipv4-l4-protocol.h
src/internet-node/pcap-trace.h
src/internet-node/tcp-l4-protocol.h
src/internet-node/udp-l4-protocol.h
src/mobility/hierarchical-mobility-model.cc
src/mobility/mobility-model-notifier.cc
src/mobility/mobility-model-notifier.h
src/mobility/mobility-model.cc
src/mobility/mobility-model.h
src/mobility/mobility.h
src/mobility/wscript
src/node/net-device.h
src/node/node.h
--- a/examples/mixed-wireless.cc	Tue May 13 01:04:42 2008 +0100
+++ b/examples/mixed-wireless.cc	Wed May 14 19:24:17 2008 -0400
@@ -268,7 +268,6 @@
         {
           subnetAlloc->Add (Vector (0.0, j, 0.0));
         }
-      mobility.EnableNotifier ();
       mobility.PushReferenceMobilityModel (backbone.Get (i));
       mobility.SetPositionAllocator (subnetAlloc);
       mobility.SetMobilityModel ("ns3::RandomDirection2dMobilityModel",
@@ -344,7 +343,7 @@
   CsmaHelper::EnablePcap ("mixed-wireless.pcap", appSink->GetId (), 0);
 
 #ifdef ENABLE_FOR_TRACING_EXAMPLE
-  Config::Connect ("/NodeList/*/$MobilityModelNotifier/CourseChange",
+  Config::Connect ("/NodeList/*/$MobilityModel/CourseChange",
     MakeCallback (&CourseChangeCallback));
 #endif
 
--- a/samples/main-random-topology.cc	Tue May 13 01:04:42 2008 +0100
+++ b/samples/main-random-topology.cc	Wed May 14 19:24:17 2008 -0400
@@ -25,7 +25,6 @@
   c.Create (10000);
 
   MobilityHelper mobility;
-  mobility.EnableNotifier ();
   mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
                                  "X", StringValue ("100.0"),
                                  "Y", StringValue ("100.0"),
--- a/samples/main-random-walk.cc	Tue May 13 01:04:42 2008 +0100
+++ b/samples/main-random-walk.cc	Wed May 14 19:24:17 2008 -0400
@@ -8,7 +8,7 @@
 using namespace ns3;
 
 static void 
-CourseChange (ns3::TraceContext const&, Ptr<const MobilityModel> mobility)
+CourseChange (std::string foo, Ptr<const MobilityModel> mobility)
 {
   Vector pos = mobility->GetPosition ();
   Vector vel = mobility->GetVelocity ();
@@ -22,7 +22,7 @@
   Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", StringValue ("Time"));
   Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", StringValue ("2s"));
   Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", StringValue ("Constant:1.0"));
-  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", StringValue ("0:200:0:100"));
+  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", StringValue ("0|200|0|200"));
 
   CommandLine cmd;
   cmd.Parse (argc, argv);
@@ -31,7 +31,6 @@
   c.Create (100);
 
   MobilityHelper mobility;
-  mobility.EnableNotifier ();
   mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
                                  "X", StringValue ("100.0"),
                                  "Y", StringValue ("100.0"),
@@ -40,9 +39,9 @@
                              "Mode", StringValue ("Time"),
                              "Time", StringValue ("2s"),
                              "Speed", StringValue ("Constant:1.0"),
-                             "Bounds", StringValue ("0:200:0:100"));
+                             "Bounds", StringValue ("0|200|0|200"));
   mobility.InstallAll ();
-  Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange",
+  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
                    MakeCallback (&CourseChange));
 
   Simulator::StopAt (Seconds (100.0));
--- a/src/devices/csma/csma-net-device.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/devices/csma/csma-net-device.h	Wed May 14 19:24:17 2008 -0400
@@ -420,7 +420,6 @@
    * fire.
    *
    * @see class CallBackTraceSource
-   * @see class TraceResolver
    */
   TracedCallback<Ptr<const Packet> > m_rxTrace;
   TracedCallback<Ptr<const Packet> > m_dropTrace;
--- a/src/devices/point-to-point/point-to-point-net-device.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/devices/point-to-point/point-to-point-net-device.h	Wed May 14 19:24:17 2008 -0400
@@ -267,7 +267,6 @@
    * fire.
    *
    * @see class CallBackTraceSource
-   * @see class TraceResolver
    */
   TracedCallback<Ptr<const Packet> > m_rxTrace;
   /**
@@ -275,7 +274,6 @@
    * fire.
    *
    * @see class CallBackTraceSource
-   * @see class TraceResolver
    */
   TracedCallback<Ptr<const Packet> > m_dropTrace;
 
--- a/src/helper/mobility-helper.cc	Tue May 13 01:04:42 2008 +0100
+++ b/src/helper/mobility-helper.cc	Wed May 14 19:24:17 2008 -0400
@@ -19,7 +19,6 @@
  */
 #include "ns3/mobility-helper.h"
 #include "ns3/mobility-model.h"
-#include "ns3/mobility-model-notifier.h"
 #include "ns3/position-allocator.h"
 #include "ns3/hierarchical-mobility-model.h"
 #include "ns3/log.h"
@@ -30,7 +29,6 @@
 NS_LOG_COMPONENT_DEFINE ("MobilityHelper");
 
 MobilityHelper::MobilityHelper ()
-  : m_notifierEnabled (false)
 {
   m_position = CreateObject<RandomRectanglePositionAllocator> 
     ("X", RandomVariableValue (ConstantVariable (0.0)),
@@ -40,16 +38,6 @@
 MobilityHelper::~MobilityHelper ()
 {}
 void 
-MobilityHelper::EnableNotifier (void)
-{
-  m_notifierEnabled = true;
-}
-void 
-MobilityHelper::DisableNotifier (void)
-{
-  m_notifierEnabled = false;
-}
-void 
 MobilityHelper::SetPositionAllocator (Ptr<PositionAllocator> allocator)
 {
   m_position = allocator;
@@ -156,15 +144,6 @@
 	}
       Vector position = m_position->GetNext ();
       model->SetPosition (position);
-      if (m_notifierEnabled)
-	{
-	  Ptr<MobilityModelNotifier> notifier = 
-	    object->GetObject<MobilityModelNotifier> ();
-	  if (notifier == 0)
-	    {
-	      object->AggregateObject (CreateObject<MobilityModelNotifier> ());
-	    }
-	}
     }
 }
 
--- a/src/helper/mobility-helper.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/helper/mobility-helper.h	Wed May 14 19:24:17 2008 -0400
@@ -43,20 +43,6 @@
   ~MobilityHelper ();
 
   /**
-   * After this method is called, every call to MobilityHelper::Install
-   * will also attach to the new ns3::MobilityModel an ns3::MobilityModelNotifier
-   * which can be used to listen to CourseChange events.
-   */
-  void EnableNotifier (void);
-  /**
-   * After this method is called, no ns3::MobilityModelNotifier object will
-   * be associated to any new ns3::MobilityModel created by MobilityHelper::Install.
-   * This will make it impossible to listen to "CourseChange" events from these
-   * new ns3::MobilityModel instances.
-   */
-  void DisableNotifier (void);
-
-  /**
    * \param allocator allocate initial node positions
    *
    * Set the position allocator which will be used to allocate
@@ -169,9 +155,6 @@
    * subclass (the type of which was set with MobilityHelper::SetMobilityModel), 
    * aggregates it to the mode, and sets an initial position based on the current 
    * position allocator (set through MobilityHelper::SetPositionAllocator). 
-   * Optionally, this method will also create and aggregate a
-   * ns3::MobilityModelNotifier to generate 'CourseChange' events based on the 
-   * boolean flag set by MobilityHelper::EnableNotifierAll and MobilityHelper::DisableNotifier.
    */
   void Install (NodeContainer container);
 
@@ -183,7 +166,6 @@
 private:
 
   std::vector<Ptr<MobilityModel> > m_mobilityStack;
-  bool m_notifierEnabled;
   ObjectFactory m_mobility;
   Ptr<PositionAllocator> m_position;
 };
--- a/src/helper/ns2-mobility-helper.cc	Tue May 13 01:04:42 2008 +0100
+++ b/src/helper/ns2-mobility-helper.cc	Wed May 14 19:24:17 2008 -0400
@@ -24,7 +24,6 @@
 #include "ns3/node-list.h"
 #include "ns3/node.h"
 #include "ns3/static-speed-mobility-model.h"
-#include "ns3/mobility-model-notifier.h"
 #include "ns2-mobility-helper.h"
 
 NS_LOG_COMPONENT_DEFINE ("Ns2MobilityHelper");
@@ -36,17 +35,6 @@
   : m_filename (filename)
 {}
 
-void 
-Ns2MobilityHelper::EnableNotifier (void)
-{
-  m_notifierEnabled = true;
-}
-void 
-Ns2MobilityHelper::DisableNotifier (void)
-{
-  m_notifierEnabled = false;
-}
-
 
 
 Ptr<StaticSpeedMobilityModel>
@@ -67,12 +55,6 @@
       model = CreateObject<StaticSpeedMobilityModel> ();
       object->AggregateObject (model);
     }
-  Ptr<MobilityModelNotifier> notifier = object->GetObject<MobilityModelNotifier> ();
-  if (notifier == 0)
-    {
-      notifier = CreateObject<MobilityModelNotifier> ();
-      object->AggregateObject (notifier);
-    }
   return model;
 }
 
--- a/src/helper/ns2-mobility-helper.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/helper/ns2-mobility-helper.h	Wed May 14 19:24:17 2008 -0400
@@ -42,9 +42,6 @@
    */
   Ns2MobilityHelper (std::string filename);
 
-  void EnableNotifier (void);
-  void DisableNotifier (void);
-
   /**
    * Read the ns2 trace file and configure the movement
    * patterns of all nodes contained in the global ns3::NodeList
@@ -77,7 +74,6 @@
   Ptr<StaticSpeedMobilityModel> GetMobilityModel (std::string idString, const ObjectStore &store) const;
   double ReadDouble (std::string valueString) const;
   std::string m_filename;
-  bool m_notifierEnabled;
 };
 
 } // namespace ns3
--- a/src/internet-node/arp-l3-protocol.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/internet-node/arp-l3-protocol.h	Wed May 14 19:24:17 2008 -0400
@@ -31,7 +31,7 @@
 class NetDevice;
 class Node;
 class Packet;
-class TraceContext;
+
 /**
  * \brief An implementation of the ARP protocol
  */
--- a/src/internet-node/ascii-trace.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/internet-node/ascii-trace.h	Wed May 14 19:24:17 2008 -0400
@@ -27,7 +27,6 @@
 namespace ns3 {
 
 class Packet;
-class TraceContext;
 
 class AsciiTrace 
 {
--- a/src/internet-node/ipv4-interface.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/internet-node/ipv4-interface.h	Wed May 14 19:24:17 2008 -0400
@@ -31,7 +31,6 @@
 
 class NetDevice;
 class Packet;
-class TraceContext;
 
 /**
  * \brief The IPv4 representation of a network interface
--- a/src/internet-node/ipv4-l4-demux.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/internet-node/ipv4-l4-demux.h	Wed May 14 19:24:17 2008 -0400
@@ -32,7 +32,6 @@
 
 class Ipv4L4Protocol;
 class Node;
-class TraceContext;
 
 /**
  * \brief L4 Ipv4 Demux
--- a/src/internet-node/ipv4-l4-protocol.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/internet-node/ipv4-l4-protocol.h	Wed May 14 19:24:17 2008 -0400
@@ -31,8 +31,6 @@
 
 class Packet;
 class Ipv4Address;
-class TraceResolver;
-class TraceContext;
 
 /**
  * \brief L4 Protocol base class 
--- a/src/internet-node/pcap-trace.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/internet-node/pcap-trace.h	Wed May 14 19:24:17 2008 -0400
@@ -27,7 +27,6 @@
 namespace ns3 {
 
 class Packet;
-class TraceContext;
 class PcapWriter;
 
 class PcapTrace 
--- a/src/internet-node/tcp-l4-protocol.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/internet-node/tcp-l4-protocol.h	Wed May 14 19:24:17 2008 -0400
@@ -37,7 +37,6 @@
 namespace ns3 {
 
 class Node;
-class TraceContext;
 class Socket;
 class TcpHeader;
 /**
--- a/src/internet-node/udp-l4-protocol.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/internet-node/udp-l4-protocol.h	Wed May 14 19:24:17 2008 -0400
@@ -32,7 +32,6 @@
 namespace ns3 {
 
 class Node;
-class TraceContext;
 class Socket;
 /**
  * \brief Implementation of the UDP protocol
--- a/src/mobility/hierarchical-mobility-model.cc	Tue May 13 01:04:42 2008 +0100
+++ b/src/mobility/hierarchical-mobility-model.cc	Wed May 14 19:24:17 2008 -0400
@@ -18,7 +18,6 @@
  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
  */
 #include "hierarchical-mobility-model.h"
-#include "mobility-model-notifier.h"
 #include "ns3/pointer.h"
 
 namespace ns3 {
@@ -52,28 +51,14 @@
 HierarchicalMobilityModel::SetChild (Ptr<MobilityModel> model)
 {
   m_child = model;
-  Ptr<MobilityModelNotifier> notifier = 
-    m_child->GetObject<MobilityModelNotifier> ();
-  if (notifier == 0)
-    {
-      notifier = CreateObject<MobilityModelNotifier> ();
-      m_child->AggregateObject (notifier);
-    }
-  notifier->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));
+  m_child->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this));
 }
 
 void 
 HierarchicalMobilityModel::SetParent (Ptr<MobilityModel> model)
 {
   m_parent = model;
-  Ptr<MobilityModelNotifier> notifier = 
-    m_parent->GetObject<MobilityModelNotifier> ();
-  if (notifier == 0)
-    {
-      notifier = CreateObject<MobilityModelNotifier> ();
-      m_parent->AggregateObject (notifier);
-    }
-  notifier->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this));
+  m_parent->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this));
 }
 
 
--- a/src/mobility/mobility-model-notifier.cc	Tue May 13 01:04:42 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#include "mobility-model-notifier.h"
-#include "ns3/trace-source-accessor.h"
-
-namespace ns3 {
-
-TypeId 
-MobilityModelNotifier::GetTypeId (void)
-{
-  static TypeId tid = TypeId ("MobilityModelNotifier")
-    .SetParent<Object> ()
-    .AddConstructor<MobilityModelNotifier> ()
-    .AddTraceSource ("CourseChange", 
-                     "The value of the position and/or velocity vector changed",
-                     MakeTraceSourceAccessor (&MobilityModelNotifier::m_trace))
-    ;
-  return tid;
-}
-
-MobilityModelNotifier::MobilityModelNotifier ()
-{}
-
-void 
-MobilityModelNotifier::Notify (Ptr<const MobilityModel> position) const
-{
-  m_trace (position);
-}
-
-} // namespace ns3
--- a/src/mobility/mobility-model-notifier.h	Tue May 13 01:04:42 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
- */
-#ifndef MOBILITY_MODEL_NOTIFIER_H
-#define MOBILITY_MODEL_NOTIFIER_H
-
-#include "ns3/object.h"
-#include "ns3/callback.h"
-#include "ns3/traced-callback.h"
-#include "mobility-model.h"
-
-namespace ns3 {
-
-/**
- * \brief notify listeners of position changes.
- */
-class MobilityModelNotifier : public Object
-{
-public:
-  static TypeId GetTypeId (void);
-
-  /**
-   * Create a new position notifier
-   */
-  MobilityModelNotifier ();
-
-  /**
-   * \param position the position which just changed.
-   */
-  void Notify (Ptr<const MobilityModel> position) const;
-private:
-  TracedCallback<Ptr<const MobilityModel> > m_trace;
-};
-
-} // namespace ns3
-
-#endif /* MOBILITY_MODEL_NOTIFIER_H */
--- a/src/mobility/mobility-model.cc	Tue May 13 01:04:42 2008 +0100
+++ b/src/mobility/mobility-model.cc	Wed May 14 19:24:17 2008 -0400
@@ -17,9 +17,11 @@
  *
  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
  */
+
+#include <math.h>
+
 #include "mobility-model.h"
-#include "mobility-model-notifier.h"
-#include <math.h>
+#include "ns3/trace-source-accessor.h"
 
 namespace ns3 {
 
@@ -39,6 +41,9 @@
                    VectorValue (Vector (0.0, 0.0, 0.0)), // ignored initial value.
                    MakeVectorAccessor (&MobilityModel::GetVelocity),
                    MakeVectorChecker ())
+    .AddTraceSource ("CourseChange", 
+                     "The value of the position and/or velocity vector changed",
+                     MakeTraceSourceAccessor (&MobilityModel::m_trace))
     ;
   return tid;
 }
@@ -77,11 +82,7 @@
 void
 MobilityModel::NotifyCourseChange (void) const
 {
-  Ptr<MobilityModelNotifier> notifier = GetObject<MobilityModelNotifier> ();
-  if (notifier != 0)
-    {
-      notifier->Notify (this);
-    }
+  m_trace(this);
 }
 
 } // namespace ns3
--- a/src/mobility/mobility-model.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/mobility/mobility-model.h	Wed May 14 19:24:17 2008 -0400
@@ -20,8 +20,10 @@
 #ifndef MOBILITY_MODEL_H
 #define MOBILITY_MODEL_H
 
+#include "vector.h"
+
 #include "ns3/object.h"
-#include "vector.h"
+#include "ns3/traced-callback.h"
 
 namespace ns3 {
 
@@ -84,6 +86,13 @@
    * implement this method.
    */
   virtual Vector DoGetVelocity (void) const = 0;
+
+  /**
+   * Used to alert subscribers that a change in direction, velocity,
+   * or position has occurred.
+   */
+  TracedCallback<Ptr<const MobilityModel> > m_trace;
+
 };
 
 }; // namespace ns3
--- a/src/mobility/mobility.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/mobility/mobility.h	Wed May 14 19:24:17 2008 -0400
@@ -5,8 +5,8 @@
  *  - a set of mobility models which are used to track and maintain
  *    the "current" cartesian position and speed of an object.
  *
- *  - a "course change notifier" which can be used to register listeners
- *    to the course changes of a mobility model: ns3::MobilityModelNotifier.
+ *  - a "course change notifier" trace which can be used to register
+ *    listeners to the course changes of a mobility model
  *
  * The mobility models themselves are:
  *   - ns3::StaticMobilityModel: a model which maintains a constant position
--- a/src/mobility/wscript	Tue May 13 01:04:42 2008 +0100
+++ b/src/mobility/wscript	Wed May 14 19:24:17 2008 -0400
@@ -6,7 +6,6 @@
         'vector.cc',
         'hierarchical-mobility-model.cc',
         'mobility-model.cc',
-        'mobility-model-notifier.cc',
         'position-allocator.cc',
         'rectangle.cc',
         'static-mobility-model.cc',
@@ -23,7 +22,6 @@
         'vector.h',
         'hierarchical-mobility-model.h',
         'mobility-model.h',
-        'mobility-model-notifier.h',
         'position-allocator.h',
         'rectangle.h',
         'static-mobility-model.h',
--- a/src/node/net-device.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/node/net-device.h	Wed May 14 19:24:17 2008 -0400
@@ -32,7 +32,6 @@
 namespace ns3 {
 
 class Node;
-class TraceContext;
 class Channel;
 class Packet;
 
--- a/src/node/node.h	Tue May 13 01:04:42 2008 +0100
+++ b/src/node/node.h	Wed May 14 19:24:17 2008 -0400
@@ -29,7 +29,6 @@
 
 namespace ns3 {
 
-class TraceContext;
 class NetDevice;
 class Application;
 class Packet;