A template-based reference counting class. More...
#include "simple-ref-count.h"
Inherits ns3::Empty.
Public Member Functions | |
SimpleRefCount () | |
Default constructor. | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment operator. | |
void | Ref () const |
Increment the reference count. | |
void | Unref () const |
Decrement the reference count. | |
Private Attributes | |
uint32_t | m_count |
The reference count. | |
A template-based reference counting class.
This template can be used to give reference-counting powers to a class. This template does not require this class to have a virtual destructor or a specific (or any) parent class.
This template takes 3 arguments but only the first argument is mandatory:
T | [explicit] The typename of the subclass which derives from this template class. Yes, this is weird but it's a common C++ template pattern whose name is CRTP (Curiously Recursive Template Pattern) |
PARENT | [explicit] The typename of the parent of this template. By default, this typename is "'ns3::Empty'" which is an empty class: compilers which implement the EBCO optimization (empty base class optimization) will make this a no-op |
DELETER | [explicit] The typename of a class which implements a public static method named 'Delete'. This method will be called whenever the SimpleRefCount template detects that no references to the object it manages exist anymore. |
Interesting users of this class include ns3::Object as well as ns3::Packet.
Definition at line 69 of file simple-ref-count.h.
|
inline |
|
inline |
Copy constructor.
[in] | o | The object to copy into this one. |
Definition at line 82 of file simple-ref-count.h.
|
inline |
Get the reference count of the object.
Normally not needed; for language bindings.
Definition at line 130 of file simple-ref-count.h.
References ns3::SimpleRefCount< T, PARENT, DELETER >::m_count.
Referenced by ns3::Object::CheckLoose(), and ns3::Object::DoDelete().
|
inline |
Assignment operator.
[in] | o | The object to copy |
Definition at line 92 of file simple-ref-count.h.
|
inline |
Increment the reference count.
This method should not be called by user code. SimpleRefCount instances are expected to be used in conjunction with the Ptr template which would make calling Ref unnecessary and dangerous.
Definition at line 103 of file simple-ref-count.h.
References ns3::SimpleRefCount< T, PARENT, DELETER >::m_count, and NS_ASSERT.
|
inline |
Decrement the reference count.
This method should not be called by user code. SimpleRefCount instances are expected to be used in conjunction with the Ptr template which would make calling Ref unnecessary and dangerous.
Definition at line 115 of file simple-ref-count.h.
References ns3::SimpleRefCount< T, PARENT, DELETER >::m_count.
Referenced by ns3::DefaultSimulatorImpl::DoDispose(), ns3::DistributedSimulatorImpl::DoDispose(), ns3::NullMessageSimulatorImpl::DoDispose(), ns3::RealtimeSimulatorImpl::DoDispose(), ns3::DefaultSimulatorImpl::ProcessOneEvent(), ns3::DistributedSimulatorImpl::ProcessOneEvent(), and ns3::NullMessageSimulatorImpl::ProcessOneEvent().
|
mutableprivate |
The reference count.
Definition at line 143 of file simple-ref-count.h.
Referenced by ns3::SimpleRefCount< T, PARENT, DELETER >::GetReferenceCount(), ns3::SimpleRefCount< T, PARENT, DELETER >::Ref(), and ns3::SimpleRefCount< T, PARENT, DELETER >::Unref().