replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu Nov 12 13:01:01 2009 +0100 (2009-11-12)
changeset 5505c0ac392289c3
parent 5503 c305c6e122c9
child 5506 8a51fa38a4ee
replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
src/applications/radvd/radvd-interface.h
src/applications/radvd/radvd-prefix.h
src/common/ascii-writer.h
src/common/packet.cc
src/common/packet.h
src/contrib/flow-monitor/flow-classifier.cc
src/contrib/flow-monitor/flow-classifier.h
src/contrib/flow-monitor/flow-probe.h
src/contrib/flow-monitor/ipv4-flow-probe.h
src/core/attribute.h
src/core/callback.h
src/core/ref-count-base.cc
src/core/ref-count-base.h
src/core/simple-ref-count.h
src/core/system-thread.h
src/core/trace-source-accessor.cc
src/core/trace-source-accessor.h
src/core/unix-system-thread.cc
src/core/wscript
src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h
src/devices/mesh/dot11s/ie-dot11s-preq.h
src/devices/mesh/mesh-wifi-interface-mac-plugin.h
src/devices/mesh/wifi-information-element-vector.cc
src/devices/mesh/wifi-information-element-vector.h
src/devices/wifi/interference-helper.h
src/node/ipv4-route.h
src/node/ipv6-route.h
src/node/packetbb.cc
src/node/packetbb.h
src/simulator/event-impl.cc
src/simulator/event-impl.h
     1.1 --- a/src/applications/radvd/radvd-interface.h	Wed Nov 11 16:21:18 2009 +0100
     1.2 +++ b/src/applications/radvd/radvd-interface.h	Thu Nov 12 13:01:01 2009 +0100
     1.3 @@ -22,7 +22,7 @@
     1.4  #define RADVD_INTERFACE_H
     1.5  
     1.6  #include <list>
     1.7 -
     1.8 +#include "ns3/simple-ref-count.h"
     1.9  #include "radvd-prefix.h"
    1.10  
    1.11  namespace ns3
    1.12 @@ -33,7 +33,7 @@
    1.13   * \class RadvdInterface
    1.14   * \brief Radvd interface configuration.
    1.15   */
    1.16 -class RadvdInterface : public RefCountBase
    1.17 +class RadvdInterface : public SimpleRefCount<RadvdInterface>
    1.18  {
    1.19    public:
    1.20      /**
     2.1 --- a/src/applications/radvd/radvd-prefix.h	Wed Nov 11 16:21:18 2009 +0100
     2.2 +++ b/src/applications/radvd/radvd-prefix.h	Thu Nov 12 13:01:01 2009 +0100
     2.3 @@ -24,6 +24,7 @@
     2.4  #include <stdint.h>
     2.5  
     2.6  #include "ns3/ipv6-address.h"
     2.7 +#include "ns3/simple-ref-count.h"
     2.8  
     2.9  namespace ns3
    2.10  {
    2.11 @@ -33,7 +34,7 @@
    2.12   * \class RadvdPrefix
    2.13   * \brief Router prefix for radvd application.
    2.14   */
    2.15 -class RadvdPrefix : public RefCountBase
    2.16 +class RadvdPrefix : public SimpleRefCount<RadvdPrefix>
    2.17  {
    2.18    public:
    2.19      /**
     3.1 --- a/src/common/ascii-writer.h	Wed Nov 11 16:21:18 2009 +0100
     3.2 +++ b/src/common/ascii-writer.h	Thu Nov 12 13:01:01 2009 +0100
     3.3 @@ -23,7 +23,7 @@
     3.4  
     3.5  #include <stdint.h>
     3.6  #include <ostream>
     3.7 -#include "ns3/ref-count-base.h"
     3.8 +#include "ns3/simple-ref-count.h"
     3.9  #include "ns3/ptr.h"
    3.10  
    3.11  namespace ns3 {
    3.12 @@ -35,7 +35,7 @@
    3.13   *
    3.14   * \brief Ascii output
    3.15   */
    3.16 -class AsciiWriter : public RefCountBase
    3.17 +class AsciiWriter : public SimpleRefCount<AsciiWriter>
    3.18  {
    3.19  public:
    3.20    static Ptr<AsciiWriter> Get (std::ostream &os);
     4.1 --- a/src/common/packet.cc	Wed Nov 11 16:21:18 2009 +0100
     4.2 +++ b/src/common/packet.cc	Thu Nov 12 13:01:01 2009 +0100
     4.3 @@ -112,21 +112,6 @@
     4.4  }
     4.5  
     4.6  
     4.7 -void 
     4.8 -Packet::Ref (void) const
     4.9 -{
    4.10 -  m_refCount++;
    4.11 -}
    4.12 -void 
    4.13 -Packet::Unref (void) const
    4.14 -{
    4.15 -  m_refCount--;
    4.16 -  if (m_refCount == 0)
    4.17 -    {
    4.18 -      delete this;
    4.19 -    }
    4.20 -}
    4.21 -
    4.22  Ptr<Packet> 
    4.23  Packet::Copy (void) const
    4.24  {
    4.25 @@ -141,8 +126,7 @@
    4.26      m_byteTagList (),
    4.27      m_packetTagList (),
    4.28      m_metadata (m_globalUid, 0),
    4.29 -    m_nixVector (0),
    4.30 -    m_refCount (1)
    4.31 +    m_nixVector (0)
    4.32  {
    4.33    m_globalUid++;
    4.34  }
    4.35 @@ -151,8 +135,7 @@
    4.36    : m_buffer (o.m_buffer),
    4.37      m_byteTagList (o.m_byteTagList),
    4.38      m_packetTagList (o.m_packetTagList),
    4.39 -    m_metadata (o.m_metadata),
    4.40 -    m_refCount (1)
    4.41 +    m_metadata (o.m_metadata)
    4.42  {
    4.43    o.m_nixVector ? m_nixVector = o.m_nixVector->Copy () 
    4.44                  : m_nixVector = 0;
    4.45 @@ -179,8 +162,7 @@
    4.46      m_byteTagList (),
    4.47      m_packetTagList (),
    4.48      m_metadata (m_globalUid, size),
    4.49 -    m_nixVector (0),
    4.50 -    m_refCount (1)
    4.51 +    m_nixVector (0)
    4.52  {
    4.53    m_globalUid++;
    4.54  }
    4.55 @@ -189,8 +171,7 @@
    4.56      m_byteTagList (),
    4.57      m_packetTagList (),
    4.58      m_metadata (m_globalUid, size),
    4.59 -    m_nixVector (0),
    4.60 -    m_refCount (1)
    4.61 +    m_nixVector (0)
    4.62  {
    4.63    m_globalUid++;
    4.64    m_buffer.AddAtStart (size);
    4.65 @@ -204,8 +185,7 @@
    4.66      m_byteTagList (byteTagList),
    4.67      m_packetTagList (packetTagList),
    4.68      m_metadata (metadata),
    4.69 -    m_nixVector (0),
    4.70 -    m_refCount (1)
    4.71 +    m_nixVector (0)
    4.72  {}
    4.73  
    4.74  Ptr<Packet>
     5.1 --- a/src/common/packet.h	Wed Nov 11 16:21:18 2009 +0100
     5.2 +++ b/src/common/packet.h	Thu Nov 12 13:01:01 2009 +0100
     5.3 @@ -198,12 +198,9 @@
     5.4   * The performance aspects of the Packet API are discussed in 
     5.5   * \ref packetperf
     5.6   */
     5.7 -class Packet 
     5.8 +class Packet : public SimpleRefCount<Packet>
     5.9  {
    5.10  public:
    5.11 -  void Ref (void) const;
    5.12 -  void Unref (void) const;
    5.13 -
    5.14    Ptr<Packet> Copy (void) const;
    5.15  
    5.16    /**
    5.17 @@ -540,7 +537,6 @@
    5.18    /* Please see comments above about nix-vector */
    5.19    Ptr<NixVector> m_nixVector;
    5.20  
    5.21 -  mutable uint32_t m_refCount;
    5.22    static uint32_t m_globalUid;
    5.23  };
    5.24  
     6.1 --- a/src/contrib/flow-monitor/flow-classifier.cc	Wed Nov 11 16:21:18 2009 +0100
     6.2 +++ b/src/contrib/flow-monitor/flow-classifier.cc	Thu Nov 12 13:01:01 2009 +0100
     6.3 @@ -28,6 +28,8 @@
     6.4  {
     6.5  }
     6.6  
     6.7 +FlowClassifier::~FlowClassifier ()
     6.8 +{}
     6.9  
    6.10  FlowId
    6.11  FlowClassifier::GetNewFlowId ()
     7.1 --- a/src/contrib/flow-monitor/flow-classifier.h	Wed Nov 11 16:21:18 2009 +0100
     7.2 +++ b/src/contrib/flow-monitor/flow-classifier.h	Thu Nov 12 13:01:01 2009 +0100
     7.3 @@ -21,7 +21,7 @@
     7.4  #ifndef __FLOW_CLASSIFIER_H__
     7.5  #define __FLOW_CLASSIFIER_H__
     7.6  
     7.7 -#include "ns3/ref-count-base.h"
     7.8 +#include "ns3/simple-ref-count.h"
     7.9  #include <ostream>
    7.10  
    7.11  namespace ns3 {
    7.12 @@ -39,13 +39,14 @@
    7.13  /// statistics reference only those abstract identifiers in order to
    7.14  /// keep the core architecture generic and not tied down to any
    7.15  /// particular flow capture method or classification system.
    7.16 -class FlowClassifier : public RefCountBase
    7.17 +class FlowClassifier : public SimpleRefCount<FlowClassifier>
    7.18  {
    7.19    FlowId m_lastNewFlowId;
    7.20  
    7.21  public:
    7.22  
    7.23    FlowClassifier ();
    7.24 +  virtual ~FlowClassifier ();
    7.25  
    7.26    virtual void SerializeToXmlStream (std::ostream &os, int indent) const = 0;
    7.27  
     8.1 --- a/src/contrib/flow-monitor/flow-probe.h	Wed Nov 11 16:21:18 2009 +0100
     8.2 +++ b/src/contrib/flow-monitor/flow-probe.h	Thu Nov 12 13:01:01 2009 +0100
     8.3 @@ -24,7 +24,7 @@
     8.4  #include <map>
     8.5  #include <vector>
     8.6  
     8.7 -#include "ns3/ref-count-base.h"
     8.8 +#include "ns3/simple-ref-count.h"
     8.9  #include "ns3/flow-classifier.h"
    8.10  #include "ns3/nstime.h"
    8.11  
    8.12 @@ -36,14 +36,14 @@
    8.13  /// in a specific point of the simulated space, report those events to
    8.14  /// the global FlowMonitor, and collect its own flow statistics
    8.15  /// regarding only the packets that pass through that probe.
    8.16 -class FlowProbe : public RefCountBase
    8.17 +class FlowProbe : public SimpleRefCount<FlowProbe>
    8.18  {
    8.19  protected:
    8.20    
    8.21    FlowProbe (Ptr<FlowMonitor> flowMonitor);
    8.22    
    8.23  public:
    8.24 -  ~FlowProbe ();
    8.25 +  virtual ~FlowProbe ();
    8.26  
    8.27    struct FlowStats
    8.28    {
     9.1 --- a/src/contrib/flow-monitor/ipv4-flow-probe.h	Wed Nov 11 16:21:18 2009 +0100
     9.2 +++ b/src/contrib/flow-monitor/ipv4-flow-probe.h	Thu Nov 12 13:01:01 2009 +0100
     9.3 @@ -41,7 +41,7 @@
     9.4    
     9.5  public:
     9.6    Ipv4FlowProbe (Ptr<FlowMonitor> monitor, Ptr<Ipv4FlowClassifier> classifier, Ptr<Node> node);
     9.7 -  ~Ipv4FlowProbe ();
     9.8 +  virtual ~Ipv4FlowProbe ();
     9.9  
    9.10    /// \brief enumeration of possible reasons why a packet may be dropped
    9.11    enum DropReason 
    10.1 --- a/src/core/attribute.h	Wed Nov 11 16:21:18 2009 +0100
    10.2 +++ b/src/core/attribute.h	Thu Nov 12 13:01:01 2009 +0100
    10.3 @@ -23,7 +23,7 @@
    10.4  #include <string>
    10.5  #include <stdint.h>
    10.6  #include "ptr.h"
    10.7 -#include "ref-count-base.h"
    10.8 +#include "simple-ref-count.h"
    10.9  
   10.10  namespace ns3 {
   10.11  
   10.12 @@ -48,7 +48,7 @@
   10.13   * Most subclasses of this base class are implemented by the 
   10.14   * ATTRIBUTE_HELPER_* macros.
   10.15   */
   10.16 -class AttributeValue : public RefCountBase
   10.17 +class AttributeValue : public SimpleRefCount<AttributeValue>
   10.18  {
   10.19  public:
   10.20    AttributeValue ();
   10.21 @@ -94,7 +94,7 @@
   10.22   * of this base class are usually provided through the MakeAccessorHelper
   10.23   * template functions, hidden behind an ATTRIBUTE_HELPER_* macro.
   10.24   */
   10.25 -class AttributeAccessor : public RefCountBase
   10.26 +class AttributeAccessor : public SimpleRefCount<AttributeAccessor>
   10.27  {
   10.28  public:
   10.29    AttributeAccessor ();
   10.30 @@ -146,7 +146,7 @@
   10.31   * Most subclasses of this base class are implemented by the 
   10.32   * ATTRIBUTE_HELPER_HEADER and ATTRIBUTE_HELPER_CPP macros.
   10.33   */
   10.34 -class AttributeChecker : public RefCountBase
   10.35 +class AttributeChecker : public SimpleRefCount<AttributeChecker>
   10.36  {
   10.37  public:
   10.38    AttributeChecker ();
    11.1 --- a/src/core/callback.h	Wed Nov 11 16:21:18 2009 +0100
    11.2 +++ b/src/core/callback.h	Thu Nov 12 13:01:01 2009 +0100
    11.3 @@ -27,6 +27,7 @@
    11.4  #include "type-traits.h"
    11.5  #include "attribute.h"
    11.6  #include "attribute-helper.h"
    11.7 +#include "simple-ref-count.h"
    11.8  #include <typeinfo>
    11.9  
   11.10  namespace ns3 {
   11.11 @@ -72,25 +73,11 @@
   11.12    }
   11.13  };
   11.14  
   11.15 -class CallbackImplBase
   11.16 +class CallbackImplBase : public SimpleRefCount<CallbackImplBase>
   11.17  {
   11.18  public:
   11.19 -  CallbackImplBase ()
   11.20 -    : m_count (1) {}
   11.21    virtual ~CallbackImplBase () {}
   11.22 -  void Ref (void) const {
   11.23 -    m_count++;
   11.24 -  }
   11.25 -  void Unref (void) const {
   11.26 -    m_count--;
   11.27 -    if (m_count == 0) {
   11.28 -      delete this;
   11.29 -    }
   11.30 -  }
   11.31 -  uint32_t GetReferenceCount (void) const { return m_count; }
   11.32    virtual bool IsEqual (Ptr<const CallbackImplBase> other) const = 0;
   11.33 -private:
   11.34 -  mutable uint32_t m_count;
   11.35  };
   11.36  
   11.37  // declare the CallbackImpl class
    12.1 --- a/src/core/ref-count-base.cc	Wed Nov 11 16:21:18 2009 +0100
    12.2 +++ b/src/core/ref-count-base.cc	Thu Nov 12 13:01:01 2009 +0100
    12.3 @@ -1,52 +1,8 @@
    12.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    12.5 -/*
    12.6 - * Copyright (c) 2007 Georgia Tech Research Corporation
    12.7 - *
    12.8 - * This program is free software; you can redistribute it and/or modify
    12.9 - * it under the terms of the GNU General Public License version 2 as
   12.10 - * published by the Free Software Foundation;
   12.11 - *
   12.12 - * This program is distributed in the hope that it will be useful,
   12.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.15 - * GNU General Public License for more details.
   12.16 - *
   12.17 - * You should have received a copy of the GNU General Public License
   12.18 - * along with this program; if not, write to the Free Software
   12.19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   12.20 - *
   12.21 - * Author:  George Riley <riley@ece.gatech.edu>
   12.22 - * Adapted from original code in object.h by:
   12.23 - * Authors: Gustavo Carneiro <gjcarneiro@gmail.com>,
   12.24 - *          Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   12.25 - */
   12.26 -
   12.27  #include "ref-count-base.h"
   12.28  
   12.29  namespace ns3 {
   12.30  
   12.31 -RefCountBase::RefCountBase() 
   12.32 -  : m_count (1) 
   12.33 -{
   12.34 -}
   12.35 -
   12.36 -RefCountBase::RefCountBase (const RefCountBase &o)
   12.37 - : m_count (1)
   12.38 +RefCountBase::~RefCountBase ()
   12.39  {}
   12.40 -RefCountBase &
   12.41 -RefCountBase::operator = (const RefCountBase &o)
   12.42 -{
   12.43 -  return *this;
   12.44 -}
   12.45 -
   12.46 -RefCountBase::~RefCountBase () 
   12.47 -{
   12.48 -}
   12.49 -
   12.50 -uint32_t
   12.51 -RefCountBase::GetReferenceCount (void) const
   12.52 -{
   12.53 -  return m_count;
   12.54 -}
   12.55  
   12.56  } // namespace ns3
    13.1 --- a/src/core/ref-count-base.h	Wed Nov 11 16:21:18 2009 +0100
    13.2 +++ b/src/core/ref-count-base.h	Thu Nov 12 13:01:01 2009 +0100
    13.3 @@ -23,74 +23,26 @@
    13.4  #ifndef __REF_COUNT_BASE_H__
    13.5  #define __REF_COUNT_BASE_H__
    13.6  
    13.7 -#include <stdint.h>
    13.8 +#include "simple-ref-count.h"
    13.9  
   13.10  namespace ns3 {
   13.11  
   13.12  /**
   13.13 - * \brief a base class that provides implementations of reference counting
   13.14 - *    operations.
   13.15 - *  
   13.16 - * A base class that provides implementations of reference counting 
   13.17 - * operations, for classes that wish to use the templatized smart 
   13.18 - * pointer for memory management but that do not wish to derive from
   13.19 - * class ns3::Object.
   13.20 + * \brief A deprecated way to get reference-counting powers
   13.21   *
   13.22 + * Users who wish to use reference counting for a class of their own should use
   13.23 + * instead the template \ref ns3::SimpleRefCount. This class is maintained
   13.24 + * purely for compatibility to avoid breaking the code of users.
   13.25   */
   13.26 -class RefCountBase 
   13.27 +class RefCountBase : public SimpleRefCount<RefCountBase>
   13.28  { 
   13.29  public:
   13.30 -  RefCountBase();
   13.31 -  RefCountBase (const RefCountBase &o);
   13.32 -  RefCountBase &operator = (const RefCountBase &o);
   13.33 -  virtual ~RefCountBase ();
   13.34    /**
   13.35 -   * Increment the reference count. This method should not be called
   13.36 -   * by user code. RefCountBase instances are expected to be used in
   13.37 -   * conjunction with the Ptr template which would make calling Ref
   13.38 -   * unecessary and dangerous.
   13.39 +   * This only thing this class does it declare a virtual destructor
   13.40     */
   13.41 -  inline void Ref (void) const;
   13.42 -  /**
   13.43 -   * Decrement the reference count. This method should not be called
   13.44 -   * by user code. RefCountBase instances are expected to be used in 
   13.45 -   * conjunction with the Ptr template which would make calling Ref
   13.46 -   * unecessary and dangerous.
   13.47 -   */
   13.48 -  inline void Unref (void) const;
   13.49 -
   13.50 -  /**
   13.51 -   * Get the reference count of the object.  Normally not needed; for language bindings.
   13.52 -   */
   13.53 -  uint32_t GetReferenceCount (void) const;
   13.54 -
   13.55 -private:
   13.56 -  // Note we make this mutable so that the const methods can still
   13.57 -  // change it.
   13.58 -  mutable uint32_t m_count;  // Reference count
   13.59 +  virtual ~RefCountBase () = 0;
   13.60  };
   13.61  
   13.62  } // namespace ns3
   13.63  
   13.64 -namespace ns3 {
   13.65 -
   13.66 -// Implementation of the in-line methods
   13.67 -void
   13.68 -RefCountBase::Ref (void) const
   13.69 -{
   13.70 -  m_count++;
   13.71 -}
   13.72 -
   13.73 -void
   13.74 -RefCountBase::Unref (void) const
   13.75 -{
   13.76 -  m_count--;
   13.77 -  if (m_count == 0)
   13.78 -    { // All references removed, ok to delete
   13.79 -      delete this;
   13.80 -    }
   13.81 -}
   13.82 -
   13.83 -} // namespace ns3
   13.84 -
   13.85  #endif /* __REF_COUNT_BASE_H__*/
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/core/simple-ref-count.h	Thu Nov 12 13:01:01 2009 +0100
    14.3 @@ -0,0 +1,103 @@
    14.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    14.5 +/*
    14.6 + * Copyright (c) 2007 Georgia Tech Research Corporation, INRIA
    14.7 + *
    14.8 + * This program is free software; you can redistribute it and/or modify
    14.9 + * it under the terms of the GNU General Public License version 2 as
   14.10 + * published by the Free Software Foundation;
   14.11 + *
   14.12 + * This program is distributed in the hope that it will be useful,
   14.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.15 + * GNU General Public License for more details.
   14.16 + *
   14.17 + * You should have received a copy of the GNU General Public License
   14.18 + * along with this program; if not, write to the Free Software
   14.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   14.20 + *
   14.21 + * Authors: George Riley <riley@ece.gatech.edu>
   14.22 + *          Gustavo Carneiro <gjcarneiro@gmail.com>,
   14.23 + *          Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
   14.24 + */
   14.25 +#ifndef SIMPLE_REF_COUNT_H
   14.26 +#define SIMPLE_REF_COUNT_H
   14.27 +
   14.28 +#include "empty.h"
   14.29 +#include <stdint.h>
   14.30 +
   14.31 +namespace ns3 {
   14.32 +
   14.33 +/**
   14.34 + * \brief A template-based reference counting class
   14.35 + *
   14.36 + * This template can be used to give reference-counting powers
   14.37 + * to a class. This template does not require this class to
   14.38 + * have a virtual destructor or no parent class.
   14.39 + * 
   14.40 + * Note: if you are moving to this template from the RefCountBase class,
   14.41 + * you need to be careful to mark appropriately your destructor virtual
   14.42 + * if needed. i.e., if your class has subclasses, _do_ mark your destructor
   14.43 + * virtual.
   14.44 + *
   14.45 + * \internal
   14.46 + * Note: we rely on the fairly common EBCO (empty base class optimization)
   14.47 + * to get rid of the empty parent when the user does not provide
   14.48 + * a non-trivial parent.
   14.49 + */
   14.50 +template <typename T, typename PARENT = empty>
   14.51 +class SimpleRefCount : public PARENT
   14.52 +{
   14.53 +public:
   14.54 +  SimpleRefCount ()
   14.55 +    : m_count (1)
   14.56 +  {}
   14.57 +  SimpleRefCount (const SimpleRefCount &o)
   14.58 +    : m_count (1)
   14.59 +  {}
   14.60 +  SimpleRefCount &operator = (const SimpleRefCount &o)
   14.61 +  {
   14.62 +    return *this;
   14.63 +  }
   14.64 +  /**
   14.65 +   * Increment the reference count. This method should not be called
   14.66 +   * by user code. SimpleRefCount instances are expected to be used in
   14.67 +   * conjunction with the Ptr template which would make calling Ref
   14.68 +   * unecessary and dangerous.
   14.69 +   */
   14.70 +  inline void Ref (void) const
   14.71 +  {
   14.72 +    m_count++;
   14.73 +  }
   14.74 +  /**
   14.75 +   * Decrement the reference count. This method should not be called
   14.76 +   * by user code. SimpleRefCount instances are expected to be used in 
   14.77 +   * conjunction with the Ptr template which would make calling Ref
   14.78 +   * unecessary and dangerous.
   14.79 +   */
   14.80 +  inline void Unref (void) const
   14.81 +  {
   14.82 +    m_count--;
   14.83 +    if (m_count == 0)
   14.84 +      {
   14.85 +	delete static_cast<T*> (const_cast<SimpleRefCount *> (this));
   14.86 +      }
   14.87 +  }
   14.88 +
   14.89 +  /**
   14.90 +   * Get the reference count of the object.  
   14.91 +   * Normally not needed; for language bindings.
   14.92 +   */
   14.93 +  uint32_t GetReferenceCount (void) const
   14.94 +  {
   14.95 +    return m_count;
   14.96 +  }
   14.97 +
   14.98 +private:
   14.99 +  // Note we make this mutable so that the const methods can still
  14.100 +  // change it.
  14.101 +  mutable uint32_t m_count;
  14.102 +};
  14.103 +
  14.104 +} // namespace ns3
  14.105 +
  14.106 +#endif /* SIMPLE_REF_COUNT_H */
    15.1 --- a/src/core/system-thread.h	Wed Nov 11 16:21:18 2009 +0100
    15.2 +++ b/src/core/system-thread.h	Thu Nov 12 13:01:01 2009 +0100
    15.3 @@ -42,7 +42,7 @@
    15.4   *
    15.5   * Synchronization between threads is provided via the SystemMutex class.
    15.6   */
    15.7 -class SystemThread 
    15.8 +class SystemThread : public SimpleRefCount<SystemThread>
    15.9  {
   15.10  public:
   15.11    /**
   15.12 @@ -116,22 +116,6 @@
   15.13    ~SystemThread();
   15.14  
   15.15    /**
   15.16 -   * Increment the reference count. This method should not be called
   15.17 -   * by user code. Object instances are expected to be used in conjunction
   15.18 -   * of the Ptr template which would make calling Ref unecessary and 
   15.19 -   * dangerous.
   15.20 -   */
   15.21 -  inline void Ref (void) const;
   15.22 -
   15.23 -  /**
   15.24 -   * Decrement the reference count. This method should not be called
   15.25 -   * by user code. Object instances are expected to be used in conjunction
   15.26 -   * of the Ptr template which would make calling Ref unecessary and 
   15.27 -   * dangerous.
   15.28 -   */
   15.29 -  inline void Unref (void) const;
   15.30 -
   15.31 -  /**
   15.32     * @brief Start a thread of execution, running the provided callback.
   15.33     */
   15.34    void Start (void);
   15.35 @@ -181,26 +165,9 @@
   15.36  
   15.37  private:
   15.38    SystemThreadImpl * m_impl;
   15.39 -  mutable uint32_t m_count;
   15.40    bool m_break;
   15.41  };
   15.42  
   15.43 - void
   15.44 -SystemThread::Ref (void) const
   15.45 -{
   15.46 -  m_count++;
   15.47 -}
   15.48 -
   15.49 - void
   15.50 -SystemThread::Unref (void) const
   15.51 -{
   15.52 -  m_count--;
   15.53 -  if (m_count == 0)
   15.54 -    {
   15.55 -      delete this;
   15.56 -    }
   15.57 -}
   15.58 -
   15.59  } //namespace ns3
   15.60  
   15.61  #endif /* SYSTEM_THREAD_H */
    16.1 --- a/src/core/trace-source-accessor.cc	Wed Nov 11 16:21:18 2009 +0100
    16.2 +++ b/src/core/trace-source-accessor.cc	Thu Nov 12 13:01:01 2009 +0100
    16.3 @@ -22,23 +22,8 @@
    16.4  namespace ns3 {
    16.5  
    16.6  TraceSourceAccessor::TraceSourceAccessor ()
    16.7 -  : m_count (1)
    16.8  {}
    16.9  TraceSourceAccessor::~TraceSourceAccessor ()
   16.10  {}
   16.11 -void 
   16.12 -TraceSourceAccessor::Ref (void) const
   16.13 -{
   16.14 -  m_count++;
   16.15 -}
   16.16 -void 
   16.17 -TraceSourceAccessor::Unref (void) const
   16.18 -{
   16.19 -  m_count--;
   16.20 -  if (m_count == 0)
   16.21 -    {
   16.22 -      delete this;
   16.23 -    }
   16.24 -}
   16.25  
   16.26  } // namespace ns3
    17.1 --- a/src/core/trace-source-accessor.h	Wed Nov 11 16:21:18 2009 +0100
    17.2 +++ b/src/core/trace-source-accessor.h	Thu Nov 12 13:01:01 2009 +0100
    17.3 @@ -23,6 +23,7 @@
    17.4  #include <stdint.h>
    17.5  #include "callback.h"
    17.6  #include "ptr.h"
    17.7 +#include "simple-ref-count.h"
    17.8  
    17.9  namespace ns3 {
   17.10  
   17.11 @@ -36,13 +37,11 @@
   17.12   * This class abstracts the kind of trace source to which we want to connect
   17.13   * and provides services to Connect and Disconnect a sink to a trace source.
   17.14   */
   17.15 -class TraceSourceAccessor
   17.16 +class TraceSourceAccessor : public SimpleRefCount<TraceSourceAccessor>
   17.17  {
   17.18  public:
   17.19    TraceSourceAccessor ();
   17.20    virtual ~TraceSourceAccessor ();
   17.21 -  void Ref (void) const;
   17.22 -  void Unref (void) const;
   17.23  
   17.24    /**
   17.25     * \param obj the object instance which contains the target trace source.
   17.26 @@ -66,8 +65,6 @@
   17.27     * \param cb the callback to disconnect from the target trace source.
   17.28     */
   17.29    virtual bool Disconnect (ObjectBase *obj, std::string context, const CallbackBase &cb) const = 0;
   17.30 -private:
   17.31 -  mutable uint32_t m_count;
   17.32  };
   17.33  
   17.34  /**
    18.1 --- a/src/core/unix-system-thread.cc	Wed Nov 11 16:21:18 2009 +0100
    18.2 +++ b/src/core/unix-system-thread.cc	Thu Nov 12 13:01:01 2009 +0100
    18.3 @@ -141,8 +141,7 @@
    18.4  // class above.
    18.5  //
    18.6  SystemThread::SystemThread (Callback<void> callback) 
    18.7 -  : m_impl (new SystemThreadImpl (callback)),
    18.8 -    m_count (1)
    18.9 +  : m_impl (new SystemThreadImpl (callback))
   18.10  {
   18.11    NS_LOG_FUNCTION_NOARGS ();
   18.12  }
    19.1 --- a/src/core/wscript	Wed Nov 11 16:21:18 2009 +0100
    19.2 +++ b/src/core/wscript	Thu Nov 12 13:01:01 2009 +0100
    19.3 @@ -90,6 +90,7 @@
    19.4          'callback.h',
    19.5          'object-base.h',
    19.6          'ref-count-base.h',
    19.7 +        'simple-ref-count.h',
    19.8          'type-id.h',
    19.9          'attribute-list.h',
   19.10          'ptr.h',
    20.1 --- a/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h	Wed Nov 11 16:21:18 2009 +0100
    20.2 +++ b/src/devices/mesh/dot11s/ie-dot11s-beacon-timing.h	Thu Nov 12 13:01:01 2009 +0100
    20.3 @@ -31,7 +31,7 @@
    20.4   * \ingroup dot11s
    20.5   * \brief Describes one unit of beacon timing element
    20.6   */
    20.7 -class IeBeaconTimingUnit : public RefCountBase
    20.8 +class IeBeaconTimingUnit : public SimpleRefCount<IeBeaconTimingUnit>
    20.9  {
   20.10  public:
   20.11    IeBeaconTimingUnit ();
    21.1 --- a/src/devices/mesh/dot11s/ie-dot11s-preq.h	Wed Nov 11 16:21:18 2009 +0100
    21.2 +++ b/src/devices/mesh/dot11s/ie-dot11s-preq.h	Thu Nov 12 13:01:01 2009 +0100
    21.3 @@ -33,7 +33,7 @@
    21.4   * \brief Describes an address unit in PREQ information element
    21.5   * See 7.3.2.96 for more details
    21.6   */
    21.7 -class DestinationAddressUnit : public RefCountBase
    21.8 +class DestinationAddressUnit : public SimpleRefCount<DestinationAddressUnit>
    21.9  {
   21.10  public:
   21.11    DestinationAddressUnit ();
    22.1 --- a/src/devices/mesh/mesh-wifi-interface-mac-plugin.h	Wed Nov 11 16:21:18 2009 +0100
    22.2 +++ b/src/devices/mesh/mesh-wifi-interface-mac-plugin.h	Thu Nov 12 13:01:01 2009 +0100
    22.3 @@ -25,7 +25,7 @@
    22.4  #include "ns3/packet.h"
    22.5  #include "ns3/mac48-address.h"
    22.6  #include "ns3/mesh-wifi-beacon.h"
    22.7 -#include "ns3/ref-count-base.h"
    22.8 +#include "ns3/simple-ref-count.h"
    22.9  
   22.10  namespace ns3 {
   22.11  
   22.12 @@ -38,7 +38,7 @@
   22.13   * 
   22.14   * TODO: plugins description
   22.15   */
   22.16 -class MeshWifiInterfaceMacPlugin : public RefCountBase
   22.17 +class MeshWifiInterfaceMacPlugin : public SimpleRefCount<MeshWifiInterfaceMacPlugin>
   22.18  {
   22.19  public:
   22.20    /// This is for subclasses
    23.1 --- a/src/devices/mesh/wifi-information-element-vector.cc	Wed Nov 11 16:21:18 2009 +0100
    23.2 +++ b/src/devices/mesh/wifi-information-element-vector.cc	Thu Nov 12 13:01:01 2009 +0100
    23.3 @@ -36,6 +36,10 @@
    23.4  #include "dot11s/ie-dot11s-rann.h"
    23.5  
    23.6  namespace ns3 {
    23.7 +
    23.8 +WifiInformationElement::~WifiInformationElement ()
    23.9 +{}
   23.10 +
   23.11  bool
   23.12  operator< (WifiInformationElement const & a, WifiInformationElement const & b)
   23.13  {
    24.1 --- a/src/devices/mesh/wifi-information-element-vector.h	Wed Nov 11 16:21:18 2009 +0100
    24.2 +++ b/src/devices/mesh/wifi-information-element-vector.h	Thu Nov 12 13:01:01 2009 +0100
    24.3 @@ -23,6 +23,7 @@
    24.4  #define IE_VECTOR_H
    24.5  
    24.6  #include "ns3/header.h"
    24.7 +#include "ns3/simple-ref-count.h"
    24.8  
    24.9  namespace ns3 {
   24.10  class Packet;
   24.11 @@ -79,9 +80,10 @@
   24.12   * Element ID as defined in this standard. The Length field specifies the number of octets in the Information
   24.13   * field.
   24.14   */
   24.15 -class WifiInformationElement : public RefCountBase
   24.16 +class WifiInformationElement : public SimpleRefCount<WifiInformationElement>
   24.17  {
   24.18  public:
   24.19 +  virtual ~WifiInformationElement ();
   24.20    ///\name Each subclass must implement
   24.21    //\{
   24.22    virtual void Print (std::ostream &os) const = 0;
    25.1 --- a/src/devices/wifi/interference-helper.h	Wed Nov 11 16:21:18 2009 +0100
    25.2 +++ b/src/devices/wifi/interference-helper.h	Thu Nov 12 13:01:01 2009 +0100
    25.3 @@ -27,7 +27,7 @@
    25.4  #include "wifi-preamble.h"
    25.5  #include "wifi-phy-standard.h"
    25.6  #include "ns3/nstime.h"
    25.7 -#include "ns3/ref-count-base.h"
    25.8 +#include "ns3/simple-ref-count.h"
    25.9  
   25.10  namespace ns3 {
   25.11  
   25.12 @@ -36,13 +36,13 @@
   25.13  class InterferenceHelper
   25.14  {
   25.15  public:
   25.16 -  class Event : public RefCountBase
   25.17 +  class Event : public SimpleRefCount<InterferenceHelper::Event>
   25.18    {
   25.19    public:
   25.20      Event (uint32_t size, WifiMode payloadMode, 
   25.21  	     enum WifiPreamble preamble,
   25.22  	     Time duration, double rxPower);
   25.23 -    virtual ~Event ();
   25.24 +    ~Event ();
   25.25    
   25.26      Time GetDuration (void) const;
   25.27      Time GetStartTime (void) const;
    26.1 --- a/src/node/ipv4-route.h	Wed Nov 11 16:21:18 2009 +0100
    26.2 +++ b/src/node/ipv4-route.h	Thu Nov 12 13:01:01 2009 +0100
    26.3 @@ -23,7 +23,7 @@
    26.4  #include <vector>
    26.5  #include <ostream>
    26.6  
    26.7 -#include "ns3/ref-count-base.h"
    26.8 +#include "ns3/simple-ref-count.h"
    26.9  #include "ipv4-address.h"
   26.10  
   26.11  namespace ns3 {
   26.12 @@ -38,7 +38,8 @@
   26.13   * This is a reference counted object.  In the future, we will add other 
   26.14   * entries from struct dst_entry, struct rtable, and struct dst_ops as needed.
   26.15   */
   26.16 -class Ipv4Route : public RefCountBase {
   26.17 +class Ipv4Route : public SimpleRefCount<Ipv4Route> 
   26.18 +{
   26.19  public:
   26.20    Ipv4Route ();
   26.21  
   26.22 @@ -103,7 +104,8 @@
   26.23   * 
   26.24   * \brief Ipv4 multicast route cache entry (similar to Linux struct mfc_cache)
   26.25   */
   26.26 -class Ipv4MulticastRoute : public RefCountBase {
   26.27 +class Ipv4MulticastRoute : public SimpleRefCount<Ipv4MulticastRoute> 
   26.28 +{
   26.29  public:
   26.30    Ipv4MulticastRoute ();
   26.31  
    27.1 --- a/src/node/ipv6-route.h	Wed Nov 11 16:21:18 2009 +0100
    27.2 +++ b/src/node/ipv6-route.h	Thu Nov 12 13:01:01 2009 +0100
    27.3 @@ -25,7 +25,7 @@
    27.4  #include <vector>
    27.5  #include <ostream>
    27.6  
    27.7 -#include "ns3/ref-count-base.h"
    27.8 +#include "ns3/simple-ref-count.h"
    27.9  
   27.10  #include "ipv6-address.h"
   27.11  
   27.12 @@ -39,7 +39,7 @@
   27.13   * \class Ipv6Route
   27.14   * \brief IPv6 route cache entry.
   27.15   */
   27.16 -class Ipv6Route : public RefCountBase
   27.17 +class Ipv6Route : public SimpleRefCount<Ipv6Route>
   27.18  {
   27.19    public:
   27.20      /**
   27.21 @@ -129,7 +129,7 @@
   27.22   * \class Ipv6MulticastRoute
   27.23   * \brief IPv6 multicast route entry.
   27.24   */
   27.25 -class Ipv6MulticastRoute : public RefCountBase
   27.26 +class Ipv6MulticastRoute : public SimpleRefCount<Ipv6MulticastRoute>
   27.27  {
   27.28    public:
   27.29      /**
    28.1 --- a/src/node/packetbb.cc	Wed Nov 11 16:21:18 2009 +0100
    28.2 +++ b/src/node/packetbb.cc	Thu Nov 12 13:01:01 2009 +0100
    28.3 @@ -497,7 +497,6 @@
    28.4  
    28.5  PbbPacket::PbbPacket (void)
    28.6  {
    28.7 -  m_refCount = 1;
    28.8    m_version = VERSION;
    28.9    m_hasseqnum = false;
   28.10  }
   28.11 @@ -746,21 +745,6 @@
   28.12    m_messageList.clear ();
   28.13  }
   28.14  
   28.15 -void
   28.16 -PbbPacket::Ref (void) const
   28.17 -{
   28.18 -  m_refCount++;
   28.19 -}
   28.20 -
   28.21 -void
   28.22 -PbbPacket::Unref (void) const
   28.23 -{
   28.24 -  m_refCount--;
   28.25 -  if (m_refCount == 0)
   28.26 -    {
   28.27 -      delete this;
   28.28 -    }
   28.29 -}
   28.30  
   28.31  TypeId
   28.32  PbbPacket::GetTypeId (void)
   28.33 @@ -947,7 +931,6 @@
   28.34  
   28.35  PbbMessage::PbbMessage ()
   28.36  {
   28.37 -  m_refCount = 1;
   28.38    /* Default to IPv4 */
   28.39    m_addrSize = IPV4;
   28.40    m_hasOriginatorAddress = false;
   28.41 @@ -1274,22 +1257,6 @@
   28.42    return m_addressBlockList.clear();
   28.43  }
   28.44  
   28.45 -void
   28.46 -PbbMessage::Ref (void) const
   28.47 -{
   28.48 -  m_refCount++;
   28.49 -}
   28.50 -
   28.51 -void
   28.52 -PbbMessage::Unref (void) const
   28.53 -{
   28.54 -  m_refCount--;
   28.55 -  if (m_refCount == 0)
   28.56 -    {
   28.57 -      delete this;
   28.58 -    }
   28.59 -}
   28.60 -
   28.61  uint32_t
   28.62  PbbMessage::GetSerializedSize (void) const
   28.63  {
   28.64 @@ -1699,13 +1666,10 @@
   28.65  /* End PbbMessageIpv6 Class */
   28.66  
   28.67  PbbAddressBlock::PbbAddressBlock ()
   28.68 -{
   28.69 -  m_refCount = 1;
   28.70 -}
   28.71 +{}
   28.72  
   28.73  PbbAddressBlock::~PbbAddressBlock ()
   28.74 -{
   28.75 -}
   28.76 +{}
   28.77  
   28.78  /* Manipulating the address block */
   28.79  
   28.80 @@ -2002,23 +1966,6 @@
   28.81  {
   28.82    m_addressTlvList.Clear();
   28.83  }
   28.84 -
   28.85 -void
   28.86 -PbbAddressBlock::Ref (void) const
   28.87 -{
   28.88 -  m_refCount++;
   28.89 -}
   28.90 -
   28.91 -void
   28.92 -PbbAddressBlock::Unref (void) const
   28.93 -{
   28.94 -  m_refCount--;
   28.95 -  if (m_refCount == 0)
   28.96 -    {
   28.97 -      delete this;
   28.98 -    }
   28.99 -}
  28.100 -
  28.101  uint32_t
  28.102  PbbAddressBlock::GetSerializedSize (void) const
  28.103  {
  28.104 @@ -2448,7 +2395,6 @@
  28.105  
  28.106  PbbTlv::PbbTlv (void)
  28.107  {
  28.108 -  m_refCount = 1;
  28.109    m_hasTypeExt = false;
  28.110    m_hasIndexStart = false;
  28.111    m_hasIndexStop = false;
  28.112 @@ -2573,22 +2519,6 @@
  28.113    return m_hasValue;
  28.114  }
  28.115  
  28.116 -void
  28.117 -PbbTlv::Ref (void) const
  28.118 -{
  28.119 -  m_refCount++;
  28.120 -}
  28.121 -
  28.122 -void
  28.123 -PbbTlv::Unref (void) const
  28.124 -{
  28.125 -  m_refCount--;
  28.126 -  if (m_refCount == 0)
  28.127 -    {
  28.128 -      delete this;
  28.129 -    }
  28.130 -}
  28.131 -
  28.132  uint32_t
  28.133  PbbTlv::GetSerializedSize (void) const
  28.134  {
    29.1 --- a/src/node/packetbb.h	Wed Nov 11 16:21:18 2009 +0100
    29.2 +++ b/src/node/packetbb.h	Thu Nov 12 13:01:01 2009 +0100
    29.3 @@ -31,6 +31,7 @@
    29.4  #include "ns3/address.h"
    29.5  #include "ns3/header.h"
    29.6  #include "ns3/buffer.h"
    29.7 +#include "ns3/simple-ref-count.h"
    29.8  
    29.9  namespace ns3 {
   29.10  
   29.11 @@ -360,7 +361,7 @@
   29.12   *
   29.13   * See: http://tools.ietf.org/html/rfc5444 for details.
   29.14   */
   29.15 -class PbbPacket : public Header
   29.16 +class PbbPacket : public SimpleRefCount<PbbPacket,Header>
   29.17  {
   29.18  public:
   29.19    typedef std::list< Ptr<PbbTlv> >::iterator TlvIterator;
   29.20 @@ -595,10 +596,6 @@
   29.21     */
   29.22    void MessageClear (void);
   29.23  
   29.24 -  /* Smart pointer methods */
   29.25 -  void Ref (void) const;
   29.26 -  void Unref (void) const;
   29.27 -
   29.28    /* Methods implemented by all headers */
   29.29    static TypeId GetTypeId (void);
   29.30    virtual TypeId GetInstanceTypeId (void) const;
   29.31 @@ -644,8 +641,6 @@
   29.32  
   29.33    bool m_hasseqnum;
   29.34    uint16_t m_seqnum;
   29.35 -
   29.36 -  mutable uint32_t m_refCount;
   29.37  };
   29.38  
   29.39  /**
   29.40 @@ -655,7 +650,7 @@
   29.41   * virtual base class, when creating a message, you should instantiate either
   29.42   * PbbMessageIpv4 or PbbMessageIpv6.
   29.43   */
   29.44 -class PbbMessage
   29.45 +class PbbMessage : public SimpleRefCount<PbbMessage>
   29.46  {
   29.47  public:
   29.48    typedef std::list< Ptr<PbbTlv> >::iterator TlvIterator;
   29.49 @@ -959,10 +954,6 @@
   29.50     */
   29.51    void AddressBlockClear (void);
   29.52  
   29.53 -  /* Smart pointer methods */
   29.54 -  void Ref (void) const;
   29.55 -  void Unref (void) const;
   29.56 -
   29.57    /**
   29.58     * \brief Deserializes a message, returning the correct object depending on
   29.59     *        whether it is an IPv4 message or an IPv6 message.
   29.60 @@ -1048,8 +1039,6 @@
   29.61  
   29.62    bool m_hasSequenceNumber;
   29.63    uint16_t m_sequenceNumber;
   29.64 -
   29.65 -  mutable uint32_t m_refCount;
   29.66  };
   29.67  
   29.68  /**
   29.69 @@ -1098,7 +1087,7 @@
   29.70   * This is a pure virtual base class, when creating address blocks, you should
   29.71   * instantiate either PbbAddressBlockIpv4 or PbbAddressBlockIpv6.
   29.72   */
   29.73 -class PbbAddressBlock
   29.74 +class PbbAddressBlock : public SimpleRefCount<PbbAddressBlock>
   29.75  {
   29.76  public:
   29.77    typedef std::list< Address >::iterator AddressIterator;
   29.78 @@ -1412,10 +1401,6 @@
   29.79     */
   29.80    void TlvClear (void);
   29.81  
   29.82 -  /* Smart pointer methods */
   29.83 -  void Ref (void) const;
   29.84 -  void Unref (void) const;
   29.85 -
   29.86    /**
   29.87     * \return The size (in bytes) needed to serialize this address block.
   29.88     */
   29.89 @@ -1475,8 +1460,6 @@
   29.90    std::list<Address> m_addressList;
   29.91    std::list<uint8_t> m_prefixList;
   29.92    PbbAddressTlvBlock m_addressTlvList;
   29.93 -
   29.94 -  mutable uint32_t m_refCount;
   29.95  };
   29.96  
   29.97  /**
   29.98 @@ -1520,11 +1503,11 @@
   29.99  /**
  29.100   * \brief A packet or message TLV
  29.101   */
  29.102 -class PbbTlv
  29.103 +class PbbTlv : public SimpleRefCount<PbbTlv>
  29.104  {
  29.105  public:
  29.106    PbbTlv (void);
  29.107 -  ~PbbTlv (void);
  29.108 +  virtual ~PbbTlv (void);
  29.109  
  29.110    /**
  29.111     * \brief Sets the type of this TLV.
  29.112 @@ -1599,10 +1582,6 @@
  29.113     */
  29.114    bool HasValue (void) const;
  29.115  
  29.116 -  /* Smart pointer methods */
  29.117 -  void Ref (void) const;
  29.118 -  void Unref (void) const;
  29.119 -
  29.120    /**
  29.121     * \return The size (in bytes) needed to serialize this TLV.
  29.122     */
  29.123 @@ -1672,8 +1651,6 @@
  29.124    bool m_isMultivalue;
  29.125    bool m_hasValue;
  29.126    Buffer m_value;
  29.127 -
  29.128 -  mutable uint32_t m_refCount;
  29.129  };
  29.130  
  29.131  /**
    30.1 --- a/src/simulator/event-impl.cc	Wed Nov 11 16:21:18 2009 +0100
    30.2 +++ b/src/simulator/event-impl.cc	Thu Nov 12 13:01:01 2009 +0100
    30.3 @@ -20,15 +20,13 @@
    30.4  
    30.5  #include "event-impl.h"
    30.6  
    30.7 -
    30.8  namespace ns3 {
    30.9  
   30.10  EventImpl::~EventImpl ()
   30.11  {}
   30.12  
   30.13  EventImpl::EventImpl ()
   30.14 -  : m_cancel (false),
   30.15 -    m_count (1)
   30.16 +  : m_cancel (false)
   30.17  {}
   30.18  
   30.19  void 
    31.1 --- a/src/simulator/event-impl.h	Wed Nov 11 16:21:18 2009 +0100
    31.2 +++ b/src/simulator/event-impl.h	Thu Nov 12 13:01:01 2009 +0100
    31.3 @@ -21,6 +21,7 @@
    31.4  #define EVENT_IMPL_H
    31.5  
    31.6  #include <stdint.h>
    31.7 +#include "ns3/simple-ref-count.h"
    31.8  
    31.9  namespace ns3 {
   31.10  
   31.11 @@ -35,12 +36,10 @@
   31.12   * most subclasses are usually created by one of the many Simulator::Schedule
   31.13   * methods.
   31.14   */
   31.15 -class EventImpl
   31.16 +class EventImpl : public SimpleRefCount<EventImpl>
   31.17  {
   31.18  public:
   31.19    EventImpl ();
   31.20 -  inline void Ref (void) const;
   31.21 -  inline void Unref (void) const;
   31.22    virtual ~EventImpl () = 0;
   31.23    /**
   31.24     * Called by the simulation engine to notify the event that it has expired.
   31.25 @@ -64,30 +63,8 @@
   31.26  
   31.27  private:
   31.28    bool m_cancel;
   31.29 -  mutable uint32_t m_count;
   31.30  };
   31.31  
   31.32 -}; // namespace ns3
   31.33 -
   31.34 -namespace ns3 {
   31.35 -
   31.36 -void
   31.37 -EventImpl::Ref (void) const
   31.38 -{
   31.39 -  m_count++;
   31.40 -}
   31.41 -
   31.42 -void
   31.43 -EventImpl::Unref (void) const
   31.44 -{
   31.45 -  uint32_t c;
   31.46 -  c = --m_count;
   31.47 -  if (c == 0)
   31.48 -    {
   31.49 -      delete this;
   31.50 -    }
   31.51 -}
   31.52 -
   31.53  } // namespace ns3
   31.54  
   31.55  #endif /* EVENT_IMPL_H */