get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.

This commit is contained in:
Mathieu Lacage
2008-04-09 12:15:24 -07:00
parent d4cd3c92fd
commit e110fea8ff
16 changed files with 78 additions and 393 deletions

View File

@@ -159,7 +159,7 @@ main (int argc, char *argv[])
// specified by the default classId
Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ("RanVar", UniformVariable (0.0, 1.0),
"ErrorRate", Double (0.001));
d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", em);
d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", Pointer (em));
// Now, let's use the ListErrorModel and explicitly force a loss
// of the packets with pkt-uids = 11 and 17 on node 2, device 0
@@ -169,7 +169,7 @@ main (int argc, char *argv[])
// This time, we'll explicitly create the error model we want
Ptr<ListErrorModel> pem = CreateObject<ListErrorModel> ();
pem->SetList (sampleList);
d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", pem);
d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", Pointer (pem));
std::ofstream ascii;
ascii.open ("simple-error-model.tr");

View File

@@ -24,6 +24,7 @@
#include "ns3/config.h"
#include "ns3/uinteger.h"
#include "ns3/string.h"
#include "ns3/pointer.h"
#include "ns3/simulator.h"
#include "ns3/node.h"
@@ -87,7 +88,7 @@ main (int argc, char *argv[])
// First, we observe that we can get a pointer to the (base class)
// queue via the PointToPointNetDevice attributes, where it is called
// TxQueue
Ptr<Queue> txQueue = net0->GetAttribute ("TxQueue");
Ptr<Queue> txQueue = Pointer (net0->GetAttribute ("TxQueue"));
// Using the GetObject function, we can perform a safe downcast
// to a DropTailQueue, where MaxPackets is a member

View File

@@ -109,10 +109,6 @@ public:
MakeBooleanAccessor (&AttributeObjectTest::DoSetTestB,
&AttributeObjectTest::DoGetTestB),
MakeBooleanChecker ())
.AddAttribute ("TestPtr", "help text",
Ptr<Derived> (0),
MakePtrAccessor (&AttributeObjectTest::m_derived),
MakePtrChecker<Derived> ())
.AddAttribute ("TestInt16", "help text",
Integer (-2),
MakeIntegerAccessor (&AttributeObjectTest::m_int16),
@@ -219,7 +215,6 @@ private:
}
bool m_boolTestA;
bool m_boolTest;
Ptr<Derived> m_derived;
int16_t m_int16;
int16_t m_int16WithBounds;
int16_t m_int16SetGet;
@@ -298,23 +293,6 @@ AttributeTest::RunTests (void)
CHECK_GET_PARAM (p, "TestBoolA", Boolean, true);
Ptr<Derived> derived = p->GetAttribute ("TestPtr");
NS_TEST_ASSERT (derived == 0);
derived = Create<Derived> ();
NS_TEST_ASSERT (p->SetAttributeFailSafe("TestPtr", derived));
Ptr<Derived> stored = p->GetAttribute ("TestPtr");
NS_TEST_ASSERT (stored == derived);
Ptr<Object> storedBase = p->GetAttribute ("TestPtr");
NS_TEST_ASSERT (stored == storedBase);
Ptr<AttributeObjectTest> x = p->GetAttribute ("TestPtr");
NS_TEST_ASSERT (x == 0);
p = CreateObject<AttributeObjectTest> ("TestPtr", Create<Derived> ());
NS_TEST_ASSERT (p != 0);
derived = 0;
derived = p->GetAttribute ("TestPtr");
NS_TEST_ASSERT (derived != 0);
CHECK_GET_STR (p, "TestInt16", "-2");
CHECK_GET_PARAM (p, "TestInt16", Integer, -2);
@@ -488,16 +466,15 @@ AttributeTest::RunTests (void)
NS_TEST_ASSERT (p->TraceConnectWithoutContext ("ValueSource", MakeCallback (&AttributeTest::NotifySourceValue, this)));
derived = Pointer (p->GetAttribute ("Pointer"));
Ptr<Derived>derived = Pointer (p->GetAttribute ("Pointer"));
NS_TEST_ASSERT (derived == 0);
derived = Create<Derived> ();
NS_TEST_ASSERT (p->SetAttributeFailSafe("Pointer", Pointer (derived)));
stored = Pointer (p->GetAttribute ("Pointer"));
Ptr<Derived> stored = Pointer (p->GetAttribute ("Pointer"));
NS_TEST_ASSERT (stored == derived);
storedBase = Pointer (p->GetAttribute ("Pointer"));
Ptr<Object> storedBase = Pointer (p->GetAttribute ("Pointer"));
NS_TEST_ASSERT (stored == storedBase);
x = Pointer (p->GetAttribute ("Pointer"));
Ptr<AttributeObjectTest> x = Pointer (p->GetAttribute ("Pointer"));
NS_TEST_ASSERT (x == 0);
p = CreateObject<AttributeObjectTest> ("Pointer", Pointer (Create<Derived> ()));

View File

@@ -172,19 +172,4 @@ AttributeChecker::Unref (void) const
AttributeChecker::~AttributeChecker ()
{}
std::string
PtrValueBase::SerializeToString (Ptr<const AttributeChecker> checker) const
{
std::ostringstream oss;
oss << PeekObjectBase ();
return oss.str ();
}
bool
PtrValueBase::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
{
// XXX
return false;
}
} // namespace ns3

View File

@@ -135,17 +135,6 @@ public:
template <typename T>
T DynCast (void) const;
/**
* \param pointer a pointer to convert into an Attribute.
*/
template <typename T>
Attribute (Ptr<T> pointer);
/**
* \returns a pointer converted from this Attribute instance.
*/
template <typename T>
operator Ptr<T> ();
private:
Attribute (AttributeValue *value);
AttributeValue *m_value;
@@ -231,170 +220,10 @@ private:
mutable uint32_t m_count;
};
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (Ptr<U> T::*memberVariable);
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (void (T::*setter) (Ptr<U>));
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (Ptr<U> (T::*getter) (void) const);
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (void (T::*setter) (Ptr<U>),
Ptr<U> (T::*getter) (void) const);
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (Ptr<U> (T::*getter) (void) const,
void (T::*setter) (Ptr<U>));
class PtrChecker : public AttributeChecker {};
template <typename T>
Ptr<AttributeChecker> MakePtrChecker (void);
} // namespace ns3
namespace ns3 {
/********************************************************
* The class used to access the pointer stored in a
* PtrValue<T> AttributeValue instance.
********************************************************/
class PtrValueBase : public AttributeValue
{
public:
virtual ObjectBase *PeekObjectBase (void) const = 0;
virtual bool SetObjectBase (ObjectBase *object) = 0;
virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
};
/********************************************************
* Store the content of a Ptr<T> in a AttributeValue
********************************************************/
namespace internal {
template <typename T>
class PtrValue : public PtrValueBase
{
public:
PtrValue ()
: m_pointer () {}
PtrValue (Ptr<T> pointer)
: m_pointer (pointer) {}
virtual ObjectBase *PeekObjectBase (void) const {
return PeekPointer (m_pointer);
}
virtual bool SetObjectBase (ObjectBase *object) {
T *ptr = dynamic_cast<T *> (object);
if (ptr == 0)
{
return false;
}
m_pointer = ptr;
return true;
}
virtual Attribute Copy (void) const {
return Attribute::Create<PtrValue<T> > (*this);
}
private:
Ptr<T> m_pointer;
};
template <typename T>
class APtrChecker : public PtrChecker
{
virtual bool Check (Attribute val) const {
const PtrValueBase *value = val.DynCast<const PtrValueBase *> ();
if (value == 0)
{
return false;
}
if (value->PeekObjectBase () == 0)
{
return true;
}
T *ptr = dynamic_cast<T*> (value->PeekObjectBase ());
if (ptr == 0)
{
return false;
}
return true;
}
virtual std::string GetType (void) const {
// XXX: we should be able to return better information
return "Ptr<>";
}
virtual bool HasTypeConstraints (void) const {
return false;
}
virtual std::string GetTypeConstraints (void) const {
return "";
}
virtual Attribute Create (void) const {
return Attribute::Create<PtrValue<T> > ();
}
};
/********************************************************
* The Accessor associated to
* PtrValue<T>
********************************************************/
template <typename T, typename U>
class PtrAccessor : public AttributeAccessor
{
public:
virtual ~PtrAccessor () {}
virtual bool Set (ObjectBase * object, Attribute val) const {
T *obj = dynamic_cast<T *> (object);
if (obj == 0)
{
return false;
}
const PtrValueBase *value = val.DynCast<const PtrValueBase *> ();
if (value == 0)
{
return false;
}
Ptr<U> ptr = dynamic_cast<U*> (value->PeekObjectBase ());
if (ptr == 0)
{
return false;
}
DoSet (obj, ptr);
return true;
}
virtual bool Get (const ObjectBase * object, Attribute val) const {
const T *obj = dynamic_cast<const T *> (object);
if (obj == 0)
{
return false;
}
PtrValueBase *value = val.DynCast<PtrValueBase *> ();
if (value == 0)
{
return false;
}
return value->SetObjectBase (PeekPointer (DoGet (obj)));
}
private:
virtual void DoSet (T *object, Ptr<U> value) const = 0;
virtual Ptr<U> DoGet (const T *object) const = 0;
};
} // namespace internal
/********************************************************
* The implementation of the Attribute
* class template methods.
@@ -420,120 +249,6 @@ Attribute::DynCast (void) const
return dynamic_cast<T> (m_value);
}
template <typename T>
Attribute::Attribute (Ptr<T> pointer)
: m_value (new internal::PtrValue<T> (pointer))
{}
template <typename T>
Attribute::operator Ptr<T> ()
{
PtrValueBase *value = DynCast<PtrValueBase *> ();
if (value == 0)
{
return 0;
}
ObjectBase *objectBase = value->PeekObjectBase ();
T *obj = dynamic_cast<T *> (objectBase);
if (obj == 0)
{
return 0;
}
return obj;
}
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (Ptr<U> T::*memberVariable)
{
struct MemberVariable : public internal::PtrAccessor<T,U>
{
Ptr<U> T::*m_memberVariable;
virtual void DoSet (T *object, Ptr<U> value) const {
(object->*m_memberVariable) = value;
}
virtual Ptr<U> DoGet (const T *object) const {
return object->*m_memberVariable;
}
} *spec = new MemberVariable ();
spec->m_memberVariable = memberVariable;
return Ptr<const AttributeAccessor> (spec, false);
}
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (void (T::*setter) (Ptr<U>))
{
struct MemberMethod : public internal::PtrAccessor<T,U>
{
void (T::*m_setter) (Ptr<U>);
virtual void DoSet (T *object, Ptr<U> value) const {
(object->*m_setter) (value);
}
virtual Ptr<U> DoGet (const T *object) const {
return 0;
//return (object->*m_getter) ();
}
} *spec = new MemberMethod ();
spec->m_setter = setter;
return Ptr<const AttributeAccessor> (spec, false);
}
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (Ptr<U> (T::*getter) (void) const)
{
struct MemberMethod : public internal::PtrAccessor<T,U>
{
Ptr<U> (T::*m_getter) (void) const;
virtual void DoSet (T *object, Ptr<U> value) const {
//(object->*m_setter) (value);
}
virtual Ptr<U> DoGet (const T *object) const {
return (object->*m_getter) ();
}
} *spec = new MemberMethod ();
spec->m_getter = getter;
return Ptr<const AttributeAccessor> (spec, false);
}
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (void (T::*setter) (Ptr<U>),
Ptr<U> (T::*getter) (void) const)
{
return MakePtrAccessor (getter, setter);
}
template <typename T, typename U>
Ptr<const AttributeAccessor>
MakePtrAccessor (Ptr<U> (T::*getter) (void) const,
void (T::*setter) (Ptr<U>))
{
struct MemberMethod : public internal::PtrAccessor<T,U>
{
void (T::*m_setter) (Ptr<U>);
Ptr<U> (T::*m_getter) (void) const;
virtual void DoSet (T *object, Ptr<U> value) const {
(object->*m_setter) (value);
}
virtual Ptr<U> DoGet (const T *object) const {
return (object->*m_getter) ();
}
} *spec = new MemberMethod ();
spec->m_setter = setter;
spec->m_getter = getter;
return Ptr<const AttributeAccessor> (spec, false);
}
template <typename T>
Ptr<AttributeChecker>
MakePtrChecker (void)
{
return Create<internal::APtrChecker<T> > ();
}
} // namespace ns3
#endif /* ATTRIBUTE_H */

View File

@@ -22,6 +22,7 @@
#include "object.h"
#include "global-value.h"
#include "object-vector.h"
#include "pointer.h"
#include "log.h"
#include <sstream>
@@ -213,14 +214,11 @@ Resolver::DoResolve (std::string path, Ptr<Object> root)
return;
}
// attempt to cast to a pointer checker.
const PtrChecker *ptr = dynamic_cast<const PtrChecker *> (PeekPointer (info.checker));
const PointerChecker *ptr = dynamic_cast<const PointerChecker *> (PeekPointer (info.checker));
if (ptr != 0)
{
NS_LOG_DEBUG ("GetAttribute(ptr)="<<item<<" on path="<<GetResolvedPath (""));
// XXX: This is not completely right because anything could be stored in a
// Ptr<>. We really need to fix this by thinking seriously about our
// object hierarchy.
Ptr<Object> object = root->GetAttribute (item);
Ptr<Object> object = Pointer (root->GetAttribute (item));
if (object == 0)
{
NS_LOG_ERROR ("Requested object name=\""<<item<<
@@ -520,13 +518,13 @@ TypeId MyNode::GetTypeId (void)
MakeObjectVectorAccessor (&MyNode::m_nodesB),
MakeObjectVectorChecker ())
.AddAttribute ("NodeA", "",
Ptr<MyNode> (0),
MakePtrAccessor (&MyNode::m_nodeA),
MakePtrChecker<MyNode> ())
Pointer (),
MakePointerAccessor (&MyNode::m_nodeA),
MakePointerChecker<MyNode> ())
.AddAttribute ("NodeB", "",
Ptr<MyNode> (0),
MakePtrAccessor (&MyNode::m_nodeB),
MakePtrChecker<MyNode> ())
Pointer (),
MakePointerAccessor (&MyNode::m_nodeB),
MakePointerChecker<MyNode> ())
.AddAttribute ("A", "",
Integer (10),
MakeIntegerAccessor (&MyNode::m_a),

View File

@@ -88,7 +88,7 @@ namespace ns3 {
namespace internal {
template <typename T>
class APointerChecker : public PtrChecker
class APointerChecker : public PointerChecker
{
virtual bool Check (Attribute val) const {
const PointerValue *value = val.DynCast<const PointerValue *> ();

View File

@@ -27,6 +27,7 @@
#include "ns3/error-model.h"
#include "ns3/enum.h"
#include "ns3/boolean.h"
#include "ns3/pointer.h"
#include "ns3/trace-source-accessor.h"
#include "csma-net-device.h"
#include "csma-channel.h"
@@ -68,13 +69,13 @@ CsmaNetDevice::GetTypeId (void)
MakeDataRateAccessor (&CsmaNetDevice::m_bps),
MakeDataRateChecker ())
.AddAttribute ("RxErrorModel", "XXX",
Ptr<ErrorModel> (0),
MakePtrAccessor (&CsmaNetDevice::m_receiveErrorModel),
MakePtrChecker<ErrorModel> ())
Pointer (),
MakePointerAccessor (&CsmaNetDevice::m_receiveErrorModel),
MakePointerChecker<ErrorModel> ())
.AddAttribute ("TxQueue", "XXX",
Ptr<Queue> (0),
MakePtrAccessor (&CsmaNetDevice::m_queue),
MakePtrChecker<Queue> ())
Pointer (),
MakePointerAccessor (&CsmaNetDevice::m_queue),
MakePointerChecker<Queue> ())
.AddTraceSource ("Rx", "Receive MAC packet.",
MakeTraceSourceAccessor (&CsmaNetDevice::m_rxTrace))
.AddTraceSource ("Drop", "Drop MAC packet.",

View File

@@ -26,6 +26,7 @@
#include "ns3/llc-snap-header.h"
#include "ns3/error-model.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/pointer.h"
#include "point-to-point-net-device.h"
#include "point-to-point-channel.h"
@@ -50,13 +51,13 @@ PointToPointNetDevice::GetTypeId (void)
MakeDataRateAccessor (&PointToPointNetDevice::m_bps),
MakeDataRateChecker ())
.AddAttribute ("ReceiveErrorModel", "XXX",
Ptr<ErrorModel> (0),
MakePtrAccessor (&PointToPointNetDevice::m_receiveErrorModel),
MakePtrChecker<ErrorModel> ())
Pointer (),
MakePointerAccessor (&PointToPointNetDevice::m_receiveErrorModel),
MakePointerChecker<ErrorModel> ())
.AddAttribute ("TxQueue", "XXX",
Ptr<Queue> (0),
MakePtrAccessor (&PointToPointNetDevice::m_queue),
MakePtrChecker<Queue> ())
Pointer (),
MakePointerAccessor (&PointToPointNetDevice::m_queue),
MakePointerChecker<Queue> ())
.AddAttribute ("InterframeGap", "XXX",
Seconds (0.0),
MakeTimeAccessor (&PointToPointNetDevice::m_tInterframeGap),

View File

@@ -22,6 +22,7 @@
#include "ns3/mobility-model.h"
#include "ns3/static-mobility-model.h"
#include "ns3/double.h"
#include "ns3/pointer.h"
#include <math.h>
NS_LOG_COMPONENT_DEFINE ("PropagationLossModel");
@@ -192,9 +193,9 @@ LogDistancePropagationLossModel::GetTypeId (void)
MakeDoubleChecker<double> ())
.AddAttribute ("ReferenceModel",
"The reference model at the reference distance.",
Ptr<PropagationLossModel> (0),
MakePtrAccessor (&LogDistancePropagationLossModel::m_reference),
MakePtrChecker<PropagationLossModel> ())
Pointer (),
MakePointerAccessor (&LogDistancePropagationLossModel::m_reference),
MakePointerChecker<PropagationLossModel> ())
;
return tid;

View File

@@ -23,6 +23,7 @@
#include "ns3/net-device.h"
#include "ns3/node.h"
#include "ns3/log.h"
#include "ns3/pointer.h"
#include "wifi-channel.h"
#include "propagation-loss-model.h"
#include "propagation-delay-model.h"
@@ -38,13 +39,13 @@ WifiChannel::GetTypdId (void)
.SetParent<WifiChannel> ()
.AddConstructor<WifiChannel> ()
.AddAttribute ("PropagationLossModel", "XXX",
Ptr<PropagationLossModel> (0),
MakePtrAccessor (&WifiChannel::m_loss),
MakePtrChecker<PropagationLossModel> ())
Pointer (),
MakePointerAccessor (&WifiChannel::m_loss),
MakePointerChecker<PropagationLossModel> ())
.AddAttribute ("PropagationDelayModel", "XXX",
Ptr<PropagationDelayModel> (0),
MakePtrAccessor (&WifiChannel::m_delay),
MakePtrChecker<PropagationDelayModel> ())
Pointer (),
MakePointerAccessor (&WifiChannel::m_delay),
MakePointerChecker<PropagationDelayModel> ())
;
return tid;
}

View File

@@ -25,6 +25,7 @@
#include "ns3/llc-snap-header.h"
#include "ns3/packet.h"
#include "ns3/uinteger.h"
#include "ns3/pointer.h"
#include "ns3/node.h"
#include "ns3/trace-source-accessor.h"
@@ -36,25 +37,25 @@ WifiNetDevice::GetTypeId (void)
static TypeId tid = TypeId ("ns3::WifiNetDevice")
.SetParent<NetDevice> ()
.AddAttribute ("Channel", "XXX",
Ptr<Channel> (0),
MakePtrAccessor (&WifiNetDevice::DoGetChannel,
&WifiNetDevice::SetChannel),
MakePtrChecker<Channel> ())
Pointer (),
MakePointerAccessor (&WifiNetDevice::DoGetChannel,
&WifiNetDevice::SetChannel),
MakePointerChecker<Channel> ())
.AddAttribute ("Phy", "XXX",
Ptr<WifiPhy> (0),
MakePtrAccessor (&WifiNetDevice::GetPhy,
&WifiNetDevice::SetPhy),
MakePtrChecker<WifiPhy> ())
Pointer (),
MakePointerAccessor (&WifiNetDevice::GetPhy,
&WifiNetDevice::SetPhy),
MakePointerChecker<WifiPhy> ())
.AddAttribute ("Mac", "XXX",
Ptr<WifiMac> (0),
MakePtrAccessor (&WifiNetDevice::GetMac,
&WifiNetDevice::SetMac),
MakePtrChecker<WifiMac> ())
Pointer (),
MakePointerAccessor (&WifiNetDevice::GetMac,
&WifiNetDevice::SetMac),
MakePointerChecker<WifiMac> ())
.AddAttribute ("RemoteStationManager", "XXX",
Ptr<WifiRemoteStationManager> (0),
MakePtrAccessor (&WifiNetDevice::SetRemoteStationManager,
&WifiNetDevice::GetRemoteStationManager),
MakePtrChecker<WifiRemoteStationManager> ())
Pointer (),
MakePointerAccessor (&WifiNetDevice::SetRemoteStationManager,
&WifiNetDevice::GetRemoteStationManager),
MakePointerChecker<WifiRemoteStationManager> ())
.AddTraceSource ("Rx", "XXX",
MakeTraceSourceAccessor (&WifiNetDevice::m_rxLogger))
.AddTraceSource ("Tx", "XXX",

View File

@@ -23,6 +23,7 @@
#include "ns3/position-allocator.h"
#include "ns3/hierarchical-mobility-model.h"
#include "ns3/log.h"
#include "ns3/pointer.h"
namespace ns3 {
@@ -146,8 +147,8 @@ MobilityHelper::Layout (NodeContainer c)
// we need to setup a hierarchical mobility model
Ptr<MobilityModel> parent = m_mobilityStack.back ();
Ptr<MobilityModel> hierarchical =
CreateObject<HierarchicalMobilityModel> ("Child", model,
"Parent", parent);
CreateObject<HierarchicalMobilityModel> ("Child", Pointer (model),
"Parent", Pointer (parent));
object->AggregateObject (hierarchical);
NS_LOG_DEBUG ("node="<<object<<", mob="<<hierarchical);
}

View File

@@ -19,6 +19,7 @@
*/
#include "hierarchical-mobility-model.h"
#include "mobility-model-notifier.h"
#include "ns3/pointer.h"
namespace ns3 {
@@ -31,13 +32,13 @@ HierarchicalMobilityModel::GetTypeId (void)
.SetParent<MobilityModel> ()
.AddConstructor<HierarchicalMobilityModel> ()
.AddAttribute ("Child", "The child mobility model.",
Ptr<MobilityModel> (0),
MakePtrAccessor (&HierarchicalMobilityModel::SetChild),
MakePtrChecker<MobilityModel> ())
Pointer (),
MakePointerAccessor (&HierarchicalMobilityModel::SetChild),
MakePointerChecker<MobilityModel> ())
.AddAttribute ("Parent", "The parent mobility model.",
Ptr<MobilityModel> (0),
MakePtrAccessor (&HierarchicalMobilityModel::SetParent),
MakePtrChecker<MobilityModel> ())
Pointer (),
MakePointerAccessor (&HierarchicalMobilityModel::SetParent),
MakePointerChecker<MobilityModel> ())
;
return tid;
}

View File

@@ -20,6 +20,7 @@
#include <cmath>
#include "ns3/simulator.h"
#include "ns3/random-variable.h"
#include "ns3/pointer.h"
#include "random-waypoint-mobility-model.h"
#include "position-allocator.h"
@@ -46,9 +47,9 @@ RandomWaypointMobilityModel::GetTypeId (void)
MakeRandomVariableChecker ())
.AddAttribute ("Position",
"The position model used to pick a destination point.",
Ptr<PositionAllocator> (0),
MakePtrAccessor (&RandomWaypointMobilityModel::m_position),
MakePtrChecker<PositionAllocator> ());
Pointer (),
MakePointerAccessor (&RandomWaypointMobilityModel::m_position),
MakePointerChecker<PositionAllocator> ());
return tid;
}

View File

@@ -23,6 +23,7 @@
#include "event-impl.h"
#include "ns3/ptr.h"
#include "ns3/pointer.h"
#include "ns3/assert.h"
@@ -108,10 +109,10 @@ SimulatorPrivate::GetTypeId (void)
.AddConstructor<SimulatorPrivate> ()
.AddAttribute ("Scheduler",
"XXX",
Ptr<Scheduler> (0),
Pointer (),
// XXX: allow getting the scheduler too.
MakePtrAccessor (&SimulatorPrivate::SetScheduler),
MakePtrChecker<Scheduler> ())
MakePointerAccessor (&SimulatorPrivate::SetScheduler),
MakePointerChecker<Scheduler> ())
;
return tid;
}