convert TraceResolver * to Ptr<TraceResolver>
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 10 Aug 2007 15:47:13 +0200
changeset 1333 c0d66de933e9
parent 1332 d03df65ebdb7
child 1334 e8e07f44359f
convert TraceResolver * to Ptr<TraceResolver>
src/common/array-trace-resolver.h
src/common/composite-trace-resolver.cc
src/common/composite-trace-resolver.h
src/common/trace-resolver.cc
src/common/trace-root.cc
src/common/trace-root.h
src/devices/csma-cd/csma-cd-net-device.cc
src/devices/csma-cd/csma-cd-net-device.h
src/devices/point-to-point/point-to-point-net-device.cc
src/devices/point-to-point/point-to-point-net-device.h
src/internet-node/arp-ipv4-interface.cc
src/internet-node/arp-ipv4-interface.h
src/internet-node/arp-l3-protocol.cc
src/internet-node/arp-l3-protocol.h
src/internet-node/ipv4-interface.cc
src/internet-node/ipv4-interface.h
src/internet-node/ipv4-l3-protocol.cc
src/internet-node/ipv4-l3-protocol.h
src/internet-node/ipv4-l4-demux.cc
src/internet-node/ipv4-l4-demux.h
src/internet-node/ipv4-l4-protocol.h
src/internet-node/ipv4-loopback-interface.cc
src/internet-node/ipv4-loopback-interface.h
src/internet-node/udp-l4-protocol.cc
src/internet-node/udp-l4-protocol.h
src/node/net-device.cc
src/node/net-device.h
src/node/node-list.cc
src/node/node-list.h
src/node/node.cc
src/node/node.h
src/node/queue.cc
src/node/queue.h
--- a/src/common/array-trace-resolver.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/common/array-trace-resolver.h	Fri Aug 10 15:47:13 2007 +0200
@@ -48,7 +48,7 @@
    * to provide a method named CreateTraceResolver which takes as
    * only argument a reference to a const TraceContext and returns
    * a pointer to a TraceResolver. i.e. the signature is:
-   * TraceResolver * (*) (TraceContext const &)
+   * Ptr<TraceResolver> (*) (void)
    */
   ArrayTraceResolver (Callback<uint32_t> getSize, 
                       Callback<T, uint32_t> get);
@@ -83,9 +83,8 @@
       TraceContext tmp = context;
       INDEX index = i;
       tmp.Add (index);
-      TraceResolver *resolver = m_get (i)->CreateTraceResolver ();
+      Ptr<TraceResolver> resolver = m_get (i)->CreateTraceResolver ();
       resolver->Connect (subpath, cb, tmp);
-      delete resolver;
     }
   }
 }
@@ -99,9 +98,8 @@
   {
     for (uint32_t i = 0; i < m_getSize (); i++)
     {
-      TraceResolver *resolver = m_get (i)->CreateTraceResolver ();
+      Ptr<TraceResolver> resolver = m_get (i)->CreateTraceResolver ();
       resolver->Disconnect (subpath, cb);
-      delete resolver;
     }
   }
 }
--- a/src/common/composite-trace-resolver.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/common/composite-trace-resolver.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -33,14 +33,14 @@
 
 void 
 CompositeTraceResolver::Add (std::string name, 
-                             Callback<TraceResolver *> createResolver)
+                             Callback<Ptr<TraceResolver> > createResolver)
 {
   DoAdd (name, createResolver, TraceContext ());
 }
 
 void 
 CompositeTraceResolver::DoAdd (std::string name, 
-			       Callback<TraceResolver *> createResolver,
+			       Callback<Ptr<TraceResolver> > createResolver,
 			       TraceContext const &context)
 {
   struct CallbackTraceSourceItem item;
@@ -125,7 +125,7 @@
                                       const TraceContext &context,
                                       enum Operation op)
 {
-  TraceResolver *resolver = i->createResolver ();
+  Ptr<TraceResolver> resolver = i->createResolver ();
   switch (op) {
   case CONNECT: {
     NS_DEBUG ("connect to path="<<subpath<<" name="<<i->name);
@@ -137,7 +137,6 @@
     resolver->Disconnect (subpath, cb);
     break;
   }
-  delete resolver;
 }
 
 void 
@@ -204,7 +203,7 @@
 private:
   void TraceDouble (TraceContext const &context, double v);
   void TraceInt (TraceContext const &context, int v);
-  TraceResolver *CreateSubResolver ();
+  Ptr<TraceResolver> CreateSubResolver ();
 
 
   bool m_gotDoubleA;
@@ -244,10 +243,10 @@
   m_gotInt = true;
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 CompositeTraceResolverTest::CreateSubResolver (void)
 {
-  CompositeTraceResolver *subresolver = new CompositeTraceResolver ();
+  Ptr<CompositeTraceResolver> subresolver = Create<CompositeTraceResolver> ();
   subresolver->Add ("trace-int", m_traceInt, 
                     SubTraceSourceTest (SubTraceSourceTest::INT));
   return subresolver;
--- a/src/common/composite-trace-resolver.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/common/composite-trace-resolver.h	Fri Aug 10 15:47:13 2007 +0200
@@ -22,6 +22,7 @@
 #define COMPOSITE_TRACE_RESOLVER_H
 
 #include "ns3/callback.h"
+#include "ns3/ptr.h"
 #include "trace-resolver.h"
 #include "callback-trace-source.h"
 #include "uv-trace-source.h"
@@ -109,7 +110,7 @@
    */
   template <typename T>
   void Add (std::string name, 
-            Callback<TraceResolver *> createResolver,
+            Callback<Ptr<TraceResolver> > createResolver,
             T const &context);
 
   /**
@@ -122,7 +123,7 @@
    * will be invoked to create the child trace resolver.
    */
   void Add (std::string name, 
-            Callback<TraceResolver *> createResolver);
+            Callback<Ptr<TraceResolver> > createResolver);
   virtual void Connect (std::string path, CallbackBase const &cb, const TraceContext &context);
   virtual void Disconnect (std::string path, CallbackBase const &cb);
 
@@ -130,7 +131,7 @@
   struct CallbackTraceSourceItem
   {
     std::string name;
-    Callback<TraceResolver *> createResolver;
+    Callback<Ptr<TraceResolver> > createResolver;
     TraceContext context;
   };
   typedef std::list<struct CallbackTraceSourceItem> TraceItems;
@@ -143,9 +144,9 @@
   void DoAddTraceSource (std::string name,
                          SOURCE &traceSource, CONTEXT const &context);
   template <typename SOURCE>
-  static TraceResolver *CreateTerminalTraceResolver (SOURCE *trace);
+  static Ptr<TraceResolver> CreateTerminalTraceResolver (SOURCE *trace);
   void DoAdd (std::string name, 
-              Callback<TraceResolver *> createResolver,
+              Callback<Ptr<TraceResolver> > createResolver,
               TraceContext const &context);
   void OperationOne (std::string subpath, 
                      TraceItems::const_iterator i,
@@ -170,9 +171,9 @@
 CompositeTraceResolver::DoAddTraceSource (std::string name,
                                           SOURCE &traceSource, CONTEXT const &context)
 {
-  TraceResolver *(*create) (SOURCE *trace);
+  Ptr<TraceResolver> (*create) (SOURCE *trace);
   create = &CompositeTraceResolver::CreateTerminalTraceResolver<SOURCE>;
-  Callback<TraceResolver *> createResolver = 
+  Callback<Ptr<TraceResolver> > createResolver = 
     MakeBoundCallback (create, &traceSource);
 
   TraceContext ctx;
@@ -181,10 +182,10 @@
 }
 
 template <typename SOURCE>
-TraceResolver *
+Ptr<TraceResolver>
 CompositeTraceResolver::CreateTerminalTraceResolver (SOURCE *traceSource)
 {
-  return new TerminalTraceResolver<SOURCE> (*traceSource);
+  return Create<TerminalTraceResolver<SOURCE> > (traceSource);
 }
 
 
@@ -224,7 +225,7 @@
 template <typename T>
 void 
 CompositeTraceResolver::Add (std::string name, 
-                             Callback<TraceResolver *> createResolver,
+                             Callback<Ptr<TraceResolver> > createResolver,
                              T const &context)
 {
   TraceContext ctx;
--- a/src/common/trace-resolver.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/common/trace-resolver.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -19,6 +19,9 @@
  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
  */
 #include "trace-resolver.h"
+#include "ns3/debug.h"
+
+NS_DEBUG_COMPONENT_DEFINE ("TraceResolver");
 
 namespace ns3 {
 
@@ -40,6 +43,7 @@
   m_count--;
   if (m_count == 0)
     {
+      NS_DEBUG ("delete "<<this);
       delete this;
     }
 }
--- a/src/common/trace-root.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/common/trace-root.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -27,24 +27,24 @@
 void 
 TraceRoot::Connect (std::string path, CallbackBase const &cb)
 {
-  TraceResolver *resolver = GetComposite ();
+  Ptr<TraceResolver> resolver = GetComposite ();
   resolver->Connect (path, cb, TraceContext ());
 }
 void 
 TraceRoot::Disconnect (std::string path, CallbackBase const &cb)
 {
-  TraceResolver *resolver = GetComposite ();
+  Ptr<TraceResolver> resolver = GetComposite ();
   resolver->Disconnect (path, cb);
 }
 void 
 TraceRoot::Register (std::string name, 
-                     Callback<TraceResolver *> createResolver)
+                     Callback<Ptr<TraceResolver> > createResolver)
 {
-  CompositeTraceResolver *resolver = GetComposite ();
+  Ptr<CompositeTraceResolver> resolver = GetComposite ();
   resolver->Add (name, createResolver);
 }
 
-CompositeTraceResolver *
+Ptr<CompositeTraceResolver>
 TraceRoot::GetComposite (void)
 {
   static CompositeTraceResolver resolver;
--- a/src/common/trace-root.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/common/trace-root.h	Fri Aug 10 15:47:13 2007 +0200
@@ -325,9 +325,9 @@
   static void Connect (std::string path, CallbackBase const &cb);
   static void Disconnect (std::string path, CallbackBase const &cb);
   static void Register (std::string name, 
-                        Callback<TraceResolver *> createResolver);
+                        Callback<Ptr<TraceResolver> > createResolver);
 private:
-  static CompositeTraceResolver *GetComposite (void);
+  static Ptr<CompositeTraceResolver> GetComposite (void);
 };
 
 }// namespace ns3
--- a/src/devices/csma-cd/csma-cd-net-device.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/devices/csma-cd/csma-cd-net-device.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -449,10 +449,10 @@
     }
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 CsmaCdNetDevice::DoCreateTraceResolver (void)
 {
-  CompositeTraceResolver *resolver = new CompositeTraceResolver ();
+  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->Add ("queue", 
                  MakeCallback (&Queue::CreateTraceResolver, 
                                PeekPointer (m_queue)));
--- a/src/devices/csma-cd/csma-cd-net-device.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/devices/csma-cd/csma-cd-net-device.h	Fri Aug 10 15:47:13 2007 +0200
@@ -311,7 +311,7 @@
    * (NOT TESTED)
    * @see class TraceResolver
    */
-  virtual TraceResolver *DoCreateTraceResolver (void);
+  virtual Ptr<TraceResolver> DoCreateTraceResolver (void);
 
   /**
    * Aborts the transmission of the current packet
--- a/src/devices/point-to-point/point-to-point-net-device.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -188,9 +188,10 @@
   TransmitStart(p);
 }
 
-TraceResolver* PointToPointNetDevice::DoCreateTraceResolver (void)
+Ptr<TraceResolver> 
+PointToPointNetDevice::DoCreateTraceResolver (void)
 {
-  CompositeTraceResolver *resolver = new CompositeTraceResolver ();
+  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->Add ("queue", 
                  MakeCallback (&Queue::CreateTraceResolver, PeekPointer (m_queue)));
   resolver->Add ("rx",
--- a/src/devices/point-to-point/point-to-point-net-device.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/devices/point-to-point/point-to-point-net-device.h	Fri Aug 10 15:47:13 2007 +0200
@@ -243,7 +243,7 @@
    *
    * @see class TraceResolver
    */
-  virtual TraceResolver* DoCreateTraceResolver (void);
+  virtual Ptr<TraceResolver> DoCreateTraceResolver (void);
   virtual bool DoNeedsArp (void) const;
   /**
    * Enumeration of the states of the transmit machine of the net device.
--- a/src/internet-node/arp-ipv4-interface.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/arp-ipv4-interface.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -40,10 +40,10 @@
 ArpIpv4Interface::~ArpIpv4Interface ()
 {}
 
-TraceResolver *
+Ptr<TraceResolver>
 ArpIpv4Interface::DoCreateTraceResolver (void)
 {
-  CompositeTraceResolver *resolver = new CompositeTraceResolver ();
+  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   if (GetDevice () != 0)
     {
       resolver->Add ("netdevice",
--- a/src/internet-node/arp-ipv4-interface.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/arp-ipv4-interface.h	Fri Aug 10 15:47:13 2007 +0200
@@ -44,7 +44,7 @@
 
  private:
   virtual void SendTo (Packet p, Ipv4Address dest);
-  virtual TraceResolver *DoCreateTraceResolver (void);
+  virtual Ptr<TraceResolver> DoCreateTraceResolver (void);
   Ptr<Node> m_node;
 };
 
--- a/src/internet-node/arp-l3-protocol.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/arp-l3-protocol.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -58,10 +58,10 @@
   Object::DoDispose ();
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 ArpL3Protocol::CreateTraceResolver (void)
 {
-  return new EmptyTraceResolver ();
+  return Create<EmptyTraceResolver> ();
 }
 
 ArpCache *
--- a/src/internet-node/arp-l3-protocol.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/arp-l3-protocol.h	Fri Aug 10 15:47:13 2007 +0200
@@ -49,7 +49,7 @@
   ArpL3Protocol (Ptr<Node> node);
   virtual ~ArpL3Protocol ();
 
-  virtual TraceResolver *CreateTraceResolver (void);
+  virtual Ptr<TraceResolver> CreateTraceResolver (void);
   /**
    * \brief Recieve a packet
    */
--- a/src/internet-node/ipv4-interface.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-interface.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -22,6 +22,7 @@
 #include "ipv4-interface.h"
 #include "ns3/ipv4-address.h"
 #include "ns3/net-device.h"
+#include "ns3/trace-resolver.h"
 
 namespace ns3 {
 
@@ -45,7 +46,7 @@
   return m_netdevice;
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 Ipv4Interface::CreateTraceResolver (void)
 {
   return DoCreateTraceResolver ();
--- a/src/internet-node/ipv4-interface.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-interface.h	Fri Aug 10 15:47:13 2007 +0200
@@ -83,7 +83,7 @@
    * This method will delegate the work to the private DoCreateTraceResolver 
    * method which is supposed to be implemented by subclasses.
    */
-  TraceResolver *CreateTraceResolver (void);
+  Ptr<TraceResolver> CreateTraceResolver (void);
   /**
    * \returns the underlying NetDevice. This method can return
    *          zero if this interface has no associated NetDevice.
@@ -153,7 +153,7 @@
 
  private:
   virtual void SendTo (Packet p, Ipv4Address dest) = 0;
-  virtual TraceResolver *DoCreateTraceResolver (void) = 0;
+  virtual Ptr<TraceResolver> DoCreateTraceResolver (void) = 0;
   Ptr<NetDevice> m_netdevice;
   bool m_ifup;
   Ipv4Address m_address;
--- a/src/internet-node/ipv4-l3-protocol.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -153,10 +153,10 @@
   interface->SetUp ();
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 Ipv4L3Protocol::CreateTraceResolver (void)
 {
-  CompositeTraceResolver *resolver = new CompositeTraceResolver ();
+  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->Add ("tx", m_txTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::TX));
   resolver->Add ("rx", m_rxTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::RX));
   resolver->Add ("drop", m_dropTrace, Ipv4L3ProtocolTraceContextElement (Ipv4L3ProtocolTraceContextElement::DROP));
@@ -165,11 +165,11 @@
   return resolver;
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 Ipv4L3Protocol::InterfacesCreateTraceResolver (void) const
 {
-  ArrayTraceResolver<Ipv4Interface *, Ipv4l3ProtocolInterfaceIndex> *resolver = 
-    new ArrayTraceResolver<Ipv4Interface *,Ipv4l3ProtocolInterfaceIndex> 
+  Ptr<ArrayTraceResolver<Ipv4Interface *, Ipv4l3ProtocolInterfaceIndex> >resolver = 
+    Create<ArrayTraceResolver<Ipv4Interface *,Ipv4l3ProtocolInterfaceIndex> >
     (MakeCallback (&Ipv4L3Protocol::GetNInterfaces, this),
      MakeCallback (&Ipv4L3Protocol::GetInterface, this));
   return resolver;
--- a/src/internet-node/ipv4-l3-protocol.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-l3-protocol.h	Fri Aug 10 15:47:13 2007 +0200
@@ -92,7 +92,7 @@
    *          performed in this object. The caller must
    *          delete the returned object.
    */
-  virtual TraceResolver *CreateTraceResolver (void);
+  virtual Ptr<TraceResolver> CreateTraceResolver (void);
 
   /**
    * \param ttl default ttl to use
@@ -189,7 +189,7 @@
   void ForwardUp (Packet p, Ipv4Header const&ip);
   uint32_t AddIpv4Interface (Ipv4Interface *interface);
   void SetupLoopback (void);
-  TraceResolver *InterfacesCreateTraceResolver (void) const;
+  Ptr<TraceResolver> InterfacesCreateTraceResolver (void) const;
 
   typedef std::list<Ipv4Interface*> Ipv4InterfaceList;
   typedef std::list< std::pair< int, Ptr<Ipv4RoutingProtocol> > > Ipv4RoutingProtocolList;
--- a/src/internet-node/ipv4-l4-demux.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-l4-demux.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -78,10 +78,10 @@
   Object::DoDispose ();
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 Ipv4L4Demux::CreateTraceResolver (void)
 {
-  CompositeTraceResolver *resolver = new CompositeTraceResolver ();
+  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
     {
       Ptr<Ipv4L4Protocol> protocol = *i;
--- a/src/internet-node/ipv4-l4-demux.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-l4-demux.h	Fri Aug 10 15:47:13 2007 +0200
@@ -66,7 +66,7 @@
    *          performed in this object. The caller must
    *          delete the returned object.
    */
-  TraceResolver *CreateTraceResolver (void);
+  Ptr<TraceResolver> CreateTraceResolver (void);
   /**
    * \param protocol a template for the protocol to add to this L4 Demux.
    * \returns the L4Protocol effectively added.
--- a/src/internet-node/ipv4-l4-protocol.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-l4-protocol.h	Fri Aug 10 15:47:13 2007 +0200
@@ -59,7 +59,7 @@
    */
   int GetVersion() const;
 
-  virtual TraceResolver *CreateTraceResolver () = 0;
+  virtual Ptr<TraceResolver> CreateTraceResolver () = 0;
 
   /**
    * \param p packet to forward up
--- a/src/internet-node/ipv4-loopback-interface.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-loopback-interface.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -34,10 +34,10 @@
 Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()
 {}
 
-TraceResolver *
+Ptr<TraceResolver>
 Ipv4LoopbackInterface::DoCreateTraceResolver (void)
 {
-  return new EmptyTraceResolver ();
+  return Create<EmptyTraceResolver> ();
 }
 
 void 
--- a/src/internet-node/ipv4-loopback-interface.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/ipv4-loopback-interface.h	Fri Aug 10 15:47:13 2007 +0200
@@ -43,7 +43,7 @@
 
  private:
   virtual void SendTo (Packet p, Ipv4Address dest);
-  virtual TraceResolver *DoCreateTraceResolver (void);
+  virtual Ptr<TraceResolver> DoCreateTraceResolver (void);
 
   Ptr<Node> m_node;
 };
--- a/src/internet-node/udp-l4-protocol.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/udp-l4-protocol.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -45,10 +45,10 @@
 UdpL4Protocol::~UdpL4Protocol ()
 {}
 
-TraceResolver *
+Ptr<TraceResolver>
 UdpL4Protocol::CreateTraceResolver (void)
 {
-  return new EmptyTraceResolver ();
+  return Create<EmptyTraceResolver> ();
 }
 
 void
--- a/src/internet-node/udp-l4-protocol.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/internet-node/udp-l4-protocol.h	Fri Aug 10 15:47:13 2007 +0200
@@ -49,7 +49,7 @@
   UdpL4Protocol (Ptr<Node> node);
   virtual ~UdpL4Protocol ();
 
-  virtual TraceResolver *CreateTraceResolver (void);
+  virtual Ptr<TraceResolver> CreateTraceResolver (void);
   /**
    * \return A smart Socket pointer to a UdpSocket, allocated by this instance
    * of the UDP protocol
--- a/src/node/net-device.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/node/net-device.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -23,6 +23,7 @@
 #include "ns3/assert.h"
 #include "ns3/object.h"
 #include "ns3/debug.h"
+#include "ns3/trace-resolver.h"
 
 
 #include "channel.h"
@@ -183,7 +184,7 @@
     }
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 NetDevice::CreateTraceResolver (void)
 {
   return DoCreateTraceResolver ();
--- a/src/node/net-device.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/node/net-device.h	Fri Aug 10 15:47:13 2007 +0200
@@ -69,7 +69,7 @@
    *          performed in this object. The caller must
    *          delete the returned object.
    */
-  TraceResolver *CreateTraceResolver (void);
+  Ptr<TraceResolver> CreateTraceResolver (void);
 
   /**
    * \return the channel this NetDevice is connected to. The value
@@ -290,7 +290,7 @@
    *
    * Subclasses must implement this method.
    */
-  virtual TraceResolver *DoCreateTraceResolver (void) = 0;
+  virtual Ptr<TraceResolver> DoCreateTraceResolver (void) = 0;
   /**
    * \returns the channel associated to this NetDevice.
    *
--- a/src/node/node-list.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/node/node-list.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -76,7 +76,7 @@
   uint32_t Add (Ptr<Node> node);
   NodeList::Iterator Begin (void);
   NodeList::Iterator End (void);
-  TraceResolver *CreateTraceResolver (void);
+  Ptr<TraceResolver> CreateTraceResolver (void);
   Ptr<Node> GetNode (uint32_t n);
   uint32_t GetNNodes (void);
 
@@ -130,11 +130,11 @@
 }
 
 
-TraceResolver *
+Ptr<TraceResolver>
 NodeListPriv::CreateTraceResolver (void)
 {
-  ArrayTraceResolver<Ptr<Node>, NodeListIndex> *resolver =
-    new ArrayTraceResolver<Ptr<Node>, NodeListIndex>
+  Ptr<ArrayTraceResolver<Ptr<Node>, NodeListIndex> >resolver =
+    Create<ArrayTraceResolver<Ptr<Node>, NodeListIndex> >
     (MakeCallback (&NodeListPriv::GetNNodes, this),
      MakeCallback (&NodeListPriv::GetNode, this));
   return resolver;
@@ -164,7 +164,7 @@
 {
   return SimulationSingleton<NodeListPriv>::Get ()->End ();
 }
-TraceResolver *
+Ptr<TraceResolver>
 NodeList::CreateTraceResolver (void)
 {
   return SimulationSingleton<NodeListPriv>::Get ()->CreateTraceResolver ();
--- a/src/node/node-list.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/node/node-list.h	Fri Aug 10 15:47:13 2007 +0200
@@ -79,7 +79,7 @@
    * \returns the requested trace resolver. The caller
    *          takes ownership of the returned pointer.
    */
-  static TraceResolver *CreateTraceResolver (void);
+  static Ptr<TraceResolver> CreateTraceResolver (void);
 
   /**
    * \param n index of requested node.
--- a/src/node/node.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/node/node.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -82,11 +82,11 @@
 Node::~Node ()
 {}
 
-TraceResolver *
+Ptr<TraceResolver>
 Node::CreateTraceResolver (void)
 {
-  CompositeTraceResolver *resolver = new CompositeTraceResolver ();
-  DoFillTraceResolver (*resolver);
+  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
+  DoFillTraceResolver (*PeekPointer (resolver));
   return resolver;
 }
 
@@ -141,11 +141,11 @@
   return m_applications.size ();
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 Node::CreateDevicesTraceResolver (void)
 {
-  ArrayTraceResolver<Ptr<NetDevice>,NodeNetDeviceIndex> *resolver = 
-    new ArrayTraceResolver<Ptr<NetDevice>,NodeNetDeviceIndex> 
+  Ptr<ArrayTraceResolver<Ptr<NetDevice>,NodeNetDeviceIndex> >resolver = 
+    Create<ArrayTraceResolver<Ptr<NetDevice>,NodeNetDeviceIndex> >
     (MakeCallback (&Node::GetNDevices, this), 
      MakeCallback (&Node::GetDevice, this));
   
--- a/src/node/node.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/node/node.h	Fri Aug 10 15:47:13 2007 +0200
@@ -92,7 +92,7 @@
    * could be used directly by a user who needs access to very low-level
    * trace configuration.
    */
-  TraceResolver *CreateTraceResolver (void);
+  Ptr<TraceResolver> CreateTraceResolver (void);
 
   /**
    * \returns the unique id of this node.
@@ -212,7 +212,7 @@
   bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &packet, 
                           uint16_t protocol, const Address &from);
   void Construct (void);
-  TraceResolver *CreateDevicesTraceResolver (void);
+  Ptr<TraceResolver> CreateDevicesTraceResolver (void);
 
   struct ProtocolHandlerEntry {
     ProtocolHandler handler;
--- a/src/node/queue.cc	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/node/queue.cc	Fri Aug 10 15:47:13 2007 +0200
@@ -94,10 +94,10 @@
   NS_DEBUG("Queue::~Queue ()");
 }
 
-TraceResolver *
+Ptr<TraceResolver>
 Queue::CreateTraceResolver (void)
 {
-  CompositeTraceResolver *resolver = new CompositeTraceResolver ();
+  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
   resolver->Add ("enqueue", m_traceEnqueue, QueueTraceType (QueueTraceType::ENQUEUE));
   resolver->Add ("dequeue", m_traceDequeue, QueueTraceType (QueueTraceType::DEQUEUE));
   resolver->Add ("drop", m_traceDrop, QueueTraceType (QueueTraceType::DROP));
--- a/src/node/queue.h	Fri Aug 10 15:47:00 2007 +0200
+++ b/src/node/queue.h	Fri Aug 10 15:47:13 2007 +0200
@@ -70,7 +70,7 @@
   Queue ();
   virtual ~Queue ();
 
-  TraceResolver *CreateTraceResolver (void);
+  Ptr<TraceResolver> CreateTraceResolver (void);
   
   /**
    * \return true if the queue is empty; false otherwise