add refcounting to TraceResolver
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 10 Aug 2007 14:43:15 +0200
changeset 1330 d67fce6d56f8
parent 1329 fc842b2faece
child 1331 9f16ffab39eb
add refcounting to TraceResolver
src/common/trace-resolver.cc
src/common/trace-resolver.h
src/core/object.h
--- a/src/common/trace-resolver.cc	Fri Aug 10 14:28:52 2007 +0200
+++ b/src/common/trace-resolver.cc	Fri Aug 10 14:43:15 2007 +0200
@@ -22,11 +22,30 @@
 
 namespace ns3 {
 
+TraceResolver::TraceResolver ()
+  : m_count (1)
+{}
 
 TraceResolver::~TraceResolver ()
 {}
 
 void 
+TraceResolver::Ref (void)
+{
+  m_count++;
+}
+void 
+TraceResolver::Unref (void)
+{
+  m_count--;
+  if (m_count == 0)
+    {
+      delete this;
+    }
+}
+
+
+void 
 TraceResolver::Connect (std::string path, CallbackBase const &cb, const TraceContext &context)
 {}
 
--- a/src/common/trace-resolver.h	Fri Aug 10 14:28:52 2007 +0200
+++ b/src/common/trace-resolver.h	Fri Aug 10 14:43:15 2007 +0200
@@ -50,7 +50,12 @@
 class TraceResolver
 {
 public:
+
+  TraceResolver ();
   virtual ~TraceResolver ();
+  void Ref (void);
+  void Unref (void);
+
   /**
    * \param path the namespace path to resolver
    * \param cb the callback to connect to the matching namespace
@@ -72,6 +77,7 @@
 protected:
   std::string GetElement (std::string path);
   std::string GetSubpath (std::string path);
+  uint32_t m_count;
 };
 
 }//namespace ns3
--- a/src/core/object.h	Fri Aug 10 14:28:52 2007 +0200
+++ b/src/core/object.h	Fri Aug 10 14:43:15 2007 +0200
@@ -131,6 +131,7 @@
    * on one to get the other, and vice-versa. 
    */
   void AddInterface (Ptr<Object> other);
+
 protected:
   /**
    * \param iid an InterfaceId