A Discrete-Event Network Simulator
API
ns3::SimpleRefCount< T, PARENT, DELETER > Class Template Reference

A template-based reference counting class. More...

#include "simple-ref-count.h"

Inherits PARENT.

+ Collaboration diagram for ns3::SimpleRefCount< T, PARENT, DELETER >:

Public Member Functions

 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 

Private Attributes

uint32_t m_count
 The reference count. More...
 

Detailed Description

template<typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T>>
class ns3::SimpleRefCount< T, PARENT, DELETER >

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.

Note
If you are moving to this template from the RefCountBase class, you need to be careful to mark appropriately your destructor virtual if needed. i.e., if your class has subclasses, do mark your destructor virtual.

This template takes 3 arguments but only the first argument is mandatory:

Template Parameters
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 RBCO 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 73 of file simple-ref-count.h.

Constructor & Destructor Documentation

template<typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T>>
ns3::SimpleRefCount< T, PARENT, DELETER >::SimpleRefCount ( )
inline

Default constructor.

Definition at line 77 of file simple-ref-count.h.

template<typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T>>
ns3::SimpleRefCount< T, PARENT, DELETER >::SimpleRefCount ( const SimpleRefCount< T, PARENT, DELETER > &  o)
inline

Copy constructor.

Parameters
[in]oThe object to copy into this one.

Definition at line 84 of file simple-ref-count.h.

Member Function Documentation

template<typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T>>
uint32_t ns3::SimpleRefCount< T, PARENT, DELETER >::GetReferenceCount ( void  ) const
inline

Get the reference count of the object.

Normally not needed; for language bindings.

Returns
The reference count.

Definition at line 131 of file simple-ref-count.h.

Referenced by ns3::Object::CheckLoose(), and ns3::Object::DoDelete().

+ Here is the caller graph for this function:

template<typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T>>
SimpleRefCount& ns3::SimpleRefCount< T, PARENT, DELETER >::operator= ( const SimpleRefCount< T, PARENT, DELETER > &  o)
inline

Assignment operator.

Parameters
[in]oThe object to copy
Returns
The copy of o

Definition at line 94 of file simple-ref-count.h.

template<typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T>>
void ns3::SimpleRefCount< T, PARENT, DELETER >::Ref ( void  ) const
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 105 of file simple-ref-count.h.

template<typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T>>
void ns3::SimpleRefCount< T, PARENT, DELETER >::Unref ( void  ) const
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 116 of file simple-ref-count.h.

Referenced by ClearPtr(), ns3::DefaultSimulatorImpl::DoDispose(), ns3::NullMessageSimulatorImpl::DoDispose(), ns3::DistributedSimulatorImpl::DoDispose(), ns3::RealtimeSimulatorImpl::DoDispose(), ns3::DefaultSimulatorImpl::ProcessOneEvent(), ns3::NullMessageSimulatorImpl::ProcessOneEvent(), and ns3::DistributedSimulatorImpl::ProcessOneEvent().

+ Here is the caller graph for this function:

Member Data Documentation

template<typename T, typename PARENT = empty, typename DELETER = DefaultDeleter<T>>
uint32_t ns3::SimpleRefCount< T, PARENT, DELETER >::m_count
mutableprivate

The reference count.

Internal:
Note we make this mutable so that the const methods can still change it.

Definition at line 144 of file simple-ref-count.h.

Referenced by ns3::SimpleRefCount< LteChunkProcessor >::GetReferenceCount(), ns3::SimpleRefCount< LteChunkProcessor >::Ref(), and ns3::SimpleRefCount< LteChunkProcessor >::Unref().


The documentation for this class was generated from the following file: