src/core/ref-count-base.h
changeset 5505 c0ac392289c3
parent 3395 3b6bc7a4f975
child 5533 63e2dbaf577c
     1.1 --- a/src/core/ref-count-base.h	Tue Jul 08 10:17:18 2008 -0700
     1.2 +++ b/src/core/ref-count-base.h	Thu Nov 12 13:01:01 2009 +0100
     1.3 @@ -23,74 +23,26 @@
     1.4  #ifndef __REF_COUNT_BASE_H__
     1.5  #define __REF_COUNT_BASE_H__
     1.6  
     1.7 -#include <stdint.h>
     1.8 +#include "simple-ref-count.h"
     1.9  
    1.10  namespace ns3 {
    1.11  
    1.12  /**
    1.13 - * \brief a base class that provides implementations of reference counting
    1.14 - *    operations.
    1.15 - *  
    1.16 - * A base class that provides implementations of reference counting 
    1.17 - * operations, for classes that wish to use the templatized smart 
    1.18 - * pointer for memory management but that do not wish to derive from
    1.19 - * class ns3::Object.
    1.20 + * \brief A deprecated way to get reference-counting powers
    1.21   *
    1.22 + * Users who wish to use reference counting for a class of their own should use
    1.23 + * instead the template \ref ns3::SimpleRefCount. This class is maintained
    1.24 + * purely for compatibility to avoid breaking the code of users.
    1.25   */
    1.26 -class RefCountBase 
    1.27 +class RefCountBase : public SimpleRefCount<RefCountBase>
    1.28  { 
    1.29  public:
    1.30 -  RefCountBase();
    1.31 -  RefCountBase (const RefCountBase &o);
    1.32 -  RefCountBase &operator = (const RefCountBase &o);
    1.33 -  virtual ~RefCountBase ();
    1.34    /**
    1.35 -   * Increment the reference count. This method should not be called
    1.36 -   * by user code. RefCountBase instances are expected to be used in
    1.37 -   * conjunction with the Ptr template which would make calling Ref
    1.38 -   * unecessary and dangerous.
    1.39 +   * This only thing this class does it declare a virtual destructor
    1.40     */
    1.41 -  inline void Ref (void) const;
    1.42 -  /**
    1.43 -   * Decrement the reference count. This method should not be called
    1.44 -   * by user code. RefCountBase instances are expected to be used in 
    1.45 -   * conjunction with the Ptr template which would make calling Ref
    1.46 -   * unecessary and dangerous.
    1.47 -   */
    1.48 -  inline void Unref (void) const;
    1.49 -
    1.50 -  /**
    1.51 -   * Get the reference count of the object.  Normally not needed; for language bindings.
    1.52 -   */
    1.53 -  uint32_t GetReferenceCount (void) const;
    1.54 -
    1.55 -private:
    1.56 -  // Note we make this mutable so that the const methods can still
    1.57 -  // change it.
    1.58 -  mutable uint32_t m_count;  // Reference count
    1.59 +  virtual ~RefCountBase () = 0;
    1.60  };
    1.61  
    1.62  } // namespace ns3
    1.63  
    1.64 -namespace ns3 {
    1.65 -
    1.66 -// Implementation of the in-line methods
    1.67 -void
    1.68 -RefCountBase::Ref (void) const
    1.69 -{
    1.70 -  m_count++;
    1.71 -}
    1.72 -
    1.73 -void
    1.74 -RefCountBase::Unref (void) const
    1.75 -{
    1.76 -  m_count--;
    1.77 -  if (m_count == 0)
    1.78 -    { // All references removed, ok to delete
    1.79 -      delete this;
    1.80 -    }
    1.81 -}
    1.82 -
    1.83 -} // namespace ns3
    1.84 -
    1.85  #endif /* __REF_COUNT_BASE_H__*/