Removed TraceContext and TraceResolver references, removed MobilityModelNotifier class, and minor changes on samples/main-random-walk.cc.

This commit is contained in:
Unknown
2008-05-14 19:24:17 -04:00
parent 9ee8930726
commit 1b12b95ee9
26 changed files with 28 additions and 212 deletions

View File

@@ -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

View File

@@ -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"),

View File

@@ -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 @@ 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));

View File

@@ -420,7 +420,6 @@ private:
* fire.
*
* @see class CallBackTraceSource
* @see class TraceResolver
*/
TracedCallback<Ptr<const Packet> > m_rxTrace;
TracedCallback<Ptr<const Packet> > m_dropTrace;

View File

@@ -267,7 +267,6 @@ private:
* fire.
*
* @see class CallBackTraceSource
* @see class TraceResolver
*/
TracedCallback<Ptr<const Packet> > m_rxTrace;
/**
@@ -275,7 +274,6 @@ private:
* fire.
*
* @see class CallBackTraceSource
* @see class TraceResolver
*/
TracedCallback<Ptr<const Packet> > m_dropTrace;

View File

@@ -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<RandomRectanglePositionAllocator>
("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<PositionAllocator> allocator)
{
m_position = allocator;
@@ -156,15 +144,6 @@ MobilityHelper::Install (NodeContainer c)
}
Vector position = m_position->GetNext ();
model->SetPosition (position);
if (m_notifierEnabled)
{
Ptr<MobilityModelNotifier> notifier =
object->GetObject<MobilityModelNotifier> ();
if (notifier == 0)
{
object->AggregateObject (CreateObject<MobilityModelNotifier> ());
}
}
}
}

View File

@@ -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<Ptr<MobilityModel> > m_mobilityStack;
bool m_notifierEnabled;
ObjectFactory m_mobility;
Ptr<PositionAllocator> m_position;
};

View File

@@ -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<StaticSpeedMobilityModel>
@@ -67,12 +55,6 @@ Ns2MobilityHelper::GetMobilityModel (std::string idString, const ObjectStore &st
model = CreateObject<StaticSpeedMobilityModel> ();
object->AggregateObject (model);
}
Ptr<MobilityModelNotifier> notifier = object->GetObject<MobilityModelNotifier> ();
if (notifier == 0)
{
notifier = CreateObject<MobilityModelNotifier> ();
object->AggregateObject (notifier);
}
return model;
}

View File

@@ -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<StaticSpeedMobilityModel> GetMobilityModel (std::string idString, const ObjectStore &store) const;
double ReadDouble (std::string valueString) const;
std::string m_filename;
bool m_notifierEnabled;
};
} // namespace ns3

View File

@@ -31,7 +31,7 @@ class ArpCache;
class NetDevice;
class Node;
class Packet;
class TraceContext;
/**
* \brief An implementation of the ARP protocol
*/

View File

@@ -27,7 +27,6 @@
namespace ns3 {
class Packet;
class TraceContext;
class AsciiTrace
{

View File

@@ -31,7 +31,6 @@ namespace ns3 {
class NetDevice;
class Packet;
class TraceContext;
/**
* \brief The IPv4 representation of a network interface

View File

@@ -32,7 +32,6 @@ namespace ns3 {
class Ipv4L4Protocol;
class Node;
class TraceContext;
/**
* \brief L4 Ipv4 Demux

View File

@@ -31,8 +31,6 @@ namespace ns3 {
class Packet;
class Ipv4Address;
class TraceResolver;
class TraceContext;
/**
* \brief L4 Protocol base class

View File

@@ -27,7 +27,6 @@
namespace ns3 {
class Packet;
class TraceContext;
class PcapWriter;
class PcapTrace

View File

@@ -37,7 +37,6 @@
namespace ns3 {
class Node;
class TraceContext;
class Socket;
class TcpHeader;
/**

View File

@@ -32,7 +32,6 @@
namespace ns3 {
class Node;
class TraceContext;
class Socket;
/**
* \brief Implementation of the UDP protocol

View File

@@ -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 @@ void
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));
}

View File

@@ -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

View File

@@ -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 */

View File

@@ -17,10 +17,12 @@
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "mobility-model.h"
#include "mobility-model-notifier.h"
#include <math.h>
#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<const MobilityModel> other) const
void
MobilityModel::NotifyCourseChange (void) const
{
Ptr<MobilityModelNotifier> notifier = GetObject<MobilityModelNotifier> ();
if (notifier != 0)
{
notifier->Notify (this);
}
m_trace(this);
}
} // namespace ns3

View File

@@ -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<Ptr<const MobilityModel> > m_trace;
};
}; // namespace ns3

View File

@@ -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

View File

@@ -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',

View File

@@ -32,7 +32,6 @@
namespace ns3 {
class Node;
class TraceContext;
class Channel;
class Packet;

View File

@@ -29,7 +29,6 @@
namespace ns3 {
class TraceContext;
class NetDevice;
class Application;
class Packet;