use RefCountBase
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 10 Apr 2008 13:01:53 -0700
changeset 2948 858fc65447a5
parent 2947 b0fec3381418
child 2949 a42da8051124
use RefCountBase
src/core/attribute.cc
src/core/attribute.h
--- a/src/core/attribute.cc	Thu Apr 10 12:59:31 2008 -0700
+++ b/src/core/attribute.cc	Thu Apr 10 13:01:53 2008 -0700
@@ -55,42 +55,12 @@
 }
 
 AttributeAccessor::AttributeAccessor ()
-  : m_count (1)
 {}
-void 
-AttributeAccessor::Ref (void) const
-{
-  m_count++;
-}
-void 
-AttributeAccessor::Unref (void) const
-{
-  m_count--;
-  if (m_count == 0)
-    {
-      delete this;
-    }
-}
 AttributeAccessor::~AttributeAccessor ()
 {}
 
 AttributeChecker::AttributeChecker ()
-  : m_count (1)
 {}
-void 
-AttributeChecker::Ref (void) const
-{
-  m_count++;
-}
-void 
-AttributeChecker::Unref (void) const
-{
-  m_count--;
-  if (m_count == 0)
-    {
-      delete this;
-    }
-}
 AttributeChecker::~AttributeChecker ()
 {}
 
--- a/src/core/attribute.h	Thu Apr 10 12:59:31 2008 -0700
+++ b/src/core/attribute.h	Thu Apr 10 13:01:53 2008 -0700
@@ -75,7 +75,6 @@
   virtual bool DeserializeFromString (std::string value, Ptr<const AttributeChecker> checker) = 0;
 private:
   friend class Attribute;
-  uint32_t m_count;
 };
 
 /**
@@ -130,12 +129,10 @@
  * of this base class are usually provided through the MakeAccessorHelper
  * template functions, hidden behind an ATTRIBUTE_HELPER_* macro.
  */
-class AttributeAccessor
+class AttributeAccessor : public RefCountBase
 {
 public:
   AttributeAccessor ();
-  void Ref (void) const;
-  void Unref (void) const;
   virtual ~AttributeAccessor ();
 
   /**
@@ -157,8 +154,6 @@
    * valid with AttributeChecker::Check.
    */
   virtual bool Get (const ObjectBase * object, Attribute attribute) const = 0;
-private:
-  mutable uint32_t m_count;
 };
 
 /**
@@ -173,12 +168,10 @@
  * Most subclasses of this base class are implemented by the 
  * ATTRIBUTE_HELPER_* macros.
  */
-class AttributeChecker
+class AttributeChecker : public RefCountBase
 {
 public:
   AttributeChecker ();
-  void Ref (void) const;
-  void Unref (void) const;
   virtual ~AttributeChecker ();
   /**
    * \param value a pointer to the value to check
@@ -198,8 +191,6 @@
    * to calling Attribute::DeserializeFromString.
    */
   virtual Attribute Create (void) const = 0;
-private:
-  mutable uint32_t m_count;
 };
 
 } // namespace ns3