diff --git a/examples/mixed-wireless.cc b/examples/mixed-wireless.cc index 05dbcf0a4..aefde4816 100644 --- a/examples/mixed-wireless.cc +++ b/examples/mixed-wireless.cc @@ -268,7 +268,6 @@ main (int argc, char *argv[]) { 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 @@ main (int argc, char *argv[]) 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 diff --git a/samples/main-random-topology.cc b/samples/main-random-topology.cc index ec34d1ec8..7e4f32334 100644 --- a/samples/main-random-topology.cc +++ b/samples/main-random-topology.cc @@ -25,7 +25,6 @@ int main (int argc, char *argv[]) c.Create (10000); MobilityHelper mobility; - mobility.EnableNotifier (); mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator", "X", StringValue ("100.0"), "Y", StringValue ("100.0"), diff --git a/samples/main-random-walk.cc b/samples/main-random-walk.cc index 1ce1ae0ac..c0219a508 100644 --- a/samples/main-random-walk.cc +++ b/samples/main-random-walk.cc @@ -8,7 +8,7 @@ using namespace ns3; static void -CourseChange (ns3::TraceContext const&, Ptr mobility) +CourseChange (std::string foo, Ptr mobility) { Vector pos = mobility->GetPosition (); Vector vel = mobility->GetVelocity (); @@ -22,7 +22,7 @@ int main (int argc, char *argv[]) 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 @@ int main (int argc, char *argv[]) c.Create (100); MobilityHelper mobility; - mobility.EnableNotifier (); mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator", "X", StringValue ("100.0"), "Y", StringValue ("100.0"), @@ -40,9 +39,9 @@ int main (int argc, char *argv[]) "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)); diff --git a/src/devices/csma/csma-net-device.h b/src/devices/csma/csma-net-device.h index 107873f7c..ac149bf66 100644 --- a/src/devices/csma/csma-net-device.h +++ b/src/devices/csma/csma-net-device.h @@ -420,7 +420,6 @@ private: * fire. * * @see class CallBackTraceSource - * @see class TraceResolver */ TracedCallback > m_rxTrace; TracedCallback > m_dropTrace; diff --git a/src/devices/point-to-point/point-to-point-net-device.h b/src/devices/point-to-point/point-to-point-net-device.h index bcf541ff1..ebfaf8239 100644 --- a/src/devices/point-to-point/point-to-point-net-device.h +++ b/src/devices/point-to-point/point-to-point-net-device.h @@ -267,7 +267,6 @@ private: * fire. * * @see class CallBackTraceSource - * @see class TraceResolver */ TracedCallback > m_rxTrace; /** @@ -275,7 +274,6 @@ private: * fire. * * @see class CallBackTraceSource - * @see class TraceResolver */ TracedCallback > m_dropTrace; diff --git a/src/helper/mobility-helper.cc b/src/helper/mobility-helper.cc index 04cb4bef6..1976f0c63 100644 --- a/src/helper/mobility-helper.cc +++ b/src/helper/mobility-helper.cc @@ -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 @@ namespace ns3 { NS_LOG_COMPONENT_DEFINE ("MobilityHelper"); MobilityHelper::MobilityHelper () - : m_notifierEnabled (false) { m_position = CreateObject ("X", RandomVariableValue (ConstantVariable (0.0)), @@ -40,16 +38,6 @@ MobilityHelper::MobilityHelper () MobilityHelper::~MobilityHelper () {} void -MobilityHelper::EnableNotifier (void) -{ - m_notifierEnabled = true; -} -void -MobilityHelper::DisableNotifier (void) -{ - m_notifierEnabled = false; -} -void MobilityHelper::SetPositionAllocator (Ptr allocator) { m_position = allocator; @@ -156,15 +144,6 @@ MobilityHelper::Install (NodeContainer c) } Vector position = m_position->GetNext (); model->SetPosition (position); - if (m_notifierEnabled) - { - Ptr notifier = - object->GetObject (); - if (notifier == 0) - { - object->AggregateObject (CreateObject ()); - } - } } } diff --git a/src/helper/mobility-helper.h b/src/helper/mobility-helper.h index e1ac293fd..d37eb36c6 100644 --- a/src/helper/mobility-helper.h +++ b/src/helper/mobility-helper.h @@ -42,20 +42,6 @@ public: MobilityHelper (); ~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 * @@ -169,9 +155,6 @@ public: * 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 @@ public: private: std::vector > m_mobilityStack; - bool m_notifierEnabled; ObjectFactory m_mobility; Ptr m_position; }; diff --git a/src/helper/ns2-mobility-helper.cc b/src/helper/ns2-mobility-helper.cc index 736c92581..563287b05 100644 --- a/src/helper/ns2-mobility-helper.cc +++ b/src/helper/ns2-mobility-helper.cc @@ -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 @@ Ns2MobilityHelper::Ns2MobilityHelper (std::string filename) : m_filename (filename) {} -void -Ns2MobilityHelper::EnableNotifier (void) -{ - m_notifierEnabled = true; -} -void -Ns2MobilityHelper::DisableNotifier (void) -{ - m_notifierEnabled = false; -} - Ptr @@ -67,12 +55,6 @@ Ns2MobilityHelper::GetMobilityModel (std::string idString, const ObjectStore &st model = CreateObject (); object->AggregateObject (model); } - Ptr notifier = object->GetObject (); - if (notifier == 0) - { - notifier = CreateObject (); - object->AggregateObject (notifier); - } return model; } diff --git a/src/helper/ns2-mobility-helper.h b/src/helper/ns2-mobility-helper.h index b112129a1..809a51125 100644 --- a/src/helper/ns2-mobility-helper.h +++ b/src/helper/ns2-mobility-helper.h @@ -42,9 +42,6 @@ public: */ 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 @@ private: Ptr GetMobilityModel (std::string idString, const ObjectStore &store) const; double ReadDouble (std::string valueString) const; std::string m_filename; - bool m_notifierEnabled; }; } // namespace ns3 diff --git a/src/internet-node/arp-l3-protocol.h b/src/internet-node/arp-l3-protocol.h index 889966255..8d8870e56 100644 --- a/src/internet-node/arp-l3-protocol.h +++ b/src/internet-node/arp-l3-protocol.h @@ -31,7 +31,7 @@ class ArpCache; class NetDevice; class Node; class Packet; -class TraceContext; + /** * \brief An implementation of the ARP protocol */ diff --git a/src/internet-node/ascii-trace.h b/src/internet-node/ascii-trace.h index 05c505947..9886d9e9b 100644 --- a/src/internet-node/ascii-trace.h +++ b/src/internet-node/ascii-trace.h @@ -27,7 +27,6 @@ namespace ns3 { class Packet; -class TraceContext; class AsciiTrace { diff --git a/src/internet-node/ipv4-interface.h b/src/internet-node/ipv4-interface.h index 04828a3e6..5a1e94df5 100644 --- a/src/internet-node/ipv4-interface.h +++ b/src/internet-node/ipv4-interface.h @@ -31,7 +31,6 @@ namespace ns3 { class NetDevice; class Packet; -class TraceContext; /** * \brief The IPv4 representation of a network interface diff --git a/src/internet-node/ipv4-l4-demux.h b/src/internet-node/ipv4-l4-demux.h index 02b5df900..fa04f8a37 100644 --- a/src/internet-node/ipv4-l4-demux.h +++ b/src/internet-node/ipv4-l4-demux.h @@ -32,7 +32,6 @@ namespace ns3 { class Ipv4L4Protocol; class Node; -class TraceContext; /** * \brief L4 Ipv4 Demux diff --git a/src/internet-node/ipv4-l4-protocol.h b/src/internet-node/ipv4-l4-protocol.h index e8e0b12be..e7f2407ad 100644 --- a/src/internet-node/ipv4-l4-protocol.h +++ b/src/internet-node/ipv4-l4-protocol.h @@ -31,8 +31,6 @@ namespace ns3 { class Packet; class Ipv4Address; -class TraceResolver; -class TraceContext; /** * \brief L4 Protocol base class diff --git a/src/internet-node/pcap-trace.h b/src/internet-node/pcap-trace.h index 3ab644684..0993711b6 100644 --- a/src/internet-node/pcap-trace.h +++ b/src/internet-node/pcap-trace.h @@ -27,7 +27,6 @@ namespace ns3 { class Packet; -class TraceContext; class PcapWriter; class PcapTrace diff --git a/src/internet-node/tcp-l4-protocol.h b/src/internet-node/tcp-l4-protocol.h index e832a69a2..8936460e3 100644 --- a/src/internet-node/tcp-l4-protocol.h +++ b/src/internet-node/tcp-l4-protocol.h @@ -37,7 +37,6 @@ namespace ns3 { class Node; -class TraceContext; class Socket; class TcpHeader; /** diff --git a/src/internet-node/udp-l4-protocol.h b/src/internet-node/udp-l4-protocol.h index 34f686ffc..ce6ec7cae 100644 --- a/src/internet-node/udp-l4-protocol.h +++ b/src/internet-node/udp-l4-protocol.h @@ -32,7 +32,6 @@ namespace ns3 { class Node; -class TraceContext; class Socket; /** * \brief Implementation of the UDP protocol diff --git a/src/mobility/hierarchical-mobility-model.cc b/src/mobility/hierarchical-mobility-model.cc index b1fadc473..a275d8468 100644 --- a/src/mobility/hierarchical-mobility-model.cc +++ b/src/mobility/hierarchical-mobility-model.cc @@ -18,7 +18,6 @@ * Author: Mathieu Lacage */ #include "hierarchical-mobility-model.h" -#include "mobility-model-notifier.h" #include "ns3/pointer.h" namespace ns3 { @@ -52,28 +51,14 @@ void HierarchicalMobilityModel::SetChild (Ptr model) { m_child = model; - Ptr notifier = - m_child->GetObject (); - if (notifier == 0) - { - notifier = CreateObject (); - m_child->AggregateObject (notifier); - } - notifier->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this)); + m_child->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ChildChanged, this)); } void HierarchicalMobilityModel::SetParent (Ptr model) { m_parent = model; - Ptr notifier = - m_parent->GetObject (); - if (notifier == 0) - { - notifier = CreateObject (); - m_parent->AggregateObject (notifier); - } - notifier->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this)); + m_parent->TraceConnectWithoutContext ("CourseChange", MakeCallback (&HierarchicalMobilityModel::ParentChanged, this)); } diff --git a/src/mobility/mobility-model-notifier.cc b/src/mobility/mobility-model-notifier.cc deleted file mode 100644 index 026207137..000000000 --- a/src/mobility/mobility-model-notifier.cc +++ /dev/null @@ -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 - */ -#include "mobility-model-notifier.h" -#include "ns3/trace-source-accessor.h" - -namespace ns3 { - -TypeId -MobilityModelNotifier::GetTypeId (void) -{ - static TypeId tid = TypeId ("MobilityModelNotifier") - .SetParent () - .AddConstructor () - .AddTraceSource ("CourseChange", - "The value of the position and/or velocity vector changed", - MakeTraceSourceAccessor (&MobilityModelNotifier::m_trace)) - ; - return tid; -} - -MobilityModelNotifier::MobilityModelNotifier () -{} - -void -MobilityModelNotifier::Notify (Ptr position) const -{ - m_trace (position); -} - -} // namespace ns3 diff --git a/src/mobility/mobility-model-notifier.h b/src/mobility/mobility-model-notifier.h deleted file mode 100644 index 6fa5e35a4..000000000 --- a/src/mobility/mobility-model-notifier.h +++ /dev/null @@ -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 - */ -#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 position) const; -private: - TracedCallback > m_trace; -}; - -} // namespace ns3 - -#endif /* MOBILITY_MODEL_NOTIFIER_H */ diff --git a/src/mobility/mobility-model.cc b/src/mobility/mobility-model.cc index ddfc3592f..551b29a3e 100644 --- a/src/mobility/mobility-model.cc +++ b/src/mobility/mobility-model.cc @@ -17,10 +17,12 @@ * * Author: Mathieu Lacage */ -#include "mobility-model.h" -#include "mobility-model-notifier.h" + #include +#include "mobility-model.h" +#include "ns3/trace-source-accessor.h" + namespace ns3 { TypeId @@ -39,6 +41,9 @@ MobilityModel::GetTypeId (void) 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 @@ MobilityModel::GetDistanceFrom (Ptr other) const void MobilityModel::NotifyCourseChange (void) const { - Ptr notifier = GetObject (); - if (notifier != 0) - { - notifier->Notify (this); - } + m_trace(this); } } // namespace ns3 diff --git a/src/mobility/mobility-model.h b/src/mobility/mobility-model.h index 28cb67457..cb47cad7c 100644 --- a/src/mobility/mobility-model.h +++ b/src/mobility/mobility-model.h @@ -20,9 +20,11 @@ #ifndef MOBILITY_MODEL_H #define MOBILITY_MODEL_H -#include "ns3/object.h" #include "vector.h" +#include "ns3/object.h" +#include "ns3/traced-callback.h" + namespace ns3 { /** @@ -84,6 +86,13 @@ private: * implement this method. */ virtual Vector DoGetVelocity (void) const = 0; + + /** + * Used to alert subscribers that a change in direction, velocity, + * or position has occurred. + */ + TracedCallback > m_trace; + }; }; // namespace ns3 diff --git a/src/mobility/mobility.h b/src/mobility/mobility.h index 6ec1f2541..cca34b6e6 100644 --- a/src/mobility/mobility.h +++ b/src/mobility/mobility.h @@ -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 diff --git a/src/mobility/wscript b/src/mobility/wscript index bd022f38a..2ce6b1844 100644 --- a/src/mobility/wscript +++ b/src/mobility/wscript @@ -6,7 +6,6 @@ def build(bld): '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 @@ def build(bld): 'vector.h', 'hierarchical-mobility-model.h', 'mobility-model.h', - 'mobility-model-notifier.h', 'position-allocator.h', 'rectangle.h', 'static-mobility-model.h', diff --git a/src/node/net-device.h b/src/node/net-device.h index ef6dc69d8..4f3e93d6c 100644 --- a/src/node/net-device.h +++ b/src/node/net-device.h @@ -32,7 +32,6 @@ namespace ns3 { class Node; -class TraceContext; class Channel; class Packet; diff --git a/src/node/node.h b/src/node/node.h index cac3dd22f..272d0f52c 100644 --- a/src/node/node.h +++ b/src/node/node.h @@ -29,7 +29,6 @@ namespace ns3 { -class TraceContext; class NetDevice; class Application; class Packet;