get rid of implicit conversion of Attribute to/from Ptr<>. Replace this with an explicit Pointer class.
1.1 --- a/examples/simple-error-model.cc Wed Apr 09 11:46:04 2008 -0700
1.2 +++ b/examples/simple-error-model.cc Wed Apr 09 12:15:24 2008 -0700
1.3 @@ -159,7 +159,7 @@
1.4 // specified by the default classId
1.5 Ptr<RateErrorModel> em = CreateObject<RateErrorModel> ("RanVar", UniformVariable (0.0, 1.0),
1.6 "ErrorRate", Double (0.001));
1.7 - d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", em);
1.8 + d3d2.Get (0)->SetAttribute ("ReceiveErrorModel", Pointer (em));
1.9
1.10 // Now, let's use the ListErrorModel and explicitly force a loss
1.11 // of the packets with pkt-uids = 11 and 17 on node 2, device 0
1.12 @@ -169,7 +169,7 @@
1.13 // This time, we'll explicitly create the error model we want
1.14 Ptr<ListErrorModel> pem = CreateObject<ListErrorModel> ();
1.15 pem->SetList (sampleList);
1.16 - d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", pem);
1.17 + d0d2.Get (1)->SetAttribute ("ReceiveErrorModel", Pointer (pem));
1.18
1.19 std::ofstream ascii;
1.20 ascii.open ("simple-error-model.tr");
2.1 --- a/samples/main-attribute-value.cc Wed Apr 09 11:46:04 2008 -0700
2.2 +++ b/samples/main-attribute-value.cc Wed Apr 09 12:15:24 2008 -0700
2.3 @@ -24,6 +24,7 @@
2.4 #include "ns3/config.h"
2.5 #include "ns3/uinteger.h"
2.6 #include "ns3/string.h"
2.7 +#include "ns3/pointer.h"
2.8 #include "ns3/simulator.h"
2.9
2.10 #include "ns3/node.h"
2.11 @@ -87,7 +88,7 @@
2.12 // First, we observe that we can get a pointer to the (base class)
2.13 // queue via the PointToPointNetDevice attributes, where it is called
2.14 // TxQueue
2.15 - Ptr<Queue> txQueue = net0->GetAttribute ("TxQueue");
2.16 + Ptr<Queue> txQueue = Pointer (net0->GetAttribute ("TxQueue"));
2.17
2.18 // Using the GetObject function, we can perform a safe downcast
2.19 // to a DropTailQueue, where MaxPackets is a member
3.1 --- a/src/core/attribute-test.cc Wed Apr 09 11:46:04 2008 -0700
3.2 +++ b/src/core/attribute-test.cc Wed Apr 09 12:15:24 2008 -0700
3.3 @@ -109,10 +109,6 @@
3.4 MakeBooleanAccessor (&AttributeObjectTest::DoSetTestB,
3.5 &AttributeObjectTest::DoGetTestB),
3.6 MakeBooleanChecker ())
3.7 - .AddAttribute ("TestPtr", "help text",
3.8 - Ptr<Derived> (0),
3.9 - MakePtrAccessor (&AttributeObjectTest::m_derived),
3.10 - MakePtrChecker<Derived> ())
3.11 .AddAttribute ("TestInt16", "help text",
3.12 Integer (-2),
3.13 MakeIntegerAccessor (&AttributeObjectTest::m_int16),
3.14 @@ -219,7 +215,6 @@
3.15 }
3.16 bool m_boolTestA;
3.17 bool m_boolTest;
3.18 - Ptr<Derived> m_derived;
3.19 int16_t m_int16;
3.20 int16_t m_int16WithBounds;
3.21 int16_t m_int16SetGet;
3.22 @@ -298,23 +293,6 @@
3.23 CHECK_GET_PARAM (p, "TestBoolA", Boolean, true);
3.24
3.25
3.26 - Ptr<Derived> derived = p->GetAttribute ("TestPtr");
3.27 - NS_TEST_ASSERT (derived == 0);
3.28 - derived = Create<Derived> ();
3.29 - NS_TEST_ASSERT (p->SetAttributeFailSafe("TestPtr", derived));
3.30 - Ptr<Derived> stored = p->GetAttribute ("TestPtr");
3.31 - NS_TEST_ASSERT (stored == derived);
3.32 - Ptr<Object> storedBase = p->GetAttribute ("TestPtr");
3.33 - NS_TEST_ASSERT (stored == storedBase);
3.34 - Ptr<AttributeObjectTest> x = p->GetAttribute ("TestPtr");
3.35 - NS_TEST_ASSERT (x == 0);
3.36 -
3.37 - p = CreateObject<AttributeObjectTest> ("TestPtr", Create<Derived> ());
3.38 - NS_TEST_ASSERT (p != 0);
3.39 - derived = 0;
3.40 - derived = p->GetAttribute ("TestPtr");
3.41 - NS_TEST_ASSERT (derived != 0);
3.42 -
3.43 CHECK_GET_STR (p, "TestInt16", "-2");
3.44 CHECK_GET_PARAM (p, "TestInt16", Integer, -2);
3.45
3.46 @@ -488,16 +466,15 @@
3.47
3.48 NS_TEST_ASSERT (p->TraceConnectWithoutContext ("ValueSource", MakeCallback (&AttributeTest::NotifySourceValue, this)));
3.49
3.50 -
3.51 - derived = Pointer (p->GetAttribute ("Pointer"));
3.52 + Ptr<Derived>derived = Pointer (p->GetAttribute ("Pointer"));
3.53 NS_TEST_ASSERT (derived == 0);
3.54 derived = Create<Derived> ();
3.55 NS_TEST_ASSERT (p->SetAttributeFailSafe("Pointer", Pointer (derived)));
3.56 - stored = Pointer (p->GetAttribute ("Pointer"));
3.57 + Ptr<Derived> stored = Pointer (p->GetAttribute ("Pointer"));
3.58 NS_TEST_ASSERT (stored == derived);
3.59 - storedBase = Pointer (p->GetAttribute ("Pointer"));
3.60 + Ptr<Object> storedBase = Pointer (p->GetAttribute ("Pointer"));
3.61 NS_TEST_ASSERT (stored == storedBase);
3.62 - x = Pointer (p->GetAttribute ("Pointer"));
3.63 + Ptr<AttributeObjectTest> x = Pointer (p->GetAttribute ("Pointer"));
3.64 NS_TEST_ASSERT (x == 0);
3.65
3.66 p = CreateObject<AttributeObjectTest> ("Pointer", Pointer (Create<Derived> ()));
4.1 --- a/src/core/attribute.cc Wed Apr 09 11:46:04 2008 -0700
4.2 +++ b/src/core/attribute.cc Wed Apr 09 12:15:24 2008 -0700
4.3 @@ -172,19 +172,4 @@
4.4 AttributeChecker::~AttributeChecker ()
4.5 {}
4.6
4.7 -std::string
4.8 -PtrValueBase::SerializeToString (Ptr<const AttributeChecker> checker) const
4.9 -{
4.10 - std::ostringstream oss;
4.11 - oss << PeekObjectBase ();
4.12 - return oss.str ();
4.13 -}
4.14 -
4.15 -bool
4.16 -PtrValueBase::DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker)
4.17 -{
4.18 - // XXX
4.19 - return false;
4.20 -}
4.21 -
4.22 } // namespace ns3
5.1 --- a/src/core/attribute.h Wed Apr 09 11:46:04 2008 -0700
5.2 +++ b/src/core/attribute.h Wed Apr 09 12:15:24 2008 -0700
5.3 @@ -135,17 +135,6 @@
5.4 template <typename T>
5.5 T DynCast (void) const;
5.6
5.7 - /**
5.8 - * \param pointer a pointer to convert into an Attribute.
5.9 - */
5.10 - template <typename T>
5.11 - Attribute (Ptr<T> pointer);
5.12 - /**
5.13 - * \returns a pointer converted from this Attribute instance.
5.14 - */
5.15 - template <typename T>
5.16 - operator Ptr<T> ();
5.17 -
5.18 private:
5.19 Attribute (AttributeValue *value);
5.20 AttributeValue *m_value;
5.21 @@ -231,171 +220,11 @@
5.22 mutable uint32_t m_count;
5.23 };
5.24
5.25 -template <typename T, typename U>
5.26 -Ptr<const AttributeAccessor>
5.27 -MakePtrAccessor (Ptr<U> T::*memberVariable);
5.28 -
5.29 -template <typename T, typename U>
5.30 -Ptr<const AttributeAccessor>
5.31 -MakePtrAccessor (void (T::*setter) (Ptr<U>));
5.32 -template <typename T, typename U>
5.33 -Ptr<const AttributeAccessor>
5.34 -MakePtrAccessor (Ptr<U> (T::*getter) (void) const);
5.35 -template <typename T, typename U>
5.36 -Ptr<const AttributeAccessor>
5.37 -MakePtrAccessor (void (T::*setter) (Ptr<U>),
5.38 - Ptr<U> (T::*getter) (void) const);
5.39 -template <typename T, typename U>
5.40 -Ptr<const AttributeAccessor>
5.41 -MakePtrAccessor (Ptr<U> (T::*getter) (void) const,
5.42 - void (T::*setter) (Ptr<U>));
5.43 -
5.44 -
5.45 -
5.46 -class PtrChecker : public AttributeChecker {};
5.47 -
5.48 -template <typename T>
5.49 -Ptr<AttributeChecker> MakePtrChecker (void);
5.50 -
5.51 -
5.52 -
5.53 } // namespace ns3
5.54
5.55 namespace ns3 {
5.56
5.57 /********************************************************
5.58 - * The class used to access the pointer stored in a
5.59 - * PtrValue<T> AttributeValue instance.
5.60 - ********************************************************/
5.61 -
5.62 -class PtrValueBase : public AttributeValue
5.63 -{
5.64 -public:
5.65 - virtual ObjectBase *PeekObjectBase (void) const = 0;
5.66 - virtual bool SetObjectBase (ObjectBase *object) = 0;
5.67 - virtual std::string SerializeToString (Ptr<const AttributeChecker> checker) const;
5.68 - virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker);
5.69 -};
5.70 -
5.71 -/********************************************************
5.72 - * Store the content of a Ptr<T> in a AttributeValue
5.73 - ********************************************************/
5.74 -
5.75 -namespace internal {
5.76 -
5.77 -template <typename T>
5.78 -class PtrValue : public PtrValueBase
5.79 -{
5.80 -public:
5.81 - PtrValue ()
5.82 - : m_pointer () {}
5.83 - PtrValue (Ptr<T> pointer)
5.84 - : m_pointer (pointer) {}
5.85 -
5.86 - virtual ObjectBase *PeekObjectBase (void) const {
5.87 - return PeekPointer (m_pointer);
5.88 - }
5.89 - virtual bool SetObjectBase (ObjectBase *object) {
5.90 - T *ptr = dynamic_cast<T *> (object);
5.91 - if (ptr == 0)
5.92 - {
5.93 - return false;
5.94 - }
5.95 - m_pointer = ptr;
5.96 - return true;
5.97 - }
5.98 - virtual Attribute Copy (void) const {
5.99 - return Attribute::Create<PtrValue<T> > (*this);
5.100 - }
5.101 -private:
5.102 - Ptr<T> m_pointer;
5.103 -};
5.104 -
5.105 -template <typename T>
5.106 -class APtrChecker : public PtrChecker
5.107 -{
5.108 - virtual bool Check (Attribute val) const {
5.109 - const PtrValueBase *value = val.DynCast<const PtrValueBase *> ();
5.110 - if (value == 0)
5.111 - {
5.112 - return false;
5.113 - }
5.114 - if (value->PeekObjectBase () == 0)
5.115 - {
5.116 - return true;
5.117 - }
5.118 - T *ptr = dynamic_cast<T*> (value->PeekObjectBase ());
5.119 - if (ptr == 0)
5.120 - {
5.121 - return false;
5.122 - }
5.123 - return true;
5.124 - }
5.125 - virtual std::string GetType (void) const {
5.126 - // XXX: we should be able to return better information
5.127 - return "Ptr<>";
5.128 - }
5.129 - virtual bool HasTypeConstraints (void) const {
5.130 - return false;
5.131 - }
5.132 - virtual std::string GetTypeConstraints (void) const {
5.133 - return "";
5.134 - }
5.135 - virtual Attribute Create (void) const {
5.136 - return Attribute::Create<PtrValue<T> > ();
5.137 - }
5.138 -};
5.139 -
5.140 -/********************************************************
5.141 - * The Accessor associated to
5.142 - * PtrValue<T>
5.143 - ********************************************************/
5.144 -
5.145 -template <typename T, typename U>
5.146 -class PtrAccessor : public AttributeAccessor
5.147 -{
5.148 -public:
5.149 - virtual ~PtrAccessor () {}
5.150 - virtual bool Set (ObjectBase * object, Attribute val) const {
5.151 - T *obj = dynamic_cast<T *> (object);
5.152 - if (obj == 0)
5.153 - {
5.154 - return false;
5.155 - }
5.156 - const PtrValueBase *value = val.DynCast<const PtrValueBase *> ();
5.157 - if (value == 0)
5.158 - {
5.159 - return false;
5.160 - }
5.161 - Ptr<U> ptr = dynamic_cast<U*> (value->PeekObjectBase ());
5.162 - if (ptr == 0)
5.163 - {
5.164 - return false;
5.165 - }
5.166 - DoSet (obj, ptr);
5.167 - return true;
5.168 - }
5.169 - virtual bool Get (const ObjectBase * object, Attribute val) const {
5.170 - const T *obj = dynamic_cast<const T *> (object);
5.171 - if (obj == 0)
5.172 - {
5.173 - return false;
5.174 - }
5.175 - PtrValueBase *value = val.DynCast<PtrValueBase *> ();
5.176 - if (value == 0)
5.177 - {
5.178 - return false;
5.179 - }
5.180 - return value->SetObjectBase (PeekPointer (DoGet (obj)));
5.181 - }
5.182 -private:
5.183 - virtual void DoSet (T *object, Ptr<U> value) const = 0;
5.184 - virtual Ptr<U> DoGet (const T *object) const = 0;
5.185 -};
5.186 -
5.187 -} // namespace internal
5.188 -
5.189 -/********************************************************
5.190 * The implementation of the Attribute
5.191 * class template methods.
5.192 ********************************************************/
5.193 @@ -420,120 +249,6 @@
5.194 return dynamic_cast<T> (m_value);
5.195 }
5.196
5.197 -template <typename T>
5.198 -Attribute::Attribute (Ptr<T> pointer)
5.199 - : m_value (new internal::PtrValue<T> (pointer))
5.200 -{}
5.201 -template <typename T>
5.202 -Attribute::operator Ptr<T> ()
5.203 -{
5.204 - PtrValueBase *value = DynCast<PtrValueBase *> ();
5.205 - if (value == 0)
5.206 - {
5.207 - return 0;
5.208 - }
5.209 - ObjectBase *objectBase = value->PeekObjectBase ();
5.210 - T *obj = dynamic_cast<T *> (objectBase);
5.211 - if (obj == 0)
5.212 - {
5.213 - return 0;
5.214 - }
5.215 - return obj;
5.216 -}
5.217 -
5.218 -
5.219 -
5.220 -template <typename T, typename U>
5.221 -Ptr<const AttributeAccessor>
5.222 -MakePtrAccessor (Ptr<U> T::*memberVariable)
5.223 -{
5.224 - struct MemberVariable : public internal::PtrAccessor<T,U>
5.225 - {
5.226 - Ptr<U> T::*m_memberVariable;
5.227 - virtual void DoSet (T *object, Ptr<U> value) const {
5.228 - (object->*m_memberVariable) = value;
5.229 - }
5.230 - virtual Ptr<U> DoGet (const T *object) const {
5.231 - return object->*m_memberVariable;
5.232 - }
5.233 - } *spec = new MemberVariable ();
5.234 - spec->m_memberVariable = memberVariable;
5.235 - return Ptr<const AttributeAccessor> (spec, false);
5.236 -}
5.237 -
5.238 -template <typename T, typename U>
5.239 -Ptr<const AttributeAccessor>
5.240 -MakePtrAccessor (void (T::*setter) (Ptr<U>))
5.241 -{
5.242 - struct MemberMethod : public internal::PtrAccessor<T,U>
5.243 - {
5.244 - void (T::*m_setter) (Ptr<U>);
5.245 - virtual void DoSet (T *object, Ptr<U> value) const {
5.246 - (object->*m_setter) (value);
5.247 - }
5.248 - virtual Ptr<U> DoGet (const T *object) const {
5.249 - return 0;
5.250 - //return (object->*m_getter) ();
5.251 - }
5.252 - } *spec = new MemberMethod ();
5.253 - spec->m_setter = setter;
5.254 - return Ptr<const AttributeAccessor> (spec, false);
5.255 -}
5.256 -
5.257 -template <typename T, typename U>
5.258 -Ptr<const AttributeAccessor>
5.259 -MakePtrAccessor (Ptr<U> (T::*getter) (void) const)
5.260 -{
5.261 - struct MemberMethod : public internal::PtrAccessor<T,U>
5.262 - {
5.263 - Ptr<U> (T::*m_getter) (void) const;
5.264 - virtual void DoSet (T *object, Ptr<U> value) const {
5.265 - //(object->*m_setter) (value);
5.266 - }
5.267 - virtual Ptr<U> DoGet (const T *object) const {
5.268 - return (object->*m_getter) ();
5.269 - }
5.270 - } *spec = new MemberMethod ();
5.271 - spec->m_getter = getter;
5.272 - return Ptr<const AttributeAccessor> (spec, false);
5.273 -}
5.274 -template <typename T, typename U>
5.275 -Ptr<const AttributeAccessor>
5.276 -MakePtrAccessor (void (T::*setter) (Ptr<U>),
5.277 - Ptr<U> (T::*getter) (void) const)
5.278 -{
5.279 - return MakePtrAccessor (getter, setter);
5.280 -}
5.281 -template <typename T, typename U>
5.282 -Ptr<const AttributeAccessor>
5.283 -MakePtrAccessor (Ptr<U> (T::*getter) (void) const,
5.284 - void (T::*setter) (Ptr<U>))
5.285 -{
5.286 - struct MemberMethod : public internal::PtrAccessor<T,U>
5.287 - {
5.288 - void (T::*m_setter) (Ptr<U>);
5.289 - Ptr<U> (T::*m_getter) (void) const;
5.290 - virtual void DoSet (T *object, Ptr<U> value) const {
5.291 - (object->*m_setter) (value);
5.292 - }
5.293 - virtual Ptr<U> DoGet (const T *object) const {
5.294 - return (object->*m_getter) ();
5.295 - }
5.296 - } *spec = new MemberMethod ();
5.297 - spec->m_setter = setter;
5.298 - spec->m_getter = getter;
5.299 - return Ptr<const AttributeAccessor> (spec, false);
5.300 -}
5.301 -
5.302 -
5.303 -
5.304 -template <typename T>
5.305 -Ptr<AttributeChecker>
5.306 -MakePtrChecker (void)
5.307 -{
5.308 - return Create<internal::APtrChecker<T> > ();
5.309 -}
5.310 -
5.311 } // namespace ns3
5.312
5.313 #endif /* ATTRIBUTE_H */
6.1 --- a/src/core/config.cc Wed Apr 09 11:46:04 2008 -0700
6.2 +++ b/src/core/config.cc Wed Apr 09 12:15:24 2008 -0700
6.3 @@ -22,6 +22,7 @@
6.4 #include "object.h"
6.5 #include "global-value.h"
6.6 #include "object-vector.h"
6.7 +#include "pointer.h"
6.8 #include "log.h"
6.9 #include <sstream>
6.10
6.11 @@ -213,14 +214,11 @@
6.12 return;
6.13 }
6.14 // attempt to cast to a pointer checker.
6.15 - const PtrChecker *ptr = dynamic_cast<const PtrChecker *> (PeekPointer (info.checker));
6.16 + const PointerChecker *ptr = dynamic_cast<const PointerChecker *> (PeekPointer (info.checker));
6.17 if (ptr != 0)
6.18 {
6.19 NS_LOG_DEBUG ("GetAttribute(ptr)="<<item<<" on path="<<GetResolvedPath (""));
6.20 - // XXX: This is not completely right because anything could be stored in a
6.21 - // Ptr<>. We really need to fix this by thinking seriously about our
6.22 - // object hierarchy.
6.23 - Ptr<Object> object = root->GetAttribute (item);
6.24 + Ptr<Object> object = Pointer (root->GetAttribute (item));
6.25 if (object == 0)
6.26 {
6.27 NS_LOG_ERROR ("Requested object name=\""<<item<<
6.28 @@ -520,13 +518,13 @@
6.29 MakeObjectVectorAccessor (&MyNode::m_nodesB),
6.30 MakeObjectVectorChecker ())
6.31 .AddAttribute ("NodeA", "",
6.32 - Ptr<MyNode> (0),
6.33 - MakePtrAccessor (&MyNode::m_nodeA),
6.34 - MakePtrChecker<MyNode> ())
6.35 + Pointer (),
6.36 + MakePointerAccessor (&MyNode::m_nodeA),
6.37 + MakePointerChecker<MyNode> ())
6.38 .AddAttribute ("NodeB", "",
6.39 - Ptr<MyNode> (0),
6.40 - MakePtrAccessor (&MyNode::m_nodeB),
6.41 - MakePtrChecker<MyNode> ())
6.42 + Pointer (),
6.43 + MakePointerAccessor (&MyNode::m_nodeB),
6.44 + MakePointerChecker<MyNode> ())
6.45 .AddAttribute ("A", "",
6.46 Integer (10),
6.47 MakeIntegerAccessor (&MyNode::m_a),
7.1 --- a/src/core/pointer.h Wed Apr 09 11:46:04 2008 -0700
7.2 +++ b/src/core/pointer.h Wed Apr 09 12:15:24 2008 -0700
7.3 @@ -88,7 +88,7 @@
7.4 namespace internal {
7.5
7.6 template <typename T>
7.7 -class APointerChecker : public PtrChecker
7.8 +class APointerChecker : public PointerChecker
7.9 {
7.10 virtual bool Check (Attribute val) const {
7.11 const PointerValue *value = val.DynCast<const PointerValue *> ();
8.1 --- a/src/devices/csma/csma-net-device.cc Wed Apr 09 11:46:04 2008 -0700
8.2 +++ b/src/devices/csma/csma-net-device.cc Wed Apr 09 12:15:24 2008 -0700
8.3 @@ -27,6 +27,7 @@
8.4 #include "ns3/error-model.h"
8.5 #include "ns3/enum.h"
8.6 #include "ns3/boolean.h"
8.7 +#include "ns3/pointer.h"
8.8 #include "ns3/trace-source-accessor.h"
8.9 #include "csma-net-device.h"
8.10 #include "csma-channel.h"
8.11 @@ -68,13 +69,13 @@
8.12 MakeDataRateAccessor (&CsmaNetDevice::m_bps),
8.13 MakeDataRateChecker ())
8.14 .AddAttribute ("RxErrorModel", "XXX",
8.15 - Ptr<ErrorModel> (0),
8.16 - MakePtrAccessor (&CsmaNetDevice::m_receiveErrorModel),
8.17 - MakePtrChecker<ErrorModel> ())
8.18 + Pointer (),
8.19 + MakePointerAccessor (&CsmaNetDevice::m_receiveErrorModel),
8.20 + MakePointerChecker<ErrorModel> ())
8.21 .AddAttribute ("TxQueue", "XXX",
8.22 - Ptr<Queue> (0),
8.23 - MakePtrAccessor (&CsmaNetDevice::m_queue),
8.24 - MakePtrChecker<Queue> ())
8.25 + Pointer (),
8.26 + MakePointerAccessor (&CsmaNetDevice::m_queue),
8.27 + MakePointerChecker<Queue> ())
8.28 .AddTraceSource ("Rx", "Receive MAC packet.",
8.29 MakeTraceSourceAccessor (&CsmaNetDevice::m_rxTrace))
8.30 .AddTraceSource ("Drop", "Drop MAC packet.",
9.1 --- a/src/devices/point-to-point/point-to-point-net-device.cc Wed Apr 09 11:46:04 2008 -0700
9.2 +++ b/src/devices/point-to-point/point-to-point-net-device.cc Wed Apr 09 12:15:24 2008 -0700
9.3 @@ -26,6 +26,7 @@
9.4 #include "ns3/llc-snap-header.h"
9.5 #include "ns3/error-model.h"
9.6 #include "ns3/trace-source-accessor.h"
9.7 +#include "ns3/pointer.h"
9.8 #include "point-to-point-net-device.h"
9.9 #include "point-to-point-channel.h"
9.10
9.11 @@ -50,13 +51,13 @@
9.12 MakeDataRateAccessor (&PointToPointNetDevice::m_bps),
9.13 MakeDataRateChecker ())
9.14 .AddAttribute ("ReceiveErrorModel", "XXX",
9.15 - Ptr<ErrorModel> (0),
9.16 - MakePtrAccessor (&PointToPointNetDevice::m_receiveErrorModel),
9.17 - MakePtrChecker<ErrorModel> ())
9.18 + Pointer (),
9.19 + MakePointerAccessor (&PointToPointNetDevice::m_receiveErrorModel),
9.20 + MakePointerChecker<ErrorModel> ())
9.21 .AddAttribute ("TxQueue", "XXX",
9.22 - Ptr<Queue> (0),
9.23 - MakePtrAccessor (&PointToPointNetDevice::m_queue),
9.24 - MakePtrChecker<Queue> ())
9.25 + Pointer (),
9.26 + MakePointerAccessor (&PointToPointNetDevice::m_queue),
9.27 + MakePointerChecker<Queue> ())
9.28 .AddAttribute ("InterframeGap", "XXX",
9.29 Seconds (0.0),
9.30 MakeTimeAccessor (&PointToPointNetDevice::m_tInterframeGap),
10.1 --- a/src/devices/wifi/propagation-loss-model.cc Wed Apr 09 11:46:04 2008 -0700
10.2 +++ b/src/devices/wifi/propagation-loss-model.cc Wed Apr 09 12:15:24 2008 -0700
10.3 @@ -22,6 +22,7 @@
10.4 #include "ns3/mobility-model.h"
10.5 #include "ns3/static-mobility-model.h"
10.6 #include "ns3/double.h"
10.7 +#include "ns3/pointer.h"
10.8 #include <math.h>
10.9
10.10 NS_LOG_COMPONENT_DEFINE ("PropagationLossModel");
10.11 @@ -192,9 +193,9 @@
10.12 MakeDoubleChecker<double> ())
10.13 .AddAttribute ("ReferenceModel",
10.14 "The reference model at the reference distance.",
10.15 - Ptr<PropagationLossModel> (0),
10.16 - MakePtrAccessor (&LogDistancePropagationLossModel::m_reference),
10.17 - MakePtrChecker<PropagationLossModel> ())
10.18 + Pointer (),
10.19 + MakePointerAccessor (&LogDistancePropagationLossModel::m_reference),
10.20 + MakePointerChecker<PropagationLossModel> ())
10.21 ;
10.22 return tid;
10.23
11.1 --- a/src/devices/wifi/wifi-channel.cc Wed Apr 09 11:46:04 2008 -0700
11.2 +++ b/src/devices/wifi/wifi-channel.cc Wed Apr 09 12:15:24 2008 -0700
11.3 @@ -23,6 +23,7 @@
11.4 #include "ns3/net-device.h"
11.5 #include "ns3/node.h"
11.6 #include "ns3/log.h"
11.7 +#include "ns3/pointer.h"
11.8 #include "wifi-channel.h"
11.9 #include "propagation-loss-model.h"
11.10 #include "propagation-delay-model.h"
11.11 @@ -38,13 +39,13 @@
11.12 .SetParent<WifiChannel> ()
11.13 .AddConstructor<WifiChannel> ()
11.14 .AddAttribute ("PropagationLossModel", "XXX",
11.15 - Ptr<PropagationLossModel> (0),
11.16 - MakePtrAccessor (&WifiChannel::m_loss),
11.17 - MakePtrChecker<PropagationLossModel> ())
11.18 + Pointer (),
11.19 + MakePointerAccessor (&WifiChannel::m_loss),
11.20 + MakePointerChecker<PropagationLossModel> ())
11.21 .AddAttribute ("PropagationDelayModel", "XXX",
11.22 - Ptr<PropagationDelayModel> (0),
11.23 - MakePtrAccessor (&WifiChannel::m_delay),
11.24 - MakePtrChecker<PropagationDelayModel> ())
11.25 + Pointer (),
11.26 + MakePointerAccessor (&WifiChannel::m_delay),
11.27 + MakePointerChecker<PropagationDelayModel> ())
11.28 ;
11.29 return tid;
11.30 }
12.1 --- a/src/devices/wifi/wifi-net-device.cc Wed Apr 09 11:46:04 2008 -0700
12.2 +++ b/src/devices/wifi/wifi-net-device.cc Wed Apr 09 12:15:24 2008 -0700
12.3 @@ -25,6 +25,7 @@
12.4 #include "ns3/llc-snap-header.h"
12.5 #include "ns3/packet.h"
12.6 #include "ns3/uinteger.h"
12.7 +#include "ns3/pointer.h"
12.8 #include "ns3/node.h"
12.9 #include "ns3/trace-source-accessor.h"
12.10
12.11 @@ -36,25 +37,25 @@
12.12 static TypeId tid = TypeId ("ns3::WifiNetDevice")
12.13 .SetParent<NetDevice> ()
12.14 .AddAttribute ("Channel", "XXX",
12.15 - Ptr<Channel> (0),
12.16 - MakePtrAccessor (&WifiNetDevice::DoGetChannel,
12.17 - &WifiNetDevice::SetChannel),
12.18 - MakePtrChecker<Channel> ())
12.19 + Pointer (),
12.20 + MakePointerAccessor (&WifiNetDevice::DoGetChannel,
12.21 + &WifiNetDevice::SetChannel),
12.22 + MakePointerChecker<Channel> ())
12.23 .AddAttribute ("Phy", "XXX",
12.24 - Ptr<WifiPhy> (0),
12.25 - MakePtrAccessor (&WifiNetDevice::GetPhy,
12.26 - &WifiNetDevice::SetPhy),
12.27 - MakePtrChecker<WifiPhy> ())
12.28 + Pointer (),
12.29 + MakePointerAccessor (&WifiNetDevice::GetPhy,
12.30 + &WifiNetDevice::SetPhy),
12.31 + MakePointerChecker<WifiPhy> ())
12.32 .AddAttribute ("Mac", "XXX",
12.33 - Ptr<WifiMac> (0),
12.34 - MakePtrAccessor (&WifiNetDevice::GetMac,
12.35 - &WifiNetDevice::SetMac),
12.36 - MakePtrChecker<WifiMac> ())
12.37 + Pointer (),
12.38 + MakePointerAccessor (&WifiNetDevice::GetMac,
12.39 + &WifiNetDevice::SetMac),
12.40 + MakePointerChecker<WifiMac> ())
12.41 .AddAttribute ("RemoteStationManager", "XXX",
12.42 - Ptr<WifiRemoteStationManager> (0),
12.43 - MakePtrAccessor (&WifiNetDevice::SetRemoteStationManager,
12.44 - &WifiNetDevice::GetRemoteStationManager),
12.45 - MakePtrChecker<WifiRemoteStationManager> ())
12.46 + Pointer (),
12.47 + MakePointerAccessor (&WifiNetDevice::SetRemoteStationManager,
12.48 + &WifiNetDevice::GetRemoteStationManager),
12.49 + MakePointerChecker<WifiRemoteStationManager> ())
12.50 .AddTraceSource ("Rx", "XXX",
12.51 MakeTraceSourceAccessor (&WifiNetDevice::m_rxLogger))
12.52 .AddTraceSource ("Tx", "XXX",
13.1 --- a/src/helper/mobility-helper.cc Wed Apr 09 11:46:04 2008 -0700
13.2 +++ b/src/helper/mobility-helper.cc Wed Apr 09 12:15:24 2008 -0700
13.3 @@ -23,6 +23,7 @@
13.4 #include "ns3/position-allocator.h"
13.5 #include "ns3/hierarchical-mobility-model.h"
13.6 #include "ns3/log.h"
13.7 +#include "ns3/pointer.h"
13.8
13.9 namespace ns3 {
13.10
13.11 @@ -146,8 +147,8 @@
13.12 // we need to setup a hierarchical mobility model
13.13 Ptr<MobilityModel> parent = m_mobilityStack.back ();
13.14 Ptr<MobilityModel> hierarchical =
13.15 - CreateObject<HierarchicalMobilityModel> ("Child", model,
13.16 - "Parent", parent);
13.17 + CreateObject<HierarchicalMobilityModel> ("Child", Pointer (model),
13.18 + "Parent", Pointer (parent));
13.19 object->AggregateObject (hierarchical);
13.20 NS_LOG_DEBUG ("node="<<object<<", mob="<<hierarchical);
13.21 }
14.1 --- a/src/mobility/hierarchical-mobility-model.cc Wed Apr 09 11:46:04 2008 -0700
14.2 +++ b/src/mobility/hierarchical-mobility-model.cc Wed Apr 09 12:15:24 2008 -0700
14.3 @@ -19,6 +19,7 @@
14.4 */
14.5 #include "hierarchical-mobility-model.h"
14.6 #include "mobility-model-notifier.h"
14.7 +#include "ns3/pointer.h"
14.8
14.9 namespace ns3 {
14.10
14.11 @@ -31,13 +32,13 @@
14.12 .SetParent<MobilityModel> ()
14.13 .AddConstructor<HierarchicalMobilityModel> ()
14.14 .AddAttribute ("Child", "The child mobility model.",
14.15 - Ptr<MobilityModel> (0),
14.16 - MakePtrAccessor (&HierarchicalMobilityModel::SetChild),
14.17 - MakePtrChecker<MobilityModel> ())
14.18 + Pointer (),
14.19 + MakePointerAccessor (&HierarchicalMobilityModel::SetChild),
14.20 + MakePointerChecker<MobilityModel> ())
14.21 .AddAttribute ("Parent", "The parent mobility model.",
14.22 - Ptr<MobilityModel> (0),
14.23 - MakePtrAccessor (&HierarchicalMobilityModel::SetParent),
14.24 - MakePtrChecker<MobilityModel> ())
14.25 + Pointer (),
14.26 + MakePointerAccessor (&HierarchicalMobilityModel::SetParent),
14.27 + MakePointerChecker<MobilityModel> ())
14.28 ;
14.29 return tid;
14.30 }
15.1 --- a/src/mobility/random-waypoint-mobility-model.cc Wed Apr 09 11:46:04 2008 -0700
15.2 +++ b/src/mobility/random-waypoint-mobility-model.cc Wed Apr 09 12:15:24 2008 -0700
15.3 @@ -20,6 +20,7 @@
15.4 #include <cmath>
15.5 #include "ns3/simulator.h"
15.6 #include "ns3/random-variable.h"
15.7 +#include "ns3/pointer.h"
15.8 #include "random-waypoint-mobility-model.h"
15.9 #include "position-allocator.h"
15.10
15.11 @@ -46,9 +47,9 @@
15.12 MakeRandomVariableChecker ())
15.13 .AddAttribute ("Position",
15.14 "The position model used to pick a destination point.",
15.15 - Ptr<PositionAllocator> (0),
15.16 - MakePtrAccessor (&RandomWaypointMobilityModel::m_position),
15.17 - MakePtrChecker<PositionAllocator> ());
15.18 + Pointer (),
15.19 + MakePointerAccessor (&RandomWaypointMobilityModel::m_position),
15.20 + MakePointerChecker<PositionAllocator> ());
15.21
15.22 return tid;
15.23 }
16.1 --- a/src/simulator/simulator.cc Wed Apr 09 11:46:04 2008 -0700
16.2 +++ b/src/simulator/simulator.cc Wed Apr 09 12:15:24 2008 -0700
16.3 @@ -23,6 +23,7 @@
16.4 #include "event-impl.h"
16.5
16.6 #include "ns3/ptr.h"
16.7 +#include "ns3/pointer.h"
16.8 #include "ns3/assert.h"
16.9
16.10
16.11 @@ -108,10 +109,10 @@
16.12 .AddConstructor<SimulatorPrivate> ()
16.13 .AddAttribute ("Scheduler",
16.14 "XXX",
16.15 - Ptr<Scheduler> (0),
16.16 + Pointer (),
16.17 // XXX: allow getting the scheduler too.
16.18 - MakePtrAccessor (&SimulatorPrivate::SetScheduler),
16.19 - MakePtrChecker<Scheduler> ())
16.20 + MakePointerAccessor (&SimulatorPrivate::SetScheduler),
16.21 + MakePointerChecker<Scheduler> ())
16.22 ;
16.23 return tid;
16.24 }